Merge "Handle existing VIM strategies during subcloud rehome"

This commit is contained in:
Zuul
2024-02-15 22:06:35 +00:00
committed by Gerrit Code Review
4 changed files with 60 additions and 3 deletions

View File

@@ -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

View File

@@ -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"]

View File

@@ -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"]

View File

@@ -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"