Skip to content

Commit

Permalink
Update operator and CRDs
Browse files Browse the repository at this point in the history
- Scale down volume-populator-controller deployment when OCP is >= 4.16
- Update progress regex to match CDI

Signed-off-by: Benny Zlotnik <[email protected]>
  • Loading branch information
bennyz committed May 23, 2024
1 parent db63c57 commit 48b9b60
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cmd/openstack-populator/openstack-populator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
2 changes: 1 addition & 1 deletion cmd/ovirt-populator/ovirt-populator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
2 changes: 0 additions & 2 deletions operator/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ spec:
feature_ui_plugin: 'true'
feature_validation: 'true'
feature_volume_populator: 'true'
populator_replicas: 0
35 changes: 35 additions & 0 deletions operator/roles/forkliftcontroller/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pkg/lib-volume-populator/populator-machinery/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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*)")

Check warning on line 833 in pkg/lib-volume-populator/populator-machinery/controller.go

View check run for this annotation

Codecov / codecov/patch

pkg/lib-volume-populator/populator-machinery/controller.go#L833

Added line #L833 was not covered by tests

url, err := getMetricsURL(pod)
if err != nil {
Expand Down

0 comments on commit 48b9b60

Please sign in to comment.