From e5d644fec32823a24ef17de6f08c45d273dfd23b 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 --- 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 7222aadf09..ce1e4ff88f 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 ae5a87f2e9..99977b6183 100644 --- a/manila/scheduler/manager.py +++ b/manila/scheduler/manager.py @@ -333,12 +333,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