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
This commit is contained in:
Hemna 2020-02-18 21:46:36 -08:00
parent fcbfa927a3
commit be547a9cf8
3 changed files with 52 additions and 0 deletions

View File

@ -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,

View File

@ -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.

View File

@ -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.