Check patching api prior to uploading managed app

The patching operation check is happening too late when uploading a
platform managed application. If the patching API is not responding, the
managed application will be created in the database and end up stuck in
the uploading state as the upload will not proceed.

Move the check to the proper location to avoid prematurely creating the
application if it can't be loaded until patch dependencies are verified.

Also, prior to spawning the greenthread for application apply, save the
state to 'applying'. This will prevent multiple audit cycles from
starting greenthreads for the same action.

Change-Id: Iada51635a6965acb404be05cfd4d9ef167aebe9f
Closes-Bug: #1829791
Signed-off-by: Robert Church <robert.church@windriver.com>
This commit is contained in:
Robert Church
2019-05-20 23:17:17 -04:00
committed by Bob Church
parent 319b5602df
commit 8a20895fab

View File

@@ -5123,6 +5123,9 @@ class ConductorManager(service.PeriodicService):
LOG.debug("Platform managed application %s: %s" % (app_name, status))
if status == constants.APP_NOT_PRESENT:
if _patching_operation_is_occurring():
continue
LOG.info("Platform managed application %s: Creating..." % app_name)
app_data = {'name': app_name,
'app_version': constants.APP_VERSION_PLACEHOLDER,
@@ -5152,9 +5155,6 @@ class ConductorManager(service.PeriodicService):
app.manifest_file = os.path.basename(tarball.manifest_file)
app.save()
if _patching_operation_is_occurring():
continue
# Action: Upload.
# Do not block this audit task or any other periodic task. This
# could be long running. The next audit cycle will pick up the
@@ -5180,11 +5180,13 @@ class ConductorManager(service.PeriodicService):
try:
app = kubeapp_obj.get_by_name(context, app_name)
app.status = constants.APP_APPLY_IN_PROGRESS
except exception.KubeAppNotFound as e:
LOG.exception(e)
continue
app.status = constants.APP_APPLY_IN_PROGRESS
app.save()
# Action: Apply the application
# Do not block this audit task or any other periodic task. This
# could be long running. The next audit cycle will pick up the