From 382b56f2fe86659a26b3cdeb20f804245fb6ba6e Mon Sep 17 00:00:00 2001 From: Patrick East Date: Mon, 4 Jan 2016 12:02:50 -0800 Subject: [PATCH] =?utf8?q?Don=E2=80=99t=20log=20warnings=20for=20image=20c?= =?utf8?q?ache=20when=20disabled?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Right now we do a check for the internal tenant and log a warning before we check to see if the cache is even turned on for that backend. We should be only checking for the internal tenant if the image cache has been configured for the backend. In addition we shouldn’t log a warning for this since there is already a warning for the internal context when we try and create it if it is not configured correctly… to reduce the warning spam this change switches the log message to an info level. Change-Id: Iddc4648543d268a4b3b8d557c94c4d2876654e22 Closes-Bug: #1530964 --- cinder/volume/flows/manager/create_volume.py | 31 ++++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/cinder/volume/flows/manager/create_volume.py b/cinder/volume/flows/manager/create_volume.py index 6ae0cc436..4322f5f37 100644 --- a/cinder/volume/flows/manager/create_volume.py +++ b/cinder/volume/flows/manager/create_volume.py @@ -714,24 +714,23 @@ class CreateVolumeFromSpecTask(flow_utils.CinderTask): volume_ref, image_location, image_meta) - # Try and use the image cache. should_create_cache_entry = False - internal_context = cinder_context.get_internal_tenant_context() - if not internal_context: - LOG.warning(_LW('Unable to get Cinder internal context, will ' - 'not use image-volume cache.')) - - if not cloned and internal_context and self.image_volume_cache: - model_update, cloned = self._create_from_image_cache( - context, - internal_context, - volume_ref, - image_id, - image_meta - ) - if not cloned: - should_create_cache_entry = True + if self.image_volume_cache and not cloned: + internal_context = cinder_context.get_internal_tenant_context() + if not internal_context: + LOG.info(_LI('Unable to get Cinder internal context, will ' + 'not use image-volume cache.')) + else: + model_update, cloned = self._create_from_image_cache( + context, + internal_context, + volume_ref, + image_id, + image_meta + ) + if not cloned: + should_create_cache_entry = True # Fall back to default behavior of creating volume, # download the image data and copy it into the volume. -- 2.45.2