From f3b1a2aed1e4fc00b0c080e8cbce579e9bf4a367 Mon Sep 17 00:00:00 2001 From: Daniel Caires Date: Mon, 24 Feb 2025 08:48:31 -0300 Subject: [PATCH] Add ingress update during upgrade recovery It was found that after disabling the ingress reconciliation during the update process, if for any reason the update fails the old Ingress will not come back when the suspend flag is 'True' in the Ingress Helmrelease. This review aims to add an update step during the application recovery, that will reactivate the Helmrelease reconciliation. Test Plan: PASS - Build python3-k8sapp-openstack package PASS - Build STX-Openstack tarball PASS - Run system application-update and force fail it PASS - Update recovery is triggered PASS - Full recovery to 24.09 Story: 2011262 Task: 51285 Change-Id: Ic390c81e65eaf40989318f4f91c75539a7a7295a Signed-off-by: Daniel Caires --- .../lifecycle/lifecycle_openstack.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/python3-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/lifecycle/lifecycle_openstack.py b/python3-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/lifecycle/lifecycle_openstack.py index 7665d69e..b41be88b 100644 --- a/python3-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/lifecycle/lifecycle_openstack.py +++ b/python3-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/lifecycle/lifecycle_openstack.py @@ -64,6 +64,8 @@ class OpenstackAppLifecycleOperator(base.AppLifecycleOperator): elif hook_info.operation == constants.APP_REMOVE_OP and \ hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_POST: return self._delete_app_specific_resources_post_remove(app_op, app, hook_info) + elif hook_info.operation == constants.APP_RECOVER_OP: + return self._recover_app_resources_failed_update() # Rbd elif hook_info.lifecycle_type == constants.APP_LIFECYCLE_TYPE_RBD: @@ -430,3 +432,24 @@ class OpenstackAppLifecycleOperator(base.AppLifecycleOperator): status = helm_utils.delete_helm_release( release='osh-openstack-ingress', namespace=app_constants.HELM_NS_OPENSTACK) LOG.info(status) + + def _recover_app_resources_failed_update(self): + """ Perform resource recover after failed update""" + + # TODO: Remove in the future. This code is only necessary when + # updating from stx-10 to stx-11 STX-O release. + release = 'ingress' + patch = {"spec": {"suspend": False}} + + # Update helmrelease to revert changes + app_utils.update_helmrelease(release, patch) + + # The new Ingress must be disabled and deleted before starting recovery + release_failed = 'ingress-nginx-openstack' + patch_failed = {"spec": {"suspend": True}} + app_utils.update_helmrelease(release_failed, patch_failed) + + # Uninstall helm release. + status = helm_utils.delete_helm_release( + release=release_failed, namespace=app_constants.HELM_NS_OPENSTACK) + LOG.info(status)