From ce80a04a266189c639c001a3357bfb9e5c42da32 Mon Sep 17 00:00:00 2001 From: Callum Dickinson Date: Thu, 11 Sep 2025 23:12:40 +1200 Subject: [PATCH] Make image attributes in Gnocchi optional The container_format and disk_format attributes for Glance images can be set to null in certain cases (such as when images are "empty" and have not any data uploaded to them yet). Ceilometer does generate samples for these when processing notifications or doing polling, and if the size attribute is available and not set to None (which can happen in certain cases) it will try to create the resource in Gnocchi and publish measures. This ends up failing as the container_format and disk_format attributes are marked as "required" in Gnocchi. To make handling for this situation a little better (so these kinds of resources can be monitored for at least), make the container_format and disk_format attributes optional in Gnocchi. Change-Id: I63edfa7d48aa3b75ee73cdcc091fa093c53879d3 Signed-off-by: Callum Dickinson --- ceilometer/gnocchi_client.py | 18 ++++++++++++++++++ ...t-attributes-optional-cc7acd492f791553.yaml | 8 ++++++++ 2 files changed, 26 insertions(+) create mode 100644 releasenotes/notes/make-image-format-attributes-optional-cc7acd492f791553.yaml diff --git a/ceilometer/gnocchi_client.py b/ceilometer/gnocchi_client.py index d71905728b..4ea1843d9e 100644 --- a/ceilometer/gnocchi_client.py +++ b/ceilometer/gnocchi_client.py @@ -227,6 +227,24 @@ resources_update_operations = [ "value": {"type": "string", "min_length": 0, "max_length": 255, "required": False} # Allow the hypervisor to be withheld }]}, + {"desc": "make container_format optional for image", + "type": "update_attribute_type", + "resource_type": "image", + "data": [{ + "op": "add", # Usually update, the attribute likely already exists + "path": "/attributes/container_format", + "value": {"type": "string", "min_length": 0, "max_length": 255, + "required": False} # This can be null in certain cases + }]}, + {"desc": "make disk_format optional for image", + "type": "update_attribute_type", + "resource_type": "image", + "data": [{ + "op": "add", # Usually update, the attribute likely already exists + "path": "/attributes/disk_format", + "value": {"type": "string", "min_length": 0, "max_length": 255, + "required": False} # This can be null in certain cases + }]}, ] diff --git a/releasenotes/notes/make-image-format-attributes-optional-cc7acd492f791553.yaml b/releasenotes/notes/make-image-format-attributes-optional-cc7acd492f791553.yaml new file mode 100644 index 0000000000..55a60a959d --- /dev/null +++ b/releasenotes/notes/make-image-format-attributes-optional-cc7acd492f791553.yaml @@ -0,0 +1,8 @@ +--- +upgrade: + - | + The ``container_format`` and ``disk_format`` attributes have been made + optional for ``image`` resources in Gnocchi. This fixes an issue where + image resources would fail to be created in Gnocchi because + ``container_format`` and ``disk_format`` are set to ``null`` (which is + possible on images that haven't had data uploaded to them yet).