From 21f44848269e57b3f0fc03511db89cd8f3b6b672 Mon Sep 17 00:00:00 2001 From: Michel Nederlof Date: Tue, 30 Apr 2024 16:23:38 +0200 Subject: [PATCH] Add more metadata to volume.size and volume.backup.size pollster When events are received from cinder, this includes the the volume_type_id field (and not the volume_type name). Since Wallaby version it is now possible to fetch this id from the API, so we can now make this poller consistent with what is sent over the notification bus. Another useful missing field for backups is the is_incremental field. As the backup.user_id field was added in microversion 3.56, it makes sense to add this information here as well to make it consistent with other samples. Closes-bug: #2064290 Change-Id: Ib109f399bab43ed8a6a0e0afea27ff0e5f7ae883 --- ceilometer/tests/unit/volume/test_cinder.py | 9 +++++++++ ceilometer/volume/cinder.py | 4 +++- ceilometer/volume/discovery.py | 6 ++++-- ...dd-volume-pollster-metadata-d7b435fed9aac0aa.yaml | 12 ++++++++++++ 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/add-volume-pollster-metadata-d7b435fed9aac0aa.yaml diff --git a/ceilometer/tests/unit/volume/test_cinder.py b/ceilometer/tests/unit/volume/test_cinder.py index d528e1b0e9..94806d311a 100644 --- a/ceilometer/tests/unit/volume/test_cinder.py +++ b/ceilometer/tests/unit/volume/test_cinder.py @@ -63,6 +63,12 @@ VOLUME_LIST = [ u"size": u"1572864000" }, 'os-vol-mig-status-attr:name_id': None, + 'group_id': None, + 'provider_id': None, + 'shared_targets': False, + 'service_uuid': '2f6b5a18-0cd5-4421-b97e-d2c3e85ed758', + 'cluster_name': None, + 'volume_type_id': '65a9f65a-4696-4435-a09d-bc44d797c529', 'name': None, 'bootable': 'false', 'created_at': '2016-06-23T08:27:45.000000', @@ -95,6 +101,7 @@ SNAPSHOT_LIST = [ u"min_ram": u"0", u"size": u"1572864000" }, + "group_snapshot_id": None, 'name': None}) ] @@ -121,6 +128,8 @@ BACKUP_LIST = [ '6824974c08974d4db864bbaa6bc08303', 'fail_reason': u"", 'is_incremental': False, + 'metadata': {}, + 'user_id': 'be255bd31eb944578000fc762fde6dcf', 'id': '75a52125-85ff-4a8d-b2aa-580f3b22273f', 'size': 1}) ] diff --git a/ceilometer/volume/cinder.py b/ceilometer/volume/cinder.py index 06d5fca052..3037694716 100644 --- a/ceilometer/volume/cinder.py +++ b/ceilometer/volume/cinder.py @@ -39,6 +39,7 @@ class VolumeSizePollster(_Base): FIELDS = ['name', 'status', 'volume_type', + 'volume_type_id', 'availability_zone', 'os-vol-host-attr:host', 'migration_status', @@ -96,6 +97,7 @@ class VolumeBackupSize(_Base): return 'volume_backups' FIELDS = ['name', + 'is_incremental', 'object_count', 'container', 'volume_id', @@ -109,7 +111,7 @@ class VolumeBackupSize(_Base): type=sample.TYPE_GAUGE, unit='GB', volume=backup.size, - user_id=None, + user_id=backup.user_id, project_id=getattr( backup, 'os-backup-project-attr:project_id', None), resource_id=backup.id, diff --git a/ceilometer/volume/discovery.py b/ceilometer/volume/discovery.py index eefa36dec0..c80160d928 100644 --- a/ceilometer/volume/discovery.py +++ b/ceilometer/volume/discovery.py @@ -28,10 +28,12 @@ class _BaseDiscovery(plugin_base.DiscoveryBase): def __init__(self, conf): super(_BaseDiscovery, self).__init__(conf) creds = conf.service_credentials - # NOTE(tobias-urdin): We set 3.43 (the maximum for Pike) because + # NOTE(mnederlof): We set 3.64 (the maximum for Wallaby) because: # we need atleast 3.41 to get user_id on snapshots. + # we need atleast 3.56 for user_id and project_id on backups. + # we need atleast 3.63 for volume_type_id on volumes. self.client = cinder_client.Client( - version='3.43', + version='3.64', session=keystone_client.get_session(conf), region_name=creds.region_name, interface=creds.interface, diff --git a/releasenotes/notes/add-volume-pollster-metadata-d7b435fed9aac0aa.yaml b/releasenotes/notes/add-volume-pollster-metadata-d7b435fed9aac0aa.yaml new file mode 100644 index 0000000000..8cecebd4d9 --- /dev/null +++ b/releasenotes/notes/add-volume-pollster-metadata-d7b435fed9aac0aa.yaml @@ -0,0 +1,12 @@ +--- +features: + - > + Add volume.volume_type_id and backup.is_incremental metadata for cinder + pollsters. Also user_id information is now included for backups with the + generated samples. +upgrade: + - > + The cinder api microversion has been increased from Pike to Wallaby + version (3.64) for volume/snapshot/backup related pollsters. + These might not work until the cinder API has been upgraded up to this + microversion.