diff --git a/cmd/openstack-populator/openstack-populator.go b/cmd/openstack-populator/openstack-populator.go index fad2ad622..a7e9e78c8 100644 --- a/cmd/openstack-populator/openstack-populator.go +++ b/cmd/openstack-populator/openstack-populator.go @@ -90,7 +90,7 @@ func downloadAndSaveImage(client *libclient.Client, config *AppConfig) { func createProgressCounter() *prometheus.CounterVec { progressVec := prometheus.NewCounterVec( prometheus.CounterOpts{ - Name: "openstack_populator_progress", + Name: "openstack_populator_progress_total", Help: "Progress of volume population", }, []string{"ownerUID"}, diff --git a/cmd/ovirt-populator/ovirt-populator.go b/cmd/ovirt-populator/ovirt-populator.go index ea7562884..472d63910 100644 --- a/cmd/ovirt-populator/ovirt-populator.go +++ b/cmd/ovirt-populator/ovirt-populator.go @@ -109,7 +109,7 @@ func executePopulationProcess(config *engineConfig, diskID, volPath, ownerUID st func monitorProgress(scanner *bufio.Scanner, ownerUID string, pvcSize int64, done chan struct{}) { progress := prometheus.NewCounterVec( prometheus.CounterOpts{ - Name: "ovirt_progress", + Name: "ovirt_populator_progress_total", Help: "Progress of volume population", }, []string{"ownerUID"}, diff --git a/operator/BUILD.bazel b/operator/BUILD.bazel index 0a1a21714..9e5536999 100644 --- a/operator/BUILD.bazel +++ b/operator/BUILD.bazel @@ -70,8 +70,6 @@ container_image( ":bundle/manifests/forklift.konveyor.io_hosts.yaml", ":bundle/manifests/forklift.konveyor.io_migrations.yaml", ":bundle/manifests/forklift.konveyor.io_networkmaps.yaml", - ":bundle/manifests/forklift.konveyor.io_openstackvolumepopulators.yaml", - ":bundle/manifests/forklift.konveyor.io_ovirtvolumepopulators.yaml", ":bundle/manifests/forklift.konveyor.io_plans.yaml", ":bundle/manifests/forklift.konveyor.io_providers.yaml", ":bundle/manifests/forklift.konveyor.io_storagemaps.yaml", diff --git a/operator/config/manifests/bases/forklift-operator.clusterserviceversion.yaml b/operator/config/manifests/bases/forklift-operator.clusterserviceversion.yaml index a5cbc37c0..3aa417340 100644 --- a/operator/config/manifests/bases/forklift-operator.clusterserviceversion.yaml +++ b/operator/config/manifests/bases/forklift-operator.clusterserviceversion.yaml @@ -72,16 +72,6 @@ spec: kind: Hook name: hooks.forklift.konveyor.io version: v1beta1 - - description: oVirt Volume Populator - displayName: OvirtVolumePopulator - kind: OvirtVolumePopulator - name: ovirtvolumepopulators.forklift.konveyor.io - version: v1beta1 - - description: OpenStack Volume Populator - displayName: OpenstackVolumePopulator - kind: OpenstackVolumePopulator - name: openstackvolumepopulators.forklift.konveyor.io - version: v1beta1 description: | The Forklift Operator fully manages the deployment and life cycle of Forklift on [OpenShift](https://www.openshift.com/). diff --git a/operator/config/samples/forklift_v1beta1_forkliftcontroller.yaml b/operator/config/samples/forklift_v1beta1_forkliftcontroller.yaml index 222fec928..175254acc 100644 --- a/operator/config/samples/forklift_v1beta1_forkliftcontroller.yaml +++ b/operator/config/samples/forklift_v1beta1_forkliftcontroller.yaml @@ -8,3 +8,4 @@ spec: feature_ui_plugin: 'true' feature_validation: 'true' feature_volume_populator: 'true' + populator_replicas: 0 diff --git a/operator/roles/forkliftcontroller/tasks/main.yml b/operator/roles/forkliftcontroller/tasks/main.yml index 7ea557bbf..f7ae59569 100644 --- a/operator/roles/forkliftcontroller/tasks/main.yml +++ b/operator/roles/forkliftcontroller/tasks/main.yml @@ -20,6 +20,40 @@ set_fact: api_groups: "{{ lookup('k8s', cluster_info='api_groups') }}" + - name: Read the service account token + slurp: + src: /var/run/secrets/kubernetes.io/serviceaccount/token + register: sa_token + + - name: Decode the service account token + set_fact: + k8s_auth_token: "{{ sa_token['content'] | b64decode }}" + + - name: Get Kubernetes version information + uri: + url: https://kubernetes.default.svc/version + method: GET + headers: + Authorization: "Bearer {{ k8s_auth_token }}" + validate_certs: no + register: version_info + + - name: Print Kubernetes version information for debugging + debug: + msg: "Kubernetes version: {{ version_info.json }}" + + - name: Extract major version + set_fact: + major_version: "{{ version_info.json.major | int }}" + + - name: Extract and clean minor version + set_fact: + minor_version: "{{ version_info.json.minor | regex_replace('[^0-9]', '') | int }}" + + - name: Check Kubernetes version and set replicas + set_fact: + populator_replicas: "{{ 1 if (major_version > 1) or (major_version == 1 and minor_version > 28) else 0 }}" + - when: "'route.openshift.io' not in api_groups" block: - name: "Enable k8s cluster environment" @@ -85,6 +119,7 @@ k8s: state: "{{ volume_populator_state }}" definition: "{{ lookup('template', 'populator/deployment-populator-controller.yml.j2') }}" + replicas: "{{ populator_replicas }}" - when: k8s_cluster|bool block: diff --git a/pkg/lib-volume-populator/populator-machinery/controller.go b/pkg/lib-volume-populator/populator-machinery/controller.go index d075b7170..e228199cb 100644 --- a/pkg/lib-volume-populator/populator-machinery/controller.go +++ b/pkg/lib-volume-populator/populator-machinery/controller.go @@ -830,7 +830,7 @@ func (c *controller) updatePvc(ctx context.Context, pvc *corev1.PersistentVolume func (c *controller) updateProgress(pod *corev1.Pod, pvc *corev1.PersistentVolumeClaim, cr *unstructured.Unstructured) error { populatorKind := pvc.Spec.DataSourceRef.Kind - importRegExp := regexp.MustCompile("progress\\{ownerUID=\"" + string(pvc.UID) + "\"\\} (\\d+\\.?\\d*)") + importRegExp := regexp.MustCompile("progress_total\\{ownerUID=\"" + string(pvc.UID) + "\"\\} (\\d+\\.?\\d*)") url, err := getMetricsURL(pod) if err != nil {