diff --git a/playbookconfig/src/playbooks/rehome_subcloud.yml b/playbookconfig/src/playbooks/rehome_subcloud.yml index 2d90e41c4..2c3faeb4c 100644 --- a/playbookconfig/src/playbooks/rehome_subcloud.yml +++ b/playbookconfig/src/playbooks/rehome_subcloud.yml @@ -1,6 +1,6 @@ --- # -# Copyright (c) 2021-2023 Wind River Systems, Inc. +# Copyright (c) 2021-2024 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # @@ -26,4 +26,4 @@ - rehome-subcloud/update-network-config - role: rehome-subcloud/update-keystone-data become: yes - - common/check-services-status + - rehome-subcloud/validate-after-rehome diff --git a/playbookconfig/src/playbooks/roles/rehome-subcloud/validate-after-rehome/tasks/main.yml b/playbookconfig/src/playbooks/roles/rehome-subcloud/validate-after-rehome/tasks/main.yml new file mode 100644 index 000000000..6167c1596 --- /dev/null +++ b/playbookconfig/src/playbooks/roles/rehome-subcloud/validate-after-rehome/tasks/main.yml @@ -0,0 +1,22 @@ +--- +# +# Copyright (c) 2024 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +# ROLE DESCRIPTION: +# Validates and perform cleanup tasks post rehome +# + +- name: Verify that all services are enabled-active + import_role: + name: common/check-services-status + +# Delete any existing strategy if it's in a safe state +- name: Delete existing {{ existing_strategy.type | default("strategy") }} + shell: | + source /etc/platform/openrc + sw-manager {{ existing_strategy.type }} delete + when: > + existing_strategy.status is defined and existing_strategy.status in + ["applied", "ready-to-apply", "build-failed", "build-timeout"] diff --git a/playbookconfig/src/playbooks/roles/rehome-subcloud/validate-before-rehome/tasks/main.yml b/playbookconfig/src/playbooks/roles/rehome-subcloud/validate-before-rehome/tasks/main.yml index e294b68ee..5caf6a506 100644 --- a/playbookconfig/src/playbooks/roles/rehome-subcloud/validate-before-rehome/tasks/main.yml +++ b/playbookconfig/src/playbooks/roles/rehome-subcloud/validate-before-rehome/tasks/main.yml @@ -71,3 +71,31 @@ The subcloud currently has one or more management affecting alarms. Please resolve the alarm condition(s) then try again. when: management_alarm_count.stdout | int > 0 + +# Verify if there is a strategy in an aborted state as aborted strategies don't +# raise management affecting alarms. States that raises mgmt affecting alarms: +# applying, apply-failed, apply-timeout, aborting +- name: Find existing strategies + shell: | + source /etc/platform/openrc + sw-manager {{ item }} show | awk '/state:/ {print $2}' | grep . + loop: "{{ vim_strategies }}" + register: result + failed_when: false + when: "(result | default({'rc': 1})).rc == 1" + +- name: Store the existing strategy + set_fact: + existing_strategy: >- + {{ result.results | + json_query('[?rc==`0`].{type: item, status: stdout}') | + first | default(None)}} + +- name: Fail if existing strategy is in an aborted state + fail: + msg: >- + The subcloud currently has an aborted {{ existing_strategy.type}}. + Please resolve the strategy condition then try again. + when: > + existing_strategy and existing_strategy.status in + ["abort-failed", "abort-timeout", "aborted"] diff --git a/playbookconfig/src/playbooks/roles/rehome-subcloud/validate-before-rehome/vars/main.yml b/playbookconfig/src/playbooks/roles/rehome-subcloud/validate-before-rehome/vars/main.yml index 20beb996c..0c0a82f5d 100644 --- a/playbookconfig/src/playbooks/roles/rehome-subcloud/validate-before-rehome/vars/main.yml +++ b/playbookconfig/src/playbooks/roles/rehome-subcloud/validate-before-rehome/vars/main.yml @@ -1,8 +1,15 @@ --- # -# Copyright (c) 2022 Wind River Systems, Inc. +# Copyright (c) 2022, 2024 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # rehoming_min_software_version: 22.12 +vim_strategies: + - "fw-update-strategy" + - "kube-upgrade-strategy" + - "system-config-update-strategy" + - "kube-rootca-update-strategy" + - "patch-strategy" + - "upgrade-strategy"