Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare gating version against existing deployment versions #1972

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) }}"
rooftopcellist marked this conversation as resolved.
Show resolved Hide resolved
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, '<')
rooftopcellist marked this conversation as resolved.
Show resolved Hide resolved
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) }}"
rooftopcellist marked this conversation as resolved.
Show resolved Hide resolved

- 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: ''
Loading