From 122995fda7626c86a70c5413c48513c6b70f9b34 Mon Sep 17 00:00:00 2001 From: Hao Liu Date: Fri, 3 Nov 2023 11:12:15 -0400 Subject: [PATCH] Add owner ref on AWXMeshIngress to AWX This way when AWX is deleted associated AWXMeshIngress will all be deleted as well --- config/manager/manager.yaml | 1 + roles/mesh_ingress/defaults/main.yml | 2 ++ roles/mesh_ingress/tasks/main.yml | 21 +++++++++++++++++++++ watches.yaml | 1 + 4 files changed, 25 insertions(+) diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index 7612d5b1..bbec097c 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -39,6 +39,7 @@ spec: - --leader-elect - --leader-election-id=awx-operator image: controller:latest + imagePullPolicy: Always name: awx-manager env: - name: ANSIBLE_GATHERING diff --git a/roles/mesh_ingress/defaults/main.yml b/roles/mesh_ingress/defaults/main.yml index b5fe314a..42e81986 100644 --- a/roles/mesh_ingress/defaults/main.yml +++ b/roles/mesh_ingress/defaults/main.yml @@ -1,4 +1,6 @@ deployment_type: awx +set_self_owneref: true + _control_plane_ee_image: quay.io/ansible/awx-ee:latest _image_pull_policy: Always diff --git a/roles/mesh_ingress/tasks/main.yml b/roles/mesh_ingress/tasks/main.yml index 7f8382e9..06b680e3 100644 --- a/roles/mesh_ingress/tasks/main.yml +++ b/roles/mesh_ingress/tasks/main.yml @@ -24,6 +24,26 @@ set_fact: awx_spec: "{{ awx_instance.resources[0].spec }}" +- name: Set owner_reference of AWXMeshIngress to related AWX instance + k8s: + state: present + definition: + apiVersion: awx.ansible.com/v1beta1 + kind: AWX + name: "{{ deployment_name }}" + namespace: "{{ ansible_operator_meta.namespace }}" + metadata: + name: "{{ deployment_name }}" + namespace: "{{ ansible_operator_meta.namespace }}" + ownerReferences: + - apiVersion: awx.ansible.com/v1beta1 + blockOwnerDeletion: true + controller: true + kind: AWX + name: "{{ deployment_name }}" + uid: "{{ awx_instance.resources[0].metadata.uid }}" + when: set_self_owneref | bool + - name: Set user provided control plane ee image set_fact: _custom_control_plane_ee_image: "{{ awx_spec.control_plane_ee_image }}" @@ -48,6 +68,7 @@ when: is_openshift | bool # TODO: need to wait until the route is ready before we can get the hostname +# right now this will rereconcile until the route is ready - name: Set external_hostname set_fact: diff --git a/watches.yaml b/watches.yaml index 8e6a5b20..9a0067f5 100644 --- a/watches.yaml +++ b/watches.yaml @@ -22,6 +22,7 @@ kind: AWXRestore role: restore snakeCaseParameters: False + - version: v1alpha1 group: awx.ansible.com kind: AWXMeshIngress