From 1e6707212244440c35881dafcea435d4f134124e Mon Sep 17 00:00:00 2001 From: whoami-rajat Date: Fri, 13 Dec 2019 14:26:00 +0000 Subject: [PATCH] Fix: failed to create snapshot with DriverFilter Previously, while creating snapshots, the code didn't pass through scheduler therefore available capacity for backend wasn't checked. This was supported by [1] which passed a RequestSpec object to scheduler with snapshot and volume properties (the same RequestSpec object is used for volumes). But when the scheduler tries to get volume_type from RequestSpec obj, unfortunately, it has a property named 'volume_type' but is None for snapshots which breaks the scheduler when getting extra_specs from the volume type (as the default value {} would've been set if the property didn't exist). Similar issue occurred when we supported untyped volumes and was fixed by [2] and [3]. This patch sets the volume_type to an empty dict when it is found None (which is the case while creating snapshots). [1] https://review.opendev.org/#/c/509011/ [2] https://review.opendev.org/#/c/457431/ [3] https://review.opendev.org/#/c/471672/ Change-Id: I89a8cc42ca8984ee837a2b88f60ad126783282b9 Closes-Bug: #1856126 --- cinder/scheduler/filter_scheduler.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cinder/scheduler/filter_scheduler.py b/cinder/scheduler/filter_scheduler.py index d4969a4f772..b67e0595584 100644 --- a/cinder/scheduler/filter_scheduler.py +++ b/cinder/scheduler/filter_scheduler.py @@ -287,7 +287,12 @@ class FilterScheduler(driver.Scheduler): # takes 'resource_XX' and 'volume_XX' as input respectively, copying # 'volume_XX' to 'resource_XX' will make both filters happy. volume_type = request_spec.get("volume_type") - resource_type = volume_type if volume_type is not None else {} + # When creating snapshots, the value of volume_type is None here + # which causes issues in filters (Eg: Bug #1856126). + # To prevent that, we set it as an empty dictionary here. + if volume_type is None: + volume_type = {} + resource_type = volume_type config_options = self._get_configuration_options()