Merge "Add lifecycle hook to allow to_app application-update semantic checking"
This commit is contained in:
commit
658d556fe9
|
@ -23,6 +23,7 @@ from sysinv.common import constants
|
|||
from sysinv.common import exception
|
||||
from sysinv.common import utils as cutils
|
||||
from sysinv.common import kubernetes
|
||||
from sysinv.helm.lifecycle_constants import LifecycleConstants
|
||||
from sysinv.helm.lifecycle_hook import LifecycleHookInfo
|
||||
from sysinv.openstack.common.rpc import common as rpc_common
|
||||
import cgcs_patch.constants as patch_constants
|
||||
|
@ -415,6 +416,7 @@ class KubeAppController(rest.RestController):
|
|||
constants.APP_LIFECYCLE_TYPE_SEMANTIC_CHECK,
|
||||
constants.APP_LIFECYCLE_TIMING_PRE,
|
||||
constants.APP_UPDATE_OP)
|
||||
lifecycle_hook_info[LifecycleConstants.EXTRA][LifecycleConstants.FROM_APP] = True
|
||||
self._app_lifecycle_actions(applied_app,
|
||||
lifecycle_hook_info)
|
||||
except Exception as e:
|
||||
|
|
|
@ -2457,6 +2457,26 @@ class AppOperator(object):
|
|||
lifecycle_hook_info_app_upload=lifecycle_hook_info_app_update)
|
||||
lifecycle_hook_info_app_update.operation = constants.APP_UPDATE_OP
|
||||
|
||||
# Semantic checking for N+1 app
|
||||
try:
|
||||
lifecycle_hook_info = copy.deepcopy(lifecycle_hook_info_app_update)
|
||||
lifecycle_hook_info.lifecycle_type = constants.APP_LIFECYCLE_TYPE_SEMANTIC_CHECK
|
||||
lifecycle_hook_info[LifecycleConstants.EXTRA][LifecycleConstants.TO_APP] = True
|
||||
|
||||
self.app_lifecycle_actions(None, None, to_rpc_app, lifecycle_hook_info)
|
||||
except exception.LifecycleSemanticCheckException as e:
|
||||
LOG.info("App {} rejected operation {} for reason: {}"
|
||||
"".format(to_app.name, constants.APP_UPDATE_OP, str(e)))
|
||||
# lifecycle hooks not used in perform_app_recover
|
||||
return self._perform_app_recover(from_app, to_app,
|
||||
armada_process_required=False)
|
||||
except Exception as e:
|
||||
LOG.error("App {} operation {} semantic check error: {}"
|
||||
"".format(to_app.name, constants.APP_UPDATE_OP, str(e)))
|
||||
# lifecycle hooks not used in perform_app_recover
|
||||
return self._perform_app_recover(from_app, to_app,
|
||||
armada_process_required=False)
|
||||
|
||||
self.load_application_metadata_from_file(to_rpc_app)
|
||||
|
||||
# Check whether the new application is compatible with the current k8s version
|
||||
|
|
|
@ -25,3 +25,5 @@ class LifecycleConstants(object):
|
|||
TRIGGER_DELTA_FIELDS = 'delta_fields'
|
||||
ACTION = 'action'
|
||||
APP_STATUS = 'app_status'
|
||||
FROM_APP = 'from_app'
|
||||
TO_APP = 'to_app'
|
||||
|
|
Loading…
Reference in New Issue