Add support for k8s-upgrade-completed event notification

This will be used by sysinv to notify dcmanager that the kubernetes
upgrade has been completed so that it can trigger a kubernetes
audit of all subclouds.

Change-Id: I2ff48c939e808c3576a5739fa1dc37906e6a3a4e
Signed-off-by: Jessica Castelino <jessica.castelino@windriver.com>
Closes-Bug: 1928864
Depends-On: https://review.opendev.org/c/starlingx/config/+/792043
This commit is contained in:
Jessica Castelino
2021-05-19 10:02:25 -04:00
parent 077ab926e3
commit 6b87e18029
2 changed files with 19 additions and 3 deletions

View File

@@ -51,10 +51,15 @@ class NotificationsController(object):
events = request.json_body['events']
if 'platform-upgrade-completed' in events:
# We're being notified that an upgrade has completed, so
# we want to trigger a load audit of all subclouds on the
# We're being notified that a platform upgrade has completed,
# so we want to trigger a load audit of all subclouds on the
# next audit cycle.
context = restcomm.extract_context_from_environ()
self.audit_rpc_client.trigger_load_audit(context)
if 'k8s-upgrade-completed' in events:
# We're being notified that a kubernetes upgrade has completed,
# so we want to trigger a kubernetes audit of all subclouds on
# the next audit cycle.
context = restcomm.extract_context_from_environ()
self.audit_rpc_client.trigger_kubernetes_audit(context)
return

View File

@@ -46,3 +46,14 @@ class TestNotificationsController(testroot.DCManagerApiTest):
self.assertEqual(response.status_code, http_client.OK)
mock_audit_rpc_client().trigger_load_audit.assert_called_once_with(
mock.ANY)
@mock.patch.object(audit_rpc_client, 'ManagerAuditClient')
def test_post_k8(self, mock_audit_rpc_client):
mock_audit_rpc_client().trigger_kubernetes_audit.return_value = None
post_url = FAKE_URL
params = json.dumps({'events': ['k8s-upgrade-completed']})
response = self.app.post(post_url, params=params, headers=FAKE_HEADERS)
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.status_code, http_client.OK)
mock_audit_rpc_client().trigger_kubernetes_audit.assert_called_once_with(
mock.ANY)