Skip to content

Commit

Permalink
Compare gating version against existing deployment versions (#1972)
Browse files Browse the repository at this point in the history
* Compare gating version against existing deployment versions and set upgradeFrom status
* Add quotes to default version

Co-authored-by: Dimitri Savineau <[email protected]>
  • Loading branch information
rooftopcellist and dsavineau authored Oct 16, 2024
1 parent 8a5ec6e commit c30d4c1
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
19 changes: 19 additions & 0 deletions roles/installer/tasks/check_existing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---

- name: Check for existing deployment
k8s_info:
api_version: "{{ api_version }}"
kind: "{{ kind }}"
namespace: "{{ ansible_operator_meta.namespace }}"
name: "{{ ansible_operator_meta.name }}"
register: existing_deployment

- name: Set previous_version version based on AWX CR version status
ansible.builtin.set_fact:
previous_version: "{{ existing_deployment.resources[0].status.version | default('0.0.0') }}"
when: existing_deployment['resources'] | length

- name: If previous_version is less than or equal to gating_version, set upgraded_from to previous_version
ansible.builtin.set_fact:
upgraded_from: "{{ previous_version }}"
when: previous_version is version_compare(gating_version, '<')
4 changes: 4 additions & 0 deletions roles/installer/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
namespace: "{{ ansible_operator_meta.namespace }}"
register: awx_web_deployment

- name: Check for existing deployment for previous version
include_tasks: check_existing.yml
when: gating_version | length

- name: Start installation if auto_upgrade is true
include_tasks: install.yml
when:
Expand Down
10 changes: 10 additions & 0 deletions roles/installer/tasks/update_status.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@
changed_when: false
when: awx_web_pod_name != ''

- name: Update upgradedFrom status
operator_sdk.util.k8s_status:
api_version: '{{ api_version }}'
kind: "{{ kind }}"
name: "{{ ansible_operator_meta.name }}"
namespace: "{{ ansible_operator_meta.namespace }}"
status:
upgradedFrom: "{{ upgraded_from }}"
when: upgraded_from is defined

- name: Update version status
operator_sdk.util.k8s_status:
api_version: '{{ api_version }}'
Expand Down
3 changes: 3 additions & 0 deletions roles/installer/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ _metrics_utility_pvc_claim: "{{ metrics_utility_pvc_claim | default(deployment_t
_metrics_utility_pvc_claim_size: "{{ metrics_utility_pvc_claim_size | default('5Gi') }}"
_metrics_utility_cronjob_gather_schedule: "{{ metrics_utility_cronjob_gather_schedule | default('@hourly') }}"
_metrics_utility_cronjob_report_schedule: "{{ metrics_utility_cronjob_report_schedule | default('@monthly') }}"

# version check
gating_version: ''

0 comments on commit c30d4c1

Please sign in to comment.