Merge "AppFwk: remove -f prevents remove-failed state"
This commit is contained in:
commit
7782f877a0
|
@ -378,7 +378,8 @@ class KubeAppController(rest.RestController):
|
|||
lifecycle_hook_info.mode = constants.APP_LIFECYCLE_MODE_MANUAL
|
||||
|
||||
pecan.request.rpcapi.perform_app_remove(pecan.request.context,
|
||||
db_app, lifecycle_hook_info=lifecycle_hook_info)
|
||||
db_app, lifecycle_hook_info=lifecycle_hook_info,
|
||||
force=force)
|
||||
else:
|
||||
if db_app.status not in [constants.APP_APPLY_IN_PROGRESS,
|
||||
constants.APP_UPDATE_IN_PROGRESS,
|
||||
|
|
|
@ -1844,7 +1844,7 @@ APP_EVALUATE_REAPPLY_TRIGGER_TO_METADATA_MAP = {
|
|||
}
|
||||
|
||||
# Progress constants
|
||||
APP_PROGRESS_ABORTED = 'operation aborted, check logs for detail'
|
||||
APP_PROGRESS_ABORTED = 'operation aborted, check system inventory logs for details'
|
||||
APP_PROGRESS_ABORTED_BY_USER = 'operation aborted by user'
|
||||
APP_PROGRESS_APPLY_MANIFEST = 'applying application manifest'
|
||||
APP_PROGRESS_COMPLETED = 'completed'
|
||||
|
@ -1870,6 +1870,8 @@ APP_PROGRESS_UPDATE_FAILED_SKIP_RECOVERY = "Application {} update from " \
|
|||
APP_PROGRESS_UPDATE_FAILED_ARMADA_TO_FLUXCD = "Application {} update from " \
|
||||
"version {} to version {} failed and recovery skipped " \
|
||||
"because recovering between Armada and FluxCD is not allowed"
|
||||
APP_PROGRESS_REMOVE_FAILED_WARNING = "Application remove failed. Status forced to '{}'. " \
|
||||
"Use native helm commands to clean up application helm releases."
|
||||
|
||||
# Auto-recovery limits
|
||||
APP_AUTO_RECOVERY_MAX_COUNT = 5
|
||||
|
|
|
@ -331,7 +331,8 @@ class AppOperator(object):
|
|||
|
||||
def _abort_operation(self, app, operation,
|
||||
progress=constants.APP_PROGRESS_ABORTED,
|
||||
user_initiated=False, reset_status=False):
|
||||
user_initiated=False, reset_status=False,
|
||||
forced_operation=False):
|
||||
if user_initiated:
|
||||
progress = constants.APP_PROGRESS_ABORTED_BY_USER
|
||||
|
||||
|
@ -377,17 +378,28 @@ class AppOperator(object):
|
|||
"please check system inventory log for cause."),
|
||||
True)
|
||||
elif app.status == constants.APP_REMOVE_IN_PROGRESS:
|
||||
new_status = constants.APP_REMOVE_FAILURE
|
||||
op = 'application-remove'
|
||||
self._raise_app_alarm(
|
||||
app.name, constants.APP_REMOVE_FAILURE,
|
||||
fm_constants.FM_ALARM_ID_APPLICATION_REMOVE_FAILED,
|
||||
fm_constants.FM_ALARM_SEVERITY_MAJOR,
|
||||
_("Application Remove Failure"),
|
||||
fm_constants.FM_ALARM_TYPE_3,
|
||||
_("Retry removing the application. If the issue persists, "
|
||||
"please check system inventory log for cause."),
|
||||
True)
|
||||
if not forced_operation:
|
||||
new_status = constants.APP_REMOVE_FAILURE
|
||||
self._raise_app_alarm(
|
||||
app.name, constants.APP_REMOVE_FAILURE,
|
||||
fm_constants.FM_ALARM_ID_APPLICATION_REMOVE_FAILED,
|
||||
fm_constants.FM_ALARM_SEVERITY_MAJOR,
|
||||
_("Application Remove Failure"),
|
||||
fm_constants.FM_ALARM_TYPE_3,
|
||||
_("Retry removing the application. If the issue persists, "
|
||||
"please check system inventory log for cause. "
|
||||
"Using --force will set the app status to 'uploaded' "
|
||||
"in case the error persists."),
|
||||
True)
|
||||
else:
|
||||
# In case there is an existing alarm for previous remove failure
|
||||
self._clear_app_alarm(app.name)
|
||||
|
||||
new_status = constants.APP_UPLOAD_SUCCESS
|
||||
progress = constants.APP_PROGRESS_REMOVE_FAILED_WARNING.format(new_status)
|
||||
LOG.warning(progress)
|
||||
|
||||
else:
|
||||
# Should not get here, perhaps a new status was introduced?
|
||||
LOG.error("No abort handling code for app status = '%s'!" % app.status)
|
||||
|
@ -3060,7 +3072,7 @@ class AppOperator(object):
|
|||
self._clear_app_alarm(to_app.name)
|
||||
return True
|
||||
|
||||
def perform_app_remove(self, rpc_app, lifecycle_hook_info_app_remove):
|
||||
def perform_app_remove(self, rpc_app, lifecycle_hook_info_app_remove, force=False):
|
||||
"""Process application remove request
|
||||
|
||||
This method invokes Armada to delete the application manifest.
|
||||
|
@ -3068,6 +3080,8 @@ class AppOperator(object):
|
|||
|
||||
:param rpc_app: application object in the RPC request
|
||||
:param lifecycle_hook_info_app_remove: LifecycleHookInfo object
|
||||
:param force: If set to True, will set the app state to 'uploaded'
|
||||
instead of 'remove-failed' in case of an error
|
||||
|
||||
:return boolean: whether application remove was successful
|
||||
"""
|
||||
|
@ -3110,7 +3124,7 @@ class AppOperator(object):
|
|||
self.app_lifecycle_actions(None, None, rpc_app, lifecycle_hook_info_app_remove)
|
||||
|
||||
except Exception as e:
|
||||
self._abort_operation(app, constants.APP_REMOVE_OP)
|
||||
self._abort_operation(app, constants.APP_REMOVE_OP, forced_operation=force)
|
||||
LOG.exception(e)
|
||||
self._deregister_app_abort(app.name)
|
||||
return False
|
||||
|
@ -3122,10 +3136,11 @@ class AppOperator(object):
|
|||
LOG.info("Application (%s) remove completed." % app.name)
|
||||
else:
|
||||
if AppOperator.is_app_aborted(app.name):
|
||||
# App is always set to APP_REMOVE_FAILURE if abort is initiated by user.
|
||||
self._abort_operation(app, constants.APP_REMOVE_OP,
|
||||
user_initiated=True)
|
||||
user_initiated=True, forced_operation=False)
|
||||
else:
|
||||
self._abort_operation(app, constants.APP_REMOVE_OP)
|
||||
self._abort_operation(app, constants.APP_REMOVE_OP, forced_operation=force)
|
||||
rc = False
|
||||
|
||||
self._deregister_app_abort(app.name)
|
||||
|
|
|
@ -14167,12 +14167,14 @@ class ConductorManager(service.PeriodicService):
|
|||
self._app.perform_app_update(from_rpc_app, to_rpc_app, tarfile,
|
||||
operation, lifecycle_hook_info_app_update, reuse_user_overrides)
|
||||
|
||||
def perform_app_remove(self, context, rpc_app, lifecycle_hook_info_app_remove):
|
||||
def perform_app_remove(self, context, rpc_app, lifecycle_hook_info_app_remove, force=False):
|
||||
"""Handling of application removal request (via AppOperator)
|
||||
|
||||
:param context: request context.
|
||||
:param rpc_app: data object provided in the rpc request
|
||||
:param lifecycle_hook_info_app_remove: LifecycleHookInfo object
|
||||
:param force: If set to True, will set the app state to 'uploaded'
|
||||
instead of 'remove-failed' in case of an error
|
||||
|
||||
"""
|
||||
lifecycle_hook_info_app_remove.operation = constants.APP_REMOVE_OP
|
||||
|
@ -14190,7 +14192,7 @@ class ConductorManager(service.PeriodicService):
|
|||
LOG.error("Error performing app_lifecycle_actions %s" % str(e))
|
||||
|
||||
app_removed = self._app.perform_app_remove(
|
||||
rpc_app, lifecycle_hook_info_app_remove)
|
||||
rpc_app, lifecycle_hook_info_app_remove, force)
|
||||
lifecycle_hook_info_app_remove[LifecycleConstants.EXTRA][LifecycleConstants.APP_REMOVED] = app_removed
|
||||
|
||||
# Perform post remove operation actions
|
||||
|
|
|
@ -1793,18 +1793,21 @@ class ConductorAPI(sysinv.openstack.common.rpc.proxy.RpcProxy):
|
|||
lifecycle_hook_info_app_update=lifecycle_hook_info,
|
||||
reuse_user_overrides=reuse_user_overrides))
|
||||
|
||||
def perform_app_remove(self, context, rpc_app, lifecycle_hook_info):
|
||||
def perform_app_remove(self, context, rpc_app, lifecycle_hook_info, force=False):
|
||||
"""Handle application remove request
|
||||
|
||||
:param context: request context.
|
||||
:param rpc_app: data object provided in the rpc request
|
||||
:param lifecycle_hook_info: LifecycleHookInfo object
|
||||
:param force: If set to True, will set the app state to 'uploaded'
|
||||
instead of 'remove-failed' in case of an error
|
||||
|
||||
"""
|
||||
return self.cast(context,
|
||||
self.make_msg('perform_app_remove',
|
||||
rpc_app=rpc_app,
|
||||
lifecycle_hook_info_app_remove=lifecycle_hook_info))
|
||||
lifecycle_hook_info_app_remove=lifecycle_hook_info,
|
||||
force=force))
|
||||
|
||||
def perform_app_abort(self, context, rpc_app, lifecycle_hook_info):
|
||||
"""Handle application abort request
|
||||
|
|
Loading…
Reference in New Issue