Deffer application reapply evaluation during platform upgrades

Change-Id: I62683b91727f89cce3581301ce9c77312d2b89c0
This commit is contained in:
David Bastos
2025-02-05 15:04:41 -03:00
parent e5787367bd
commit 78cdb4a481
6 changed files with 77 additions and 0 deletions

View File

@@ -92,6 +92,7 @@ from cgtsclient.v1 import storage_file
from cgtsclient.v1 import storage_lvm
from cgtsclient.v1 import storage_tier
from cgtsclient.v1 import upgrade
from cgtsclient.v1 import kube_app
class Client(object):
@@ -186,3 +187,4 @@ class Client(object):
self.kube_rootca_update = kube_rootca_update.KubeRootCAUpdateManager(self.http_client)
self.kube_config_kubelet = \
kube_config_kubelet.KubeConfigKubeletManager(self.http_client)
self.evaluate_apps_reapply = kube_app.KubeAppManager(self.http_client)

View File

@@ -0,0 +1,17 @@
# -*- encoding: utf-8 -*-
#
# Copyright (c) 2025 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
from cgtsclient.common import base
class KubeAppManager(base.Manager):
def post_evaluate_apps_reapply(self, triggers):
path = '/v1/evaluate_apps_reapply/'
_, body = self.api.json_request('POST', path, body=triggers)
return body

View File

@@ -32,6 +32,7 @@ from sysinv.api.controllers.v1 import device_image_state
from sysinv.api.controllers.v1 import device_label
from sysinv.api.controllers.v1 import disk
from sysinv.api.controllers.v1 import datanetwork
from sysinv.api.controllers.v1 import evaluate_apps_reapply
from sysinv.api.controllers.v1 import interface_datanetwork
from sysinv.api.controllers.v1 import dns
from sysinv.api.controllers.v1 import drbdconfig
@@ -309,6 +310,9 @@ class V1(base.APIBase):
restore = [link.Link]
"Links to the restore resource"
evaluate_apps_reapply = [link.Link]
"Links to the evaluate_apps_reapply resource"
@classmethod
def convert(self):
v1 = V1()
@@ -944,6 +948,14 @@ class V1(base.APIBase):
'restore', '',
bookmark=True)
]
v1.evaluate_apps_reapply = [link.Link.make_link('self', pecan.request.host_url,
'evaluate_apps_reapply', ''),
link.Link.make_link('bookmark',
pecan.request.host_url,
'evaluate_apps_reapply', '',
bookmark=True)]
return v1
@@ -1029,6 +1041,7 @@ class Controller(rest.RestController):
device_labels = device_label.DeviceLabelController()
restore = restore.RestoreController()
network_addresspools = network_addrpool.NetworkAddresspoolController()
evaluate_apps_reapply = evaluate_apps_reapply.EvaluateAppsReapplyController()
@wsme_pecan.wsexpose(V1)
def get(self):

View File

@@ -0,0 +1,33 @@
#!/usr/bin/env python
#
# Copyright (c) 2025 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
from oslo_log import log
import pecan
from pecan import rest
import wsme
from wsme import types as wtypes
import wsmeext.pecan as wsme_pecan
from sysinv.common import constants
LOG = log.getLogger(__name__)
class EvaluateAppsReapplyController(rest.RestController):
@wsme_pecan.wsexpose(wtypes.text)
def post(self):
try:
pecan.request.rpcapi.evaluate_apps_reapply(
pecan.request.context,
trigger={'type': constants.APP_EVALUATE_REAPPLY_TYPE_USM_UPGRADE_COMPLETE})
return "Evaluation triggered successfully"
except Exception as e:
LOG.error(f"Failed to reorder apps: {str(e)}")
raise wsme.exc.ClientSideError(
f"Failed to reorder apps: {str(e)}")

View File

@@ -2124,6 +2124,7 @@ APP_EVALUATE_REAPPLY_TYPE_KUBE_UPGRADE_COMPLETE = 'kube-upgrade-complete'
APP_EVALUATE_REAPPLY_TYPE_HOST_ADD_LABEL = 'host-label-assign'
APP_EVALUATE_REAPPLY_TYPE_HOST_MODIFY = 'host-modify'
APP_EVALUATE_REAPPLY_TYPE_SB_MODIFY = 'storage-backend-modify'
APP_EVALUATE_REAPPLY_TYPE_USM_UPGRADE_COMPLETE = 'usm-upgrade-complete'
APP_EVALUATE_REAPPLY_TRIGGER_TO_METADATA_MAP = {
UNLOCK_ACTION:
@@ -2160,6 +2161,8 @@ APP_EVALUATE_REAPPLY_TRIGGER_TO_METADATA_MAP = {
APP_EVALUATE_REAPPLY_TYPE_HOST_MODIFY,
APP_EVALUATE_REAPPLY_TYPE_SB_MODIFY:
APP_EVALUATE_REAPPLY_TYPE_SB_MODIFY,
APP_EVALUATE_REAPPLY_TYPE_USM_UPGRADE_COMPLETE:
APP_EVALUATE_REAPPLY_TYPE_USM_UPGRADE_COMPLETE,
}
# Progress constants

View File

@@ -17237,6 +17237,15 @@ class ConductorManager(service.PeriodicService):
"""
# Check if platform upgrade is in progress
try:
upgrade = usm_service.get_platform_upgrade(self.dbapi)
if upgrade:
LOG.info("Deferring apps reapply evaluation. Upgrade in progress.")
return
except exception.NotFound:
pass
# Defer apps reapply evaluation if Kubernetes upgrades are in progress
# or if apps are still post updating.
try: