From be547a9cf8796ff21bbdf1de611b021e6e0e7691 Mon Sep 17 00:00:00 2001 From: Hemna Date: Tue, 18 Feb 2020 21:46:36 -0800 Subject: [PATCH] API: os-reset_status notification fix This patch fixes the os-reset_status api call notifications for volumes, snapshots and backups and deprecates the existing notifications scheme for os-reset_status. Existing notifications for volumes are going to a publisher_id of 'volumeStatusUpdate'. Notifications for snapshots were going to 'volumeStatusUpdate'. Notifications for backups were going to 'backupStatusUpdate'. This patch changes notifications for volumes to go to the 'volume' publisher_id as all other volume actions in cinder. This patch changes notifications for snapshots to go to the 'snapshot' publisher_id as all other snapshot actions in cinder. This patch changes notifications for backups to go to the 'backup' publisher_id as all other backups actions in cinder. Change-Id: I2550b00127ee2533b0ab12c4efb4927dbcaaa190 Closes-Bug: 1863806 --- cinder/api/contrib/admin_actions.py | 24 +++++++++++++++++ cinder/backup/manager.py | 2 ++ ...-notification-update-4a80a8b5feb821ef.yaml | 26 +++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 releasenotes/notes/reset-status-notification-update-4a80a8b5feb821ef.yaml diff --git a/cinder/api/contrib/admin_actions.py b/cinder/api/contrib/admin_actions.py index 40575bfd183..eeebbe52287 100644 --- a/cinder/api/contrib/admin_actions.py +++ b/cinder/api/contrib/admin_actions.py @@ -31,6 +31,7 @@ from cinder.i18n import _ from cinder import objects from cinder import rpc from cinder import volume +from cinder.volume import volume_utils LOG = logging.getLogger(__name__) @@ -63,6 +64,9 @@ class AdminController(wsgi.Controller): def validate_update(self, req, body): raise NotImplementedError() + def _notify_reset_status(self, context, id, message): + raise NotImplementedError() + def authorize(self, context, action_name, target_obj=None): context.authorize( 'volume_extension:%(resource)s_admin_actions:%(action)s' % @@ -97,10 +101,13 @@ class AdminController(wsgi.Controller): LOG.debug(msg, {'resource': self.resource_name, 'id': id, 'update': update}) + # calling notifier here for volumeStatusUpdate is deprecated. + # Will be replaced with _notify_reset_status() notifier_info = dict(id=id, update=update) notifier = rpc.get_notifier('volumeStatusUpdate') notifier.info(context, self.collection + '.reset_status.start', notifier_info) + self._notify_reset_status(context, id, 'reset_status.start') # Not found exception will be handled at the wsgi level self._update(context, id, update) @@ -110,6 +117,7 @@ class AdminController(wsgi.Controller): notifier.info(context, self.collection + '.reset_status.end', notifier_info) + self._notify_reset_status(context, id, 'reset_status.end') @wsgi.response(http_client.ACCEPTED) @wsgi.action('os-force_delete') @@ -127,6 +135,11 @@ class VolumeAdminController(AdminController): collection = 'volumes' + def _notify_reset_status(self, context, id, message): + volume = objects.Volume.get_by_id(context, id) + volume_utils.notify_about_volume_usage(context, volume, + message) + def _update(self, *args, **kwargs): context = args[0] volume_id = args[1] @@ -242,6 +255,11 @@ class SnapshotAdminController(AdminController): collection = 'snapshots' + def _notify_reset_status(self, context, id, message): + snapshot = objects.Snapshot.get_by_id(context, id) + volume_utils.notify_about_snapshot_usage(context, snapshot, + message) + @validation.schema(admin_actions.reset_status_snapshot) def validate_update(self, req, body): status = body['os-reset_status']['status'] @@ -269,6 +287,11 @@ class BackupAdminController(AdminController): collection = 'backups' + def _notify_reset_status(self, context, id, message): + backup = objects.Backup.get_by_id(context, id) + volume_utils.notify_about_backup_usage(context, backup, + message) + def _get(self, *args, **kwargs): return self.backup_api.get(*args, **kwargs) @@ -291,6 +314,7 @@ class BackupAdminController(AdminController): notifier = rpc.get_notifier('backupStatusUpdate') notifier.info(context, self.collection + '.reset_status.start', notifier_info) + self._notify_reset_status(context, id, 'reset_status.start') # Not found exception will be handled at the wsgi level self.backup_api.reset_status(context=context, backup_id=id, diff --git a/cinder/backup/manager.py b/cinder/backup/manager.py index 54b392e307b..60877db1da3 100644 --- a/cinder/backup/manager.py +++ b/cinder/backup/manager.py @@ -978,6 +978,8 @@ class BackupManager(manager.SchedulerDependentManager): notifier = rpc.get_notifier('backupStatusUpdate') notifier.info(context, "backups.reset_status.end", notifier_info) + volume_utils.notify_about_backup_usage(context, backup, + 'reset_status.end') def check_support_to_force_delete(self, context): """Check if the backup driver supports force delete operation. diff --git a/releasenotes/notes/reset-status-notification-update-4a80a8b5feb821ef.yaml b/releasenotes/notes/reset-status-notification-update-4a80a8b5feb821ef.yaml new file mode 100644 index 00000000000..b996a04272a --- /dev/null +++ b/releasenotes/notes/reset-status-notification-update-4a80a8b5feb821ef.yaml @@ -0,0 +1,26 @@ +--- +deprecations: + - | + In this release, sending ``os-reset_status`` notifications to the + following *nonstandard* publisher_ids is DEPRECATED: + + * 'volumeStatusUpdate' for volume status resets + * 'volumeStatusUpdate' for snapshot status resets + * 'backupStatusUpdate' for backup status resets + + The notifications continue to be published to the above during the + deprecation period. Beginning with this release, the ``os-reset_status`` + notifications are also sent to the following *standard* publisher_ids: + + * 'volume' for volume status resets + * 'snapshot' for snapshot status resets + * 'backup' for backup status resets + + This will allow consumers of these notifications to make a smooth + transition. In the Victoria release, ``os-reset_status`` notifications + will *only* be sent to the standard publisher_ids. +fixes: + - | + ``os-reset_status`` notifications for volumes, snapshots and backups will + now go to the standard publisher id for volume, snapshot and backup like + all other notifications for volume, snapshot and backup.