Coverage for manila/scheduler/filters/retry.py: 100%
15 statements
« prev ^ index » next coverage.py v7.11.0, created at 2026-02-18 22:19 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2026-02-18 22:19 +0000
1# Copyright (c) 2012 OpenStack, LLC.
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
16from oslo_log import log
18from manila.scheduler.filters import base_host
20LOG = log.getLogger(__name__)
23class RetryFilter(base_host.BaseHostFilter):
24 """Filter out already tried nodes for scheduling purposes."""
26 def host_passes(self, host_state, filter_properties):
27 """Skip nodes that have already been attempted."""
28 retry = filter_properties.get('retry')
29 if not retry:
30 # Re-scheduling is disabled
31 LOG.debug("Re-scheduling is disabled")
32 return True
34 hosts = retry.get('hosts', [])
35 host = host_state.host
37 passes = host not in hosts
38 pass_msg = "passes" if passes else "fails"
40 LOG.debug("Host %(host)s %(pass_msg)s. Previously tried hosts: "
41 "%(hosts)s",
42 {"host": host, "pass_msg": pass_msg, "hosts": hosts})
44 # Host passes if it's not in the list of previously attempted hosts:
45 return passes