Skip to content

Commit d229233

Browse files
authored
Merge pull request #139 from mhjacks/v1.4
Backport selected fixes for 1.4 branch
2 parents 2ab2c11 + 404e1af commit d229233

File tree

4 files changed

+147
-3
lines changed

4 files changed

+147
-3
lines changed

Diff for: .github/workflows/superlinter.yml

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
VALIDATE_YAML: false
3434
VALIDATE_ANSIBLE: false
3535
VALIDATE_DOCKERFILE_HADOLINT: false
36+
NATURAL_LANGUAGE: false
3637
# VALIDATE_MARKDOWN: false
3738
# VALIDATE_NATURAL_LANGUAGE: false
3839
#VALIDATE_TEKTON: false

Diff for: Changes.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
## Changes for v1.2 (February 9, 2023)
1616

17-
* Kiosk_mode improvements: kiosk_mode role now has a variable `kiosk_port` which influences the kiosk-mode script and controls which port firefox connects to. (Previously this was hard-coded to port 8088; the var defaults to 8088 so existing setups will continue to work. This will make it easier to tailor or customize the pattern to work with containers other than Ignition.
17+
* Kiosk_mode improvements: kiosk_mode role now has a variable `kiosk_port` which influences the kiosk-mode script and controls which port firefox connects to. (Previously this was hardcoded to port 8088; the var defaults to 8088 so existing setups will continue to work. This will make it easier to tailor or customize the pattern to work with containers other than Ignition.
1818

1919
* cloud-init changes: move the cloud-init configuration file, user, and password to secrets from edge-gitops-vms values. This was a regrettable oversight in v1.0 and v1.1.
2020

@@ -26,7 +26,7 @@
2626

2727
* No "visible" changes so not updating the branch pointer
2828

29-
* Updated ansible code to follow best practices and silent many linter warnings
29+
* Updated ansible code to follow best practices and silent many linting warnings
3030

3131
* Updated edge-gitops-vms chart to add SkipDryRunOnMissingResource annotations to prevent errors occuring due to race conditions with OpenShift Virtualization
3232

@@ -52,3 +52,5 @@
5252
* Update deploy_kubevirt_worker.yml Ansible playbook to copy securityGroups and blockDevices config from first machineSet. Tag naming schemes changed from OCP 4.15 to 4.16; this method ensures forward and backward compatibility.
5353
* Remove ODF overrides from OCP 4.12/3 that force storageClass to gp2; all released versions should use gp3-csi now.
5454
* Include overrides for OCP 4.12 and OCP 4.13 to use the older `ocs-storagecluster-ceph-rbd` storageClass.
55+
* Backport odf_fix_dataimportcrons.yml from development Ansible Edge GitOps/Federated Edge Observability and
56+
use stable channel for KubeVirt/OCP-V (3/25/2025)

Diff for: ansible/odf_fix_dataimportcrons.yml

+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
#!/usr/bin/env ansible-playbook
2+
---
3+
# This workaround was implemented to fix a problem where openshift-cnv would
4+
# not recognize a default virt storage class change and change the format of
5+
# datasources. The issue was fixed in OpenShift Virtualization 4.16.4.
6+
- name: Determine if we have PVC clean-up to do
7+
become: false
8+
connection: local
9+
hosts: localhost
10+
gather_facts: false
11+
vars:
12+
kubeconfig: "{{ lookup('env', 'KUBECONFIG') }}"
13+
dataimportcron_cleanup: false
14+
image_cleanup_namespace: "openshift-virtualization-os-images"
15+
cluster_version: "{{ global['clusterVersion'] | default('UNSET') }}"
16+
tasks:
17+
- name: Check cluster version
18+
ansible.builtin.debug:
19+
var: cluster_version
20+
21+
- name: Exit if normal version check is not right
22+
ansible.builtin.meta: end_play
23+
when: cluster_version not in [ '4.16', '4.17', '4.18', 'UNSET' ]
24+
25+
- name: Find default storageclass
26+
ansible.builtin.shell: |
27+
set -o pipefail
28+
oc get storageclass -o json | jq -r '.items[] | select(.metadata.annotations."storageclass.kubernetes.io/is-default-class")'
29+
register: default_sc_output
30+
changed_when: false
31+
32+
- name: Find virtualization default storageclass
33+
ansible.builtin.shell: |
34+
set -o pipefail
35+
oc get storageclass -o json | jq -r '.items[] | select(.metadata.annotations."storageclass.kubevirt.io/is-default-virt-class")'
36+
register: default_virt_sc_output
37+
changed_when: false
38+
39+
- name: Compare default virtualization storageclass and default storageclass to determine whether to clean PVCs
40+
block:
41+
- name: Parse results
42+
ansible.builtin.set_fact:
43+
default_sc: '{{ default_sc_output.stdout | from_json }}'
44+
default_virt_sc: '{{ default_virt_sc_output.stdout | from_json }}'
45+
46+
- name: Commit to dataimportcron cleanup
47+
ansible.builtin.set_fact:
48+
dataimportcron_cleanup: true
49+
when:
50+
- default_virt_sc.metadata.name == "ocs-storagecluster-ceph-rbd-virtualization"
51+
- default_sc.metadata.name != default_virt_sc.metadata.name
52+
rescue:
53+
- name: Note that we exited
54+
ansible.builtin.debug:
55+
msg: "Caught an error before we could determine to clean up dataimportcrons, exiting"
56+
57+
- name: End play (successfully)
58+
ansible.builtin.meta: end_play
59+
60+
- name: Cleanup incorrect datasourceimport images (PVCs)
61+
when:
62+
- dataimportcron_cleanup
63+
block:
64+
- name: Find dataimportcrons
65+
kubernetes.core.k8s_info:
66+
kind: dataimportcron
67+
namespace: '{{ image_cleanup_namespace }}'
68+
api_version: cdi.kubevirt.io/v1beta1
69+
register: dic_list
70+
71+
- name: Extract dic names
72+
ansible.builtin.set_fact:
73+
dic_names: "{{ dic_names | default([]) + [ item.metadata.name ] }}"
74+
loop: "{{ dic_list.resources }}"
75+
76+
- name: Show names
77+
ansible.builtin.debug:
78+
var: dic_names
79+
80+
- name: Find datasources to cleanup
81+
kubernetes.core.k8s_info:
82+
kind: datasource
83+
namespace: '{{ image_cleanup_namespace }}'
84+
api_version: cdi.kubevirt.io/v1beta1
85+
register: ds_cleanup_list
86+
87+
- name: Keep track of objects to remove
88+
ansible.builtin.set_fact:
89+
cron_cleanups: []
90+
ds_cleanups: []
91+
92+
- name: Record datasources that need cleanup
93+
ansible.builtin.set_fact:
94+
cron_cleanups: "{{ cron_cleanups + [ item.metadata.labels['cdi.kubevirt.io/dataImportCron'] ] }}"
95+
ds_cleanups: "{{ ds_cleanups + [ item.metadata.name ] }}"
96+
loop: "{{ ds_cleanup_list.resources }}"
97+
when:
98+
- item['metadata']['labels']['cdi.kubevirt.io/dataImportCron'] is defined
99+
- item['metadata']['labels']['cdi.kubevirt.io/dataImportCron'] in dic_names
100+
- item.status.conditions[0].message != "DataSource is ready to be consumed"
101+
102+
- name: Check on removables
103+
ansible.builtin.debug:
104+
msg:
105+
- "cron_cleanups: {{ cron_cleanups }}"
106+
- "ds_cleanups: {{ ds_cleanups }}"
107+
108+
- name: Delete datasources in cleanup list
109+
kubernetes.core.k8s:
110+
kind: datasource
111+
namespace: '{{ image_cleanup_namespace }}'
112+
api_version: cdi.kubevirt.io/v1beta1
113+
name: "{{ item }}"
114+
state: absent
115+
loop: "{{ ds_cleanups }}"
116+
117+
- name: Delete datavolumes in cleanup list
118+
kubernetes.core.k8s:
119+
kind: datavolume
120+
namespace: '{{ image_cleanup_namespace }}'
121+
api_version: cdi.kubevirt.io/v1beta1
122+
label_selectors:
123+
- 'cdi.kubevirt.io/dataImportCron={{ item }}'
124+
state: absent
125+
loop: "{{ cron_cleanups }}"
126+
127+
- name: Delete dataimportcrons in cleanup list
128+
kubernetes.core.k8s:
129+
kind: dataimportcron
130+
namespace: '{{ image_cleanup_namespace }}'
131+
api_version: cdi.kubevirt.io/v1beta1
132+
name: "{{ item }}"
133+
state: absent
134+
loop: "{{ cron_cleanups }}"
135+
rescue:
136+
- name: Note that we exited
137+
ansible.builtin.debug:
138+
msg: "Caught an error while cleaning up dataimportcrons, exiting"

Diff for: values-hub.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ clusterGroup:
1919
openshift-virtualization:
2020
name: kubevirt-hyperconverged
2121
namespace: openshift-cnv
22+
channel: stable
2223

2324
openshift-data-foundation:
2425
name: odf-operator
@@ -33,7 +34,7 @@ clusterGroup:
3334
playbook: ansible/deploy_kubevirt_worker.yml
3435
verbosity: -vvv
3536
- name: clean-golden-images
36-
playbook: ansible/odf_clean_pvcs.yml
37+
playbook: ansible/odf_fix_dataimportcrons.yml
3738
image: quay.io/hybridcloudpatterns/utility-container:latest
3839
verbosity: -vvv
3940
- name: configure-aap-controller
@@ -48,6 +49,8 @@ clusterGroup:
4849
- machinesets
4950
- persistentvolumeclaims
5051
- datavolumes
52+
- datasources
53+
- dataimportcrons
5154
verbs:
5255
- "*"
5356
- apiGroups:

0 commit comments

Comments
 (0)