Skip to content

Commit

Permalink
Compare gating version against existing deployment versions and set u…
Browse files Browse the repository at this point in the history
…pgradeFrom status
  • Loading branch information
rooftopcellist committed Oct 16, 2024
1 parent d4de2d3 commit 836518c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
19 changes: 19 additions & 0 deletions roles/installer/tasks/check_previous_version.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 > 0

- 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 | 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_previous_version.yml
when: gating_version | length > 0

- name: Start installation if auto_upgrade is true
include_tasks: install.yml
when:
Expand Down
9 changes: 9 additions & 0 deletions roles/installer/tasks/update_status.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@
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 | default(omit) }}"

- 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: "{{ gating_version | default('') }}"

0 comments on commit 836518c

Please sign in to comment.