From b3a5d3b35835d454224e5404b41a548f52322bed Mon Sep 17 00:00:00 2001 From: Trent Lloyd Date: Wed, 1 Jun 2022 15:46:39 +0800 Subject: [PATCH] Fix image-volume-cache configuration defaults The image_volume_cache_max_count and image_volume_cache_max_size_gb options were incorrectly being written to cinder.conf with a value of "None" when not configured. This occurred because config.get returns None for values with a null default, this value was being placed into a dictionary and sent over relation data to charm-cinder which renders it directly from a list of key-value pairs. Fix the handling of these options not to include them in the dictionary if they are None. Closes-Bug: #1976465 Change-Id: I61781fa5d837d0ed5191d8a92cc8e0bdf600c08a --- src/lib/charm/openstack/cinder_purestorage.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/lib/charm/openstack/cinder_purestorage.py b/src/lib/charm/openstack/cinder_purestorage.py index 8ad403e..2e540d8 100644 --- a/src/lib/charm/openstack/cinder_purestorage.py +++ b/src/lib/charm/openstack/cinder_purestorage.py @@ -48,11 +48,14 @@ class CinderpurestorageCharm( self.config.get('use-chap'))]) if self.config.get('use-image-cache'): - image_cache = [ - ('image_volume_cache_max_size_gb', - self.config.get('image-volume-cache-max-size-gb', 0)), - ('image_volume_cache_max_count', - self.config.get('image-volume-cache-max-count', 0))] + max_size_gb = self.config.get('image-volume-cache-max-size-gb') + if max_size_gb is not None: + image_cache.append(('image_volume_cache_max_size_gb', + max_size_gb)) + + max_count = self.config.get('image-volume-cache-max-count') + if max_count is not None: + image_cache.append(('image_volume_cache_max_count', max_count)) if self.config.get('use-replication'): replication_device = 'backend_id:' + \