Fix portieris webhook disable on update
After a change in how apps are being upgraded during a platform upgrade, from CLI commands (considered 'manual') to automatic operations done by the app framework, the 'pre_update' method is not being called due to the hook being considered of a different type (APP_LIFECYCLE_MODE_AUTO instead of APP_LIFECYCLE_MODE_MANUAL). This change use a different condition to decided when to call the 'pre_update' method to account for the change in the app framework: - We will use the lifecycle type 'resource' for both 'auto' and 'manual' modes, instead of 'check' only with 'manual' mode. The 'check' is constantly called at runtime for auto updates, and we only want to execute the 'pre_update' if the update is indeed in progress (after the check stage). - Due to this change, we need to make another change in the clean up method, it needs to use the operation type 'apply' instead of 'update', otherwise the 'pre_update' method will be called again and we will end in a loop. Also include changes to account for rollback: - We don't want reevaluate the Post-upgrade override if it's already filled, otherwise we will consider the temporary override to disable the webhook as a permanent one; - Since a rollback can still be done after the platform upgrade deploy is in the completed stage (but sysinv start processing updates for the apps again in this stage), don't clean up the the temporary overrides until the upgrade deploy is deleted (platform upgrade ends properly after it). Test plan: PASS: Perform upgrade (AIO-SX). PASS: Perform upgrade activation rollback (AIO-SX). PASS: App install (system application-upload/apply). PASS: App upversion (system application-update). Story: 2011357 Task: 52710 Change-Id: I96898bcc556272d9b50fcccb65b5fa304da02d7f Signed-off-by: Marcelo de Castro Loebens <Marcelo.DeCastroLoebens@windriver.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2021 Wind River Systems, Inc.
|
||||
# Copyright (c) 2021,2025 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
@@ -17,6 +17,7 @@ from sysinv.common import exception
|
||||
from sysinv.helm import lifecycle_base as base
|
||||
from sysinv.helm.lifecycle_constants import LifecycleConstants
|
||||
from sysinv.helm.lifecycle_hook import LifecycleHookInfo
|
||||
import os
|
||||
import yaml
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@@ -56,12 +57,13 @@ class PortierisAppLifecycleOperator(base.AppLifecycleOperator):
|
||||
return self.post_restore(app_op, app)
|
||||
|
||||
# Update
|
||||
if hook_info.lifecycle_type == LifecycleConstants.APP_LIFECYCLE_TYPE_SEMANTIC_CHECK:
|
||||
if hook_info.lifecycle_type == LifecycleConstants.APP_LIFECYCLE_TYPE_RESOURCE:
|
||||
# Prepare
|
||||
if hook_info.mode == LifecycleConstants.APP_LIFECYCLE_MODE_MANUAL:
|
||||
if hook_info.operation == constants.APP_UPDATE_OP:
|
||||
if hook_info.relative_timing == LifecycleConstants.APP_LIFECYCLE_TIMING_PRE:
|
||||
return self.pre_update(app_op, app)
|
||||
if hook_info.operation == constants.APP_UPDATE_OP:
|
||||
if hook_info.relative_timing == LifecycleConstants.APP_LIFECYCLE_TIMING_PRE:
|
||||
return self.pre_update(app_op, app)
|
||||
|
||||
if hook_info.lifecycle_type == LifecycleConstants.APP_LIFECYCLE_TYPE_SEMANTIC_CHECK:
|
||||
# Cleanup
|
||||
if hook_info.mode == LifecycleConstants.APP_LIFECYCLE_MODE_AUTO:
|
||||
if hook_info.operation == constants.APP_UPDATE_OP:
|
||||
@@ -89,6 +91,10 @@ class PortierisAppLifecycleOperator(base.AppLifecycleOperator):
|
||||
user_overrides = yaml.safe_load(
|
||||
self._get_helm_user_overrides(dbapi_instance, db_app_id)) or {}
|
||||
|
||||
if user_overrides.get(POST_UPGRADE_POLICY_OVERRIDE, None) is not None:
|
||||
LOG.info("Post-upgrade policy override already filled. Ignoring.")
|
||||
return
|
||||
|
||||
postUpgradePolicy = user_overrides.get('webHooks', {}).get('failurePolicy', None)
|
||||
if postUpgradePolicy is None:
|
||||
postUpgradePolicy = NULL_VALUE
|
||||
@@ -116,6 +122,10 @@ class PortierisAppLifecycleOperator(base.AppLifecycleOperator):
|
||||
user_overrides = yaml.safe_load(
|
||||
self._get_helm_user_overrides(dbapi_instance, db_app_id)) or {}
|
||||
|
||||
if os.path.exists(constants.USM_UPGRADE_IN_PROGRESS):
|
||||
LOG.info("Upgrade is in progress. Avoiding cleaning portieris update flag.")
|
||||
return
|
||||
|
||||
postUpgradePolicy = user_overrides.pop(POST_UPGRADE_POLICY_OVERRIDE, None)
|
||||
if postUpgradePolicy is None:
|
||||
return
|
||||
@@ -142,7 +152,7 @@ class PortierisAppLifecycleOperator(base.AppLifecycleOperator):
|
||||
# Reapply portieris
|
||||
LOG.info("Cleaned update overrides. Reapplying portieris.")
|
||||
lifecycle_hook_info = LifecycleHookInfo()
|
||||
lifecycle_hook_info.operation = constants.APP_UPDATE_OP
|
||||
lifecycle_hook_info.operation = constants.APP_APPLY_OP
|
||||
app_op.perform_app_apply(
|
||||
app._kube_app, LifecycleConstants.APP_LIFECYCLE_MODE_AUTO, lifecycle_hook_info
|
||||
)
|
||||
|
Reference in New Issue
Block a user