diff options
author | Hemna <waboring@hemna.com> | 2020-02-18 21:46:36 -0800 |
---|---|---|
committer | Walt <waboring@hemna.com> | 2021-02-08 15:16:20 +0000 |
commit | 1b24dd6f45372a180f80a7b13dbddbad4299a073 (patch) | |
tree | 15564487cad055bb3bf1a45b8627fb94bf150c08 | |
parent | abcefa3a11d60c1aff2b1b24e1a835db32adade7 (diff) | |
download | cinder-1b24dd6f45372a180f80a7b13dbddbad4299a073.tar.gz |
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
(cherry picked from commit be547a9cf8796ff21bbdf1de611b021e6e0e7691)
Conflicts:
releasenotes/notes/reset-status-notification-update-4a80a8b5feb821ef.yaml
- modified release note to remove deprecation notice
-rw-r--r-- | cinder/api/contrib/admin_actions.py | 24 | ||||
-rw-r--r-- | cinder/backup/manager.py | 2 | ||||
-rw-r--r-- | releasenotes/notes/reset-status-notification-update-4a80a8b5feb821ef.yaml | 13 |
3 files changed, 39 insertions, 0 deletions
diff --git a/cinder/api/contrib/admin_actions.py b/cinder/api/contrib/admin_actions.py index 02fef3d67..ba0da2d3a 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 a44cc19d8..6c6c44799 100644 --- a/cinder/backup/manager.py +++ b/cinder/backup/manager.py @@ -990,6 +990,8 @@ class BackupManager(manager.ThreadPoolManager): 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 000000000..418dc84ca --- /dev/null +++ b/releasenotes/notes/reset-status-notification-update-4a80a8b5feb821ef.yaml @@ -0,0 +1,13 @@ +--- +fixes: + - | + `Bug #1863806 <https://bugs.launchpad.net/cinder/+bug/1863806>`_: + ``os-reset_status`` notifications for volumes, snapshots, and + backups were being sent to nonstandard publisher_ids relative to + other cinder notifications for volumes, snapshots, and backups. + Now they are also sent to the following *standard* publisher_ids, + where most people would expect to find them: + + * 'volume' for volume status resets + * 'snapshot' for snapshot status resets + * 'backup' for backup status resets |