Skip to content

Commit 198e792

Browse files
authored
Merge pull request #117 from mhjacks/main
Fixes for 4.15+ for new ODF and CNV behaviors
2 parents 787d9e2 + 54f18dc commit 198e792

10 files changed

+117
-11
lines changed

Changes.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,9 @@
4242
* Remove support for 4.10 (since it is out of support)
4343
* Update platform level override using new templated valuefile name feature in common
4444
* Skip multicloud gateway (noobaa) installation in ODF by default
45+
46+
## Changes in main (July 25, 2024)
47+
48+
* Introduce clean-golden-images job to imperative. This is a workaround for a bug in CNV 4.15/ODF 4.15 where if the default StorageClass is not the same as the default virtualization storage class, CNV cannot properly provision datavolumes.
49+
* Default storageclass for edge-gitops-vms to "ocs-storagecluster-ceph-rbd-virtualization", available since ODF 4.14.
50+
* Use api_version for Route queries when discovering credentials for AAP instance.

ansible/ansible_get_credentials.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
tasks:
1111
- name: Retrieve API hostname for AAP
1212
kubernetes.core.k8s_info:
13+
api_version: route.openshift.io/v1
1314
kind: Route
1415
namespace: ansible-automation-platform
1516
name: controller

ansible/odf_clean_pvcs.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/usr/bin/env ansible-playbook
2+
---
3+
- name: Determine if we have PVC clean-up to do
4+
become: false
5+
connection: local
6+
hosts: localhost
7+
gather_facts: false
8+
vars:
9+
kubeconfig: "{{ lookup('env', 'KUBECONFIG') }}"
10+
pvc_cleanup: false
11+
image_cleanup_namespace: "openshift-virtualization-os-images"
12+
dv_namespace: edge-gitops-vms
13+
dv_remove_timeout: 1800
14+
dv_remove_status: ["Pending"]
15+
ts_fmt: '%Y-%m-%dT%H:%M:%SZ'
16+
tasks:
17+
- name: Find default storageclass
18+
ansible.builtin.shell: |
19+
set -o pipefail
20+
oc get storageclass -o json | jq -r '.items[] | select(.metadata.annotations."storageclass.kubernetes.io/is-default-class")'
21+
register: default_sc_output
22+
changed_when: false
23+
24+
- name: Find virtualization default storageclass
25+
ansible.builtin.shell: |
26+
set -o pipefail
27+
oc get storageclass -o json | jq -r '.items[] | select(.metadata.annotations."storageclass.kubevirt.io/is-default-virt-class")'
28+
register: default_virt_sc_output
29+
changed_when: false
30+
31+
- name: Compare default virtualization storageclass and default storageclass to determine whether to clean PVCs
32+
block:
33+
- name: Parse results
34+
ansible.builtin.set_fact:
35+
default_sc: '{{ default_sc_output.stdout | from_json }}'
36+
default_virt_sc: '{{ default_virt_sc_output.stdout | from_json }}'
37+
38+
- name: Commit to PVC cleanup
39+
ansible.builtin.set_fact:
40+
pvc_cleanup: true
41+
when:
42+
- default_virt_sc.metadata.name == "ocs-storagecluster-ceph-rbd-virtualization"
43+
- default_sc.metadata.name != default_virt_sc.metadata.name
44+
rescue:
45+
- name: Note that we exited
46+
ansible.builtin.debug:
47+
msg: "Caught an error before we could determine to clean up PVCs, exiting"
48+
49+
- name: Cleanup incorrect datasourceimport images (PVCs)
50+
when:
51+
- pvc_cleanup
52+
block:
53+
- name: Find PVCs
54+
kubernetes.core.k8s_info:
55+
kind: pvc
56+
namespace: '{{ image_cleanup_namespace }}'
57+
register: pvc_cleanup_list
58+
59+
- name: Remove stray datasource PVCs
60+
kubernetes.core.k8s:
61+
kind: pvc
62+
namespace: '{{ image_cleanup_namespace }}'
63+
name: '{{ item.metadata.name }}'
64+
state: absent
65+
loop: "{{ pvc_cleanup_list.resources }}"
66+
when:
67+
- item.spec.storageClassName != default_virt_sc.metadata.name
68+
69+
- name: Check for stuck datavolumes
70+
kubernetes.core.k8s_info:
71+
namespace: '{{ dv_namespace }}'
72+
kind: DataVolume
73+
api_version: cdi.kubevirt.io/v1beta1
74+
register: vm_ds
75+
76+
- name: Remove stuck datavolume if needed
77+
kubernetes.core.k8s:
78+
name: "{{ item.metadata.name }}"
79+
namespace: "{{ item.metadata.namespace }}"
80+
kind: "{{ item.kind }}"
81+
api_version: "{{ item.apiVersion }}"
82+
state: absent
83+
when:
84+
- item.status.phase in dv_remove_status
85+
- (now(utc=true) - (item.metadata.creationTimestamp|to_datetime(ts_fmt))).seconds >= dv_remove_timeout
86+
loop: '{{ vm_ds.resources }}'
87+
88+
rescue:
89+
- name: Note that we exited
90+
ansible.builtin.debug:
91+
msg: "Caught an error while cleaning up PVCs, exiting"

charts/hub/edge-gitops-vms/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cloudInitDefaultSecretName: secret/data/hub/cloud-init
1111
# Or "RWO" and "gp2"; other choices are possible too but
1212
# these are defaults for ODF which is included in the pattern
1313
defaultAccessMode: "ReadWriteMany"
14-
defaultStorageClassName: "ocs-storagecluster-ceph-rbd"
14+
defaultStorageClassName: "ocs-storagecluster-ceph-rbd-virtualization"
1515
defaultVolumeMode: "Block"
1616

1717
vmNamespace: edge-gitops-vms

tests/hub-edge-gitops-vms-industrial-edge-factory.expected.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ items:
181181
resources:
182182
requests:
183183
storage: 30Gi
184-
storageClassName: ocs-storagecluster-ceph-rbd
184+
storageClassName: ocs-storagecluster-ceph-rbd-virtualization
185185
volumeMode: Block
186186
running: true
187187
template:
@@ -319,7 +319,7 @@ items:
319319
resources:
320320
requests:
321321
storage: 30Gi
322-
storageClassName: ocs-storagecluster-ceph-rbd
322+
storageClassName: ocs-storagecluster-ceph-rbd-virtualization
323323
volumeMode: Block
324324
running: true
325325
template:

tests/hub-edge-gitops-vms-industrial-edge-hub.expected.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ items:
181181
resources:
182182
requests:
183183
storage: 30Gi
184-
storageClassName: ocs-storagecluster-ceph-rbd
184+
storageClassName: ocs-storagecluster-ceph-rbd-virtualization
185185
volumeMode: Block
186186
running: true
187187
template:
@@ -319,7 +319,7 @@ items:
319319
resources:
320320
requests:
321321
storage: 30Gi
322-
storageClassName: ocs-storagecluster-ceph-rbd
322+
storageClassName: ocs-storagecluster-ceph-rbd-virtualization
323323
volumeMode: Block
324324
running: true
325325
template:

tests/hub-edge-gitops-vms-medical-diagnosis-hub.expected.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ items:
181181
resources:
182182
requests:
183183
storage: 30Gi
184-
storageClassName: ocs-storagecluster-ceph-rbd
184+
storageClassName: ocs-storagecluster-ceph-rbd-virtualization
185185
volumeMode: Block
186186
running: true
187187
template:
@@ -319,7 +319,7 @@ items:
319319
resources:
320320
requests:
321321
storage: 30Gi
322-
storageClassName: ocs-storagecluster-ceph-rbd
322+
storageClassName: ocs-storagecluster-ceph-rbd-virtualization
323323
volumeMode: Block
324324
running: true
325325
template:

tests/hub-edge-gitops-vms-naked.expected.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ items:
181181
resources:
182182
requests:
183183
storage: 30Gi
184-
storageClassName: ocs-storagecluster-ceph-rbd
184+
storageClassName: ocs-storagecluster-ceph-rbd-virtualization
185185
volumeMode: Block
186186
running: true
187187
template:
@@ -319,7 +319,7 @@ items:
319319
resources:
320320
requests:
321321
storage: 30Gi
322-
storageClassName: ocs-storagecluster-ceph-rbd
322+
storageClassName: ocs-storagecluster-ceph-rbd-virtualization
323323
volumeMode: Block
324324
running: true
325325
template:

tests/hub-edge-gitops-vms-normal.expected.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ items:
181181
resources:
182182
requests:
183183
storage: 30Gi
184-
storageClassName: ocs-storagecluster-ceph-rbd
184+
storageClassName: ocs-storagecluster-ceph-rbd-virtualization
185185
volumeMode: Block
186186
running: true
187187
template:
@@ -319,7 +319,7 @@ items:
319319
resources:
320320
requests:
321321
storage: 30Gi
322-
storageClassName: ocs-storagecluster-ceph-rbd
322+
storageClassName: ocs-storagecluster-ceph-rbd-virtualization
323323
volumeMode: Block
324324
running: true
325325
template:

values-hub.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ clusterGroup:
3232
- name: deploy-kubevirt-worker
3333
playbook: ansible/deploy_kubevirt_worker.yml
3434
verbosity: -vvv
35+
- name: clean-golden-images
36+
playbook: ansible/odf_clean_pvcs.yml
37+
image: quay.io/hybridcloudpatterns/utility-container:latest
38+
verbosity: -vvv
3539
- name: configure-aap-controller
3640
playbook: ansible/imperative_configure_controller.yml
3741
image: quay.io/hybridcloudpatterns/ansible-edge-gitops-ee:latest
@@ -42,6 +46,8 @@ clusterGroup:
4246
- "*"
4347
resources:
4448
- machinesets
49+
- persistentvolumeclaims
50+
- datavolumes
4551
verbs:
4652
- "*"
4753
- apiGroups:
@@ -95,6 +101,8 @@ clusterGroup:
95101
namespace: edge-gitops-vms
96102
project: hub
97103
path: charts/hub/edge-gitops-vms
104+
extraValueFiles:
105+
- '/overrides/values-egv-{{ $.Values.global.clusterVersion }}.yaml'
98106

99107
# Only the hub cluster here - managed entities are edge nodes
100108
managedClusterGroups: []

0 commit comments

Comments
 (0)