Previously, when both the label and host pattern were
provided, only the label was actually used for the placement
Fixes: https://tracker.ceph.com/issues/64428
Signed-off-by: Adam King <adking@redhat.com>
(cherry picked from commit
106f34ba31c82dd87f4c3f9ad82d8ace81e6c689)
hostname=x.hostname, ports=self.ports_start)
for x in self.hosts_by_label(self.spec.placement.label)
]
+ if self.spec.placement.host_pattern:
+ ls = [h for h in ls if h.hostname in self.spec.placement.filter_matching_hostspecs(self.hosts)]
elif self.spec.placement.host_pattern:
ls = [
DaemonPlacement(daemon_type=self.primary_daemon_type,
'rgw:host2(*:81)', 'rgw:host3(*:81)'],
['rgw.c']
),
+ # label + host pattern
+ # Note all hosts will get the "foo" label, we are checking
+ # that it also filters on the host pattern when label is provided
+ NodeAssignmentTest(
+ 'mgr',
+ PlacementSpec(label='foo', host_pattern='mgr*'),
+ 'mgr1 mgr2 osd1'.split(),
+ [],
+ None, None,
+ ['mgr:mgr1', 'mgr:mgr2'], ['mgr:mgr1', 'mgr:mgr2'], []
+ ),
# cephadm.py teuth case
NodeAssignmentTest(
'mgr',
all_hosts = [hs.hostname for hs in hostspecs]
return [h.hostname for h in self.hosts if h.hostname in all_hosts]
if self.label:
- return [hs.hostname for hs in hostspecs if self.label in hs.labels]
- all_hosts = [hs.hostname for hs in hostspecs]
+ all_hosts = [hs.hostname for hs in hostspecs if self.label in hs.labels]
+ else:
+ all_hosts = [hs.hostname for hs in hostspecs]
if self.host_pattern:
return fnmatch.filter(all_hosts, self.host_pattern)
return all_hosts