diff --git a/Changes.md b/Changes.md index b984ca9a..3c42ab6a 100644 --- a/Changes.md +++ b/Changes.md @@ -77,3 +77,5 @@ * Update Ansible linter * Require metal nodes as workers - remove code to create machinesets * Add ODF console plugin +* Remove dataimportcron and PVC cleanup, as the underlying issues were fixed in 4.17 +* Remove now obsolete ansible code and shell scripts diff --git a/ansible/odf_clean_pvcs.yml b/ansible/odf_clean_pvcs.yml deleted file mode 100644 index 2380fcb7..00000000 --- a/ansible/odf_clean_pvcs.yml +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/env ansible-playbook ---- -- name: Determine if we have PVC clean-up to do - become: false - connection: local - hosts: localhost - gather_facts: false - vars: - kubeconfig: "{{ lookup('env', 'KUBECONFIG') }}" - pvc_cleanup: false - image_cleanup_namespace: "openshift-virtualization-os-images" - dv_namespace: edge-gitops-vms - dv_remove_timeout: 1800 - dv_remove_status: ["Pending"] - ts_fmt: '%Y-%m-%dT%H:%M:%SZ' - tasks: - - name: Find default storageclass - ansible.builtin.shell: | - set -o pipefail - oc get storageclass -o json | jq -r '.items[] | select(.metadata.annotations."storageclass.kubernetes.io/is-default-class")' - register: default_sc_output - changed_when: false - - - name: Find virtualization default storageclass - ansible.builtin.shell: | - set -o pipefail - oc get storageclass -o json | jq -r '.items[] | select(.metadata.annotations."storageclass.kubevirt.io/is-default-virt-class")' - register: default_virt_sc_output - changed_when: false - - - name: Compare default virtualization storageclass and default storageclass to determine whether to clean PVCs - block: - - name: Parse results - ansible.builtin.set_fact: - default_sc: '{{ default_sc_output.stdout | from_json }}' - default_virt_sc: '{{ default_virt_sc_output.stdout | from_json }}' - - - name: Commit to PVC cleanup - ansible.builtin.set_fact: - pvc_cleanup: true - when: - - default_virt_sc.metadata.name == "ocs-storagecluster-ceph-rbd-virtualization" - - default_sc.metadata.name != default_virt_sc.metadata.name - rescue: - - name: Note that we exited - ansible.builtin.debug: - msg: "Caught an error before we could determine to clean up PVCs, exiting" - - - name: Cleanup incorrect datasourceimport images (PVCs) - when: - - pvc_cleanup - block: - - name: Find PVCs - kubernetes.core.k8s_info: - kind: pvc - namespace: '{{ image_cleanup_namespace }}' - register: pvc_cleanup_list - - - name: Remove stray datasource PVCs - kubernetes.core.k8s: - kind: pvc - namespace: '{{ image_cleanup_namespace }}' - name: '{{ item.metadata.name }}' - state: absent - loop: "{{ pvc_cleanup_list.resources }}" - when: - - item.spec.storageClassName != default_virt_sc.metadata.name - - - name: Check for stuck datavolumes - kubernetes.core.k8s_info: - namespace: '{{ dv_namespace }}' - kind: DataVolume - api_version: cdi.kubevirt.io/v1beta1 - register: vm_ds - - - name: Remove stuck datavolume if needed - kubernetes.core.k8s: - name: "{{ item.metadata.name }}" - namespace: "{{ item.metadata.namespace }}" - kind: "{{ item.kind }}" - api_version: "{{ item.apiVersion }}" - state: absent - when: - - item.status.phase in dv_remove_status - - (now(utc=true) - (item.metadata.creationTimestamp|to_datetime(ts_fmt))).seconds >= dv_remove_timeout - loop: '{{ vm_ds.resources }}' - - rescue: - - name: Note that we exited - ansible.builtin.debug: - msg: "Caught an error while cleaning up PVCs, exiting" diff --git a/ansible/odf_fix_dataimportcrons.yml b/ansible/odf_fix_dataimportcrons.yml deleted file mode 100644 index d0f741a7..00000000 --- a/ansible/odf_fix_dataimportcrons.yml +++ /dev/null @@ -1,138 +0,0 @@ -#!/usr/bin/env ansible-playbook ---- -# This workaround was implemented to fix a problem where openshift-cnv would -# not recognize a default virt storage class change and change the format of -# datasources. The issue was fixed in OpenShift Virtualization 4.16.4. -- name: Determine if we have PVC clean-up to do - become: false - connection: local - hosts: localhost - gather_facts: false - vars: - kubeconfig: "{{ lookup('env', 'KUBECONFIG') }}" - dataimportcron_cleanup: false - image_cleanup_namespace: "openshift-virtualization-os-images" - cluster_version: "{{ global['clusterVersion'] | default('UNSET') }}" - tasks: - - name: Check cluster version - ansible.builtin.debug: - var: cluster_version - - - name: Exit if normal version check is not right - ansible.builtin.meta: end_play - when: cluster_version not in [ '4.17', '4.16', 'UNSET' ] - - - name: Find default storageclass - ansible.builtin.shell: | - set -o pipefail - oc get storageclass -o json | jq -r '.items[] | select(.metadata.annotations."storageclass.kubernetes.io/is-default-class")' - register: default_sc_output - changed_when: false - - - name: Find virtualization default storageclass - ansible.builtin.shell: | - set -o pipefail - oc get storageclass -o json | jq -r '.items[] | select(.metadata.annotations."storageclass.kubevirt.io/is-default-virt-class")' - register: default_virt_sc_output - changed_when: false - - - name: Compare default virtualization storageclass and default storageclass to determine whether to clean PVCs - block: - - name: Parse results - ansible.builtin.set_fact: - default_sc: '{{ default_sc_output.stdout | from_json }}' - default_virt_sc: '{{ default_virt_sc_output.stdout | from_json }}' - - - name: Commit to dataimportcron cleanup - ansible.builtin.set_fact: - dataimportcron_cleanup: true - when: - - default_virt_sc.metadata.name == "ocs-storagecluster-ceph-rbd-virtualization" - - default_sc.metadata.name != default_virt_sc.metadata.name - rescue: - - name: Note that we exited - ansible.builtin.debug: - msg: "Caught an error before we could determine to clean up dataimportcrons, exiting" - - - name: End play (successfully) - ansible.builtin.meta: end_play - - - name: Cleanup incorrect datasourceimport images (PVCs) - when: - - dataimportcron_cleanup - block: - - name: Find dataimportcrons - kubernetes.core.k8s_info: - kind: dataimportcron - namespace: '{{ image_cleanup_namespace }}' - api_version: cdi.kubevirt.io/v1beta1 - register: dic_list - - - name: Extract dic names - ansible.builtin.set_fact: - dic_names: "{{ dic_names | default([]) + [ item.metadata.name ] }}" - loop: "{{ dic_list.resources }}" - - - name: Show names - ansible.builtin.debug: - var: dic_names - - - name: Find datasources to cleanup - kubernetes.core.k8s_info: - kind: datasource - namespace: '{{ image_cleanup_namespace }}' - api_version: cdi.kubevirt.io/v1beta1 - register: ds_cleanup_list - - - name: Keep track of objects to remove - ansible.builtin.set_fact: - cron_cleanups: [] - ds_cleanups: [] - - - name: Record datasources that need cleanup - ansible.builtin.set_fact: - cron_cleanups: "{{ cron_cleanups + [ item.metadata.labels['cdi.kubevirt.io/dataImportCron'] ] }}" - ds_cleanups: "{{ ds_cleanups + [ item.metadata.name ] }}" - loop: "{{ ds_cleanup_list.resources }}" - when: - - item['metadata']['labels']['cdi.kubevirt.io/dataImportCron'] is defined - - item['metadata']['labels']['cdi.kubevirt.io/dataImportCron'] in dic_names - - item.status.conditions[0].message != "DataSource is ready to be consumed" - - - name: Check on removables - ansible.builtin.debug: - msg: - - "cron_cleanups: {{ cron_cleanups }}" - - "ds_cleanups: {{ ds_cleanups }}" - - - name: Delete datasources in cleanup list - kubernetes.core.k8s: - kind: datasource - namespace: '{{ image_cleanup_namespace }}' - api_version: cdi.kubevirt.io/v1beta1 - name: "{{ item }}" - state: absent - loop: "{{ ds_cleanups }}" - - - name: Delete datavolumes in cleanup list - kubernetes.core.k8s: - kind: datavolume - namespace: '{{ image_cleanup_namespace }}' - api_version: cdi.kubevirt.io/v1beta1 - label_selectors: - - 'cdi.kubevirt.io/dataImportCron={{ item }}' - state: absent - loop: "{{ cron_cleanups }}" - - - name: Delete dataimportcrons in cleanup list - kubernetes.core.k8s: - kind: dataimportcron - namespace: '{{ image_cleanup_namespace }}' - api_version: cdi.kubevirt.io/v1beta1 - name: "{{ item }}" - state: absent - loop: "{{ cron_cleanups }}" - rescue: - - name: Note that we exited - ansible.builtin.debug: - msg: "Caught an error while cleaning up dataimportcrons, exiting" diff --git a/scripts/ansible_load_controller.sh b/scripts/ansible_load_controller.sh deleted file mode 100755 index 679d14d4..00000000 --- a/scripts/ansible_load_controller.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env ansible-playbook ---- -- name: Retrieve AAP credentials - ansible.builtin.import_playbook: ../ansible/ansible_get_credentials.yml - -- name: Parse secrets from local values_secret.yaml file - ansible.builtin.import_playbook: ../ansible/parse_secrets_from_values_secret.yml - -- name: Configure AAP instance - ansible.builtin.import_playbook: ../ansible/ansible_configure_controller.yml diff --git a/scripts/get_image_urls.sh b/scripts/get_image_urls.sh deleted file mode 100755 index 8b080337..00000000 --- a/scripts/get_image_urls.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env ansible-playbook ---- -- name: "Retrieve RHEL image(s)" - become: false - connection: local - hosts: localhost - gather_facts: false - vars: - kubeconfig: "{{ lookup('env', 'KUBECONFIG') }}" - refresh_token_file: "{{ lookup('env', 'REFRESH_TOKEN_FILE') }}" - refresh_token_contents: "{{ lookup('file', refresh_token_file) }}" - redhat_sso_url: 'https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token' - redhat_api_url: https://api.access.redhat.com/management/v1 - image_checksums: - # rhel-8.5-x86_64-kvm.qcow2 - #- "9b63267716fa557f76df4899fb6a591c4c8a6ae2828f6297458815bff55ce8cc" - # rhel-8.5-x86_64-boot.iso - #- "61fe463758f6ee9b21c4d6698671980829ca4f747a066d556fa0e5eefc45382c" - # rhel-8.6-x86_64-kvm.qcow2 - - "c9b32bef88d605d754b932aad0140e1955ab9446818c70c4c36ca75d6f442fe9" - # rhel-8.6-x86_64-boot.iso - - "4a3ffcec86ba40c89fc2608c8e3bb00b71d572da219f30904536cdce80b58e76" - initial_download_path: /tmp - tasks: - - name: "Debug vars" - ansible.builtin.debug: - msg: '{{ refresh_token_file }} {{ refresh_token_contents }}' - - - name: Generate Access Token - ansible.builtin.uri: - body: - client_id: rhsm-api - grant_type: refresh_token - refresh_token: "{{ refresh_token_contents }}" - body_format: form-urlencoded - method: POST - url: "{{ redhat_sso_url }}" - register: access_token - - - name: Generate Image Download URLs - ansible.builtin.uri: - follow_redirects: none - headers: - Authorization: "Bearer {{ access_token.json.access_token }}" - status_code: 307 - url: "{{ redhat_api_url }}/images/{{ item }}/download" - register: image_urls - loop: "{{ image_checksums }}" - - - name: Download Red Hat Images - ansible.builtin.get_url: - checksum: "sha256:{{ item.item }}" - dest: "{{ initial_download_path }}/{{ item.json.body.filename }}" - url: "{{ item.json.body.href }}" - loop: "{{ image_urls.results }}" - - - name: Get route for upload proxy - kubernetes.core.k8s_info: - kind: Route - namespace: openshift-cnv - name: cdi-uploadproxy - register: uploadproxy_route - - - name: "Set host variable" - ansible.builtin.set_fact: - uploadproxy_url: 'https://{{ uploadproxy_route.resources[0].spec.host }}' - - - name: "debug host variable" - ansible.builtin.debug: - msg: '{{ uploadproxy_url }}' - - - name: Upload images to CDI proxy - community.kubevirt.kubevirt_cdi_upload: - pvc_namespace: default - pvc_name: 'pvc-{{ item.json.body.filename }}' - upload_host_validate_certs: false - upload_host: '{{ uploadproxy_url }}' - dest: "{{ initial_download_path }}/{{ item.json.body.filename }}" - loop: "{{ image_urls.results }}" diff --git a/scripts/update-tests.sh b/scripts/update-tests.sh deleted file mode 100755 index bb964aed..00000000 --- a/scripts/update-tests.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -x - -TEST_OPTS=$(echo -f common/examples/values-secret.yaml -f values-global.yaml --set global.repoURL="https://github.com/pattern-clone/mypattern" \ - --set main.git.repoURL="https://github.com/pattern-clone/mypattern" --set main.git.revision=main --set global.pattern="mypattern" \ - --set global.namespace="pattern-namespace" --set global.hubClusterDomain=hub.example.com --set global.localClusterDomain=region.example.com \ - --set "clusterGroup.imperative.jobs[0].name"="test" --set "clusterGroup.imperative.jobs[0].playbook"="ansible/test.yml" \ - --set clusterGroup.insecureUnsealVaultInsideCluster=true) - -echo $TEST_OPTS - -rm tests/* - -for i in $(find . -type f -iname 'Chart.yaml' -not -path "./common/*" -exec dirname "{}" \; | sed -e 's/.\///'); do \ -s=$(echo $i | sed -e s@/@-@g -e s@charts-@@); echo $s; helm template $i --name-template $s > tests/$s-naked.expected.yaml; done - -for i in $(find . -type f -iname 'Chart.yaml' -not -path "./common/*" -exec dirname "{}" \; | sed -e 's/.\///'); do \ -s=$(echo $i | sed -e s@/@-@g -e s@charts-@@); echo $s; helm template $i --name-template $s $TEST_OPTS > tests/$s-normal.expected.yaml; done diff --git a/values-hub.yaml b/values-hub.yaml index 52736b00..709894de 100644 --- a/values-hub.yaml +++ b/values-hub.yaml @@ -81,27 +81,5 @@ clusterGroup: project: hub chart: hashicorp-vault chartVersion: 0.1.* - imperative: - clusterRoleYaml: - - apiGroups: - - '*' - resources: - - persistentvolumeclaims - - datavolumes - - dataimportcrons - - datasources - verbs: - - '*' - - apiGroups: - - '*' - resources: - - '*' - verbs: - - get - - list - - watch - jobs: - - name: clean-golden-images - playbook: ansible/odf_fix_dataimportcrons.yml - verbosity: -vvv + imperative: {} managedClusterGroups: {}