From 24a1b097ec916d00a0b312ce3f7f9491b55e0ee4 Mon Sep 17 00:00:00 2001 From: haixin Date: Mon, 18 Apr 2022 12:42:18 +0800 Subject: [PATCH] update capacity filter during extend share use size increase to calculate provisioned_ratio during extend share. Closes-Bug: #1968891 Change-Id: I2d4903d6a2fda588b126a062c755db2fa2b09cdb (cherry picked from commit e5d644fec32823a24ef17de6f08c45d273dfd23b) (cherry picked from commit 19be7bb13ab988712b4aa57f0d9e73eecb2fb0af) (cherry picked from commit 9e05299994936afce80229cf8fa522f1d18a326b) --- manila/scheduler/filters/capacity.py | 4 +++- manila/scheduler/manager.py | 8 ++++++-- ...ils-to-pass-when-extending-share-6b60799e7aa41e19.yaml | 6 ++++++ 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/bug-1968891-fix-scheduler-capacity-filter-fails-to-pass-when-extending-share-6b60799e7aa41e19.yaml diff --git a/manila/scheduler/filters/capacity.py b/manila/scheduler/filters/capacity.py index 0a2f74ffe7..c66a6f7071 100644 --- a/manila/scheduler/filters/capacity.py +++ b/manila/scheduler/filters/capacity.py @@ -32,7 +32,9 @@ class CapacityFilter(base_host.BaseHostFilter): def host_passes(self, host_state, filter_properties): """Return True if host has sufficient capacity.""" - share_size = filter_properties.get('size', 0) + size_increase = filter_properties.get('size_increase') + share_size = size_increase if size_increase else filter_properties.get( + 'size', 0) if host_state.free_capacity_gb is None: # Fail Safe diff --git a/manila/scheduler/manager.py b/manila/scheduler/manager.py index 2bac36d2de..b3e68dcb8a 100644 --- a/manila/scheduler/manager.py +++ b/manila/scheduler/manager.py @@ -327,12 +327,16 @@ class SchedulerManager(manager.Manager): share = db.share_get(context, share_id) try: + size_increase = int(new_size) - share['size'] + if filter_properties: + filter_properties['size_increase'] = size_increase + else: + filter_properties = {'size_increase': size_increase} target_host = self.driver.host_passes_filters( context, share['host'], request_spec, filter_properties) - target_host.consume_from_share( - {'size': int(new_size) - share['size']}) + target_host.consume_from_share({'size': size_increase}) share_rpcapi.ShareAPI().extend_share(context, share, new_size, reservations) except exception.NoValidHost as ex: diff --git a/releasenotes/notes/bug-1968891-fix-scheduler-capacity-filter-fails-to-pass-when-extending-share-6b60799e7aa41e19.yaml b/releasenotes/notes/bug-1968891-fix-scheduler-capacity-filter-fails-to-pass-when-extending-share-6b60799e7aa41e19.yaml new file mode 100644 index 0000000000..2807954f53 --- /dev/null +++ b/releasenotes/notes/bug-1968891-fix-scheduler-capacity-filter-fails-to-pass-when-extending-share-6b60799e7aa41e19.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + `Launchpad bug 1968891 `_ + has been fixed. scheduler will use size increase rather than share size + to calculate provisioned_ratio when extending share. \ No newline at end of file