Notify dcmanager when upgrade completed
When an upgrade has been completed we want to notify dcmanager so that it can do a load audit of the subclouds rather than waiting up to an hour for the normal load audit to run. Story: 2007267 Task: 41967 Depends-On: https://review.opendev.org/c/starlingx/distcloud/+/778338 Change-Id: I0c03bbfa16745fa297e159256a284e8862ff926a Signed-off-by: Chris Friesen <chris.friesen@windriver.com>
This commit is contained in:
parent
240be6fee8
commit
ff3ce494ee
|
@ -0,0 +1,43 @@
|
|||
# Copyright (c) 2021 Wind River Systems, Inc.
|
||||
#
|
||||
# The right to copy, distribute, modify, or otherwise make use
|
||||
# of this software may be licensed only pursuant to the terms
|
||||
# of an applicable Wind River license agreement.
|
||||
#
|
||||
|
||||
import json
|
||||
|
||||
from oslo_log import log as logging
|
||||
|
||||
from sysinv.common import constants
|
||||
from sysinv.common.rest_api import get_token
|
||||
from sysinv.common.rest_api import rest_api_request
|
||||
|
||||
# well-known dcmanager upgrade completed events
|
||||
DC_EVENT_PLATFORM_UPGRADE_COMPLETED = 'platform-upgrade-completed'
|
||||
DC_EVENT_K8S_UPGRADE_COMPLETED = 'k8s-upgrade-completed'
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def notify_dcmanager(events):
|
||||
"""Send list of upgrade completion events to dcmanager."""
|
||||
try:
|
||||
token = get_token(constants.SYSTEM_CONTROLLER_REGION)
|
||||
api_url = token.get_service_url("dcmanager", "dcmanager")
|
||||
api_cmd_headers = {
|
||||
'Content-type': 'application/json',
|
||||
'User-Agent': 'sysinv/1.0',
|
||||
}
|
||||
api_cmd = api_url + '/notifications'
|
||||
api_cmd_payload = json.dumps({'events': events})
|
||||
rest_api_request(token, "POST", api_cmd, api_cmd_headers,
|
||||
api_cmd_payload)
|
||||
except Exception:
|
||||
LOG.exception("Failed to notify dcmanager of events: %s" % events)
|
||||
|
||||
|
||||
def notify_dcmanager_platform_upgrade_completed():
|
||||
"""Send the platform-upgrade-completed event to dcmanager."""
|
||||
notify_dcmanager([DC_EVENT_PLATFORM_UPGRADE_COMPLETED])
|
|
@ -82,6 +82,7 @@ from sysinv.api.controllers.v1 import utils
|
|||
from sysinv.api.controllers.v1 import vim_api
|
||||
from sysinv.common import constants
|
||||
from sysinv.common import ceph as cceph
|
||||
from sysinv.common import dc_api
|
||||
from sysinv.common import device as dconstants
|
||||
from sysinv.common import exception
|
||||
from sysinv.common import fm
|
||||
|
@ -10194,6 +10195,11 @@ class ConductorManager(service.PeriodicService):
|
|||
(from_version, to_version))
|
||||
upgrades_management.complete_upgrade(from_version, to_version, upgrade)
|
||||
LOG.info("Finished completing upgrade")
|
||||
# If applicable, notify dcmanager upgrade is complete
|
||||
system = self.dbapi.isystem_get_one()
|
||||
role = system.get('distributed_cloud_role')
|
||||
if role == constants.DISTRIBUTED_CLOUD_ROLE_SYSTEMCONTROLLER:
|
||||
dc_api.notify_dcmanager_platform_upgrade_completed()
|
||||
|
||||
# Delete upgrade record
|
||||
self.dbapi.software_upgrade_destroy(upgrade.uuid)
|
||||
|
|
Loading…
Reference in New Issue