Skip to content

[patch] MSO-2039 Adding Optimizer Rollback #1740

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions ibm/mas_devops/roles/suite_app_rollback/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
- rollback_mas_app
include_tasks: tasks/rollback_mas_iot.yml

- name: "Execute MAS Optimizer Rollback"
when:
- mas_app_id is defined and mas_app_id == "optimizer"
- rollback_mas_app
include_tasks: tasks/rollback_mas_optimizer.yml

# 5. Verify the current core version matching with specified version
# -----------------------------------------------------------------------------
- name: "Verify App Version"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
# 1. Check the existing installation
# -----------------------------------------------------------------------------
- name: "OptimizerApp : Get CR for OptimizerApp"
kubernetes.core.k8s_info:
api_version: apps.mas.ibm.com/v1
name: "{{ mas_instance_id }}"
namespace: "{{ mas_app_namespace }}"
kind: OptimizerApp
register: current_app_info

# 2. Rollback MAS Optimizer
# -----------------------------------------------------------------------------
- name: "Rollback : rollback MAS Optimizer to specified version"
kubernetes.core.k8s:
api_version: apps.mas.ibm.com/v1
name: "{{ mas_instance_id }}"
namespace: "{{ mas_app_namespace }}"
kind: OptimizerApp
definition:
spec:
version: "{{ mas_app_version }}"
apply: true
when:
- not mas_rollback_dryrun
- mas_app_version and mas_app_version != ""
- current_app_info is defined and current_app_info.resources[0].status.versions.reconciled != mas_app_version
- skip_compatibility_check or mas_app_version in current_app_info.resources[0].status.versions.supported

- name: "Debug when we are already on the desired version"
when:
- mas_app_version is defined and mas_app_version != ""
- current_app_info is defined and current_app_info.resources[0].status.versions.reconciled == mas_app_version
debug:
msg: "No action required, Optimizer app is already on the {{ mas_app_version }} version"

- name: "Debug when the version is not defined"
when:
- mas_app_version is not defined or mas_app_version == ""
debug:
msg: "No action required, no version information is available for rollback"

- name: "Debug when the version is not supported"
when:
- mas_app_version and mas_app_version != ""
- skip_compatibility_check is false and mas_app_version is not in current_app_info.resources[0].status.versions.supported
debug:
msg: "No action required, version is not supported for rollback"

# 3. Check that the Optimizer CR meets the required state
# -----------------------------------------------------------------------------
- name: "Rollback : Get CR for OptimizerApp"
kubernetes.core.k8s_info:
api_version: apps.mas.ibm.com/v1
name: "{{ mas_instance_id }}"
namespace: "{{ mas_app_namespace }}"
kind: OptimizerApp
retries: 20 # about 20 minutes
delay: 60 # 1 minute
until:
- updated_app_info.resources[0].status.versions.reconciled == mas_app_version
- updated_app_info.resources | json_query('[*].status.conditions[?type==`Ready`][].reason') | select ('match','Ready') | list | length == 1
register: updated_app_info
when:
- mas_app_version and mas_app_version != ""
- not mas_rollback_dryrun
- current_app_info is defined and current_app_info.resources[0].status.versions.reconciled != mas_app_version
- skip_compatibility_check or mas_app_version in current_app_info.resources[0].status.versions.supported

- name: "Rollback : Debug MAS Optimizer"
debug:
var: updated_app_info
Loading