daemon_id = s.get('id')
assert daemon_id
name = '%s.%s' % (s.get('type'), daemon_id)
- if s.get('type') in ['rbd-mirror', 'cephfs-mirror', 'rgw']:
+ if s.get('type') in ['rbd-mirror', 'cephfs-mirror', 'rgw', 'rgw-nfs']:
metadata = self.mgr.get_metadata(
cast(str, s.get('type')), daemon_id, {})
assert metadata is not None
try:
- name = '%s.%s' % (s.get('type'), metadata['id'])
+ if s.get('type') == 'rgw-nfs':
+ # https://tracker.ceph.com/issues/49573
+ name = metadata['id'][:-4]
+ else:
+ name = '%s.%s' % (s.get('type'), metadata['id'])
except (KeyError, TypeError):
self.log.debug(
"Failed to find daemon id for %s service %s" % (
s.get('type'), s.get('id')
)
)
- elif s.get('type') == 'rgw-nfs':
- # https://tracker.ceph.com/issues/49573
- name = daemon_id.split('-rgw')[0]
if host not in self.mgr.inventory:
missing_names.append(name)
assert out == {'host1': ['0']}
@ pytest.mark.parametrize(
- "ceph_services, cephadm_daemons, strays_expected",
+ "ceph_services, cephadm_daemons, strays_expected, metadata",
# [ ([(daemon_type, daemon_id), ... ], [...], [...]), ... ]
[
(
[('mds', 'a'), ('osd', '0'), ('mgr', 'x')],
[],
[('mds', 'a'), ('osd', '0'), ('mgr', 'x')],
+ {},
),
(
[('mds', 'a'), ('osd', '0'), ('mgr', 'x')],
[('mds', 'a'), ('osd', '0'), ('mgr', 'x')],
[],
+ {},
),
(
[('mds', 'a'), ('osd', '0'), ('mgr', 'x')],
[('mds', 'a'), ('osd', '0')],
[('mgr', 'x')],
+ {},
),
# https://tracker.ceph.com/issues/49573
(
- [('rgw-nfs', 'nfs.foo.host1-rgw')],
+ [('rgw-nfs', '14649')],
[],
- [('nfs', 'foo.host1')],
+ [('nfs', 'foo-rgw.host1')],
+ {'14649': {'id': 'nfs.foo-rgw.host1-rgw'}},
),
(
- [('rgw-nfs', 'nfs.foo.host1-rgw')],
- [('nfs', 'foo.host1')],
+ [('rgw-nfs', '14649'), ('rgw-nfs', '14650')],
+ [('nfs', 'foo-rgw.host1'), ('nfs', 'foo2.host2')],
[],
+ {'14649': {'id': 'nfs.foo-rgw.host1-rgw'}, '14650': {'id': 'nfs.foo2.host2-rgw'}},
),
(
- [],
- [('nfs', 'foo.host1')],
- [],
+ [('rgw-nfs', '14649'), ('rgw-nfs', '14650')],
+ [('nfs', 'foo-rgw.host1')],
+ [('nfs', 'foo2.host2')],
+ {'14649': {'id': 'nfs.foo-rgw.host1-rgw'}, '14650': {'id': 'nfs.foo2.host2-rgw'}},
),
]
)
cephadm_module,
ceph_services,
cephadm_daemons,
- strays_expected
+ strays_expected,
+ metadata
):
# mock ceph service-map
services = []
dm[dd.name()] = dd
cephadm_module.cache.update_host_daemons('host1', dm)
- # test
- CephadmServe(cephadm_module)._check_for_strays()
-
- # verify
- strays = cephadm_module.health_checks.get('CEPHADM_STRAY_DAEMON')
- if not strays:
- assert len(strays_expected) == 0
- else:
- for dt, di in strays_expected:
- name = '%s.%s' % (dt, di)
- for detail in strays['detail']:
- if name in detail:
- strays['detail'].remove(detail)
- break
- assert name in detail
- assert len(strays['detail']) == 0
- assert strays['count'] == len(strays_expected)
+ def get_metadata_mock(svc_type, svc_id, default):
+ return metadata[svc_id]
+
+ with mock.patch.object(cephadm_module, 'get_metadata', new_callable=lambda: get_metadata_mock):
+
+ # test
+ CephadmServe(cephadm_module)._check_for_strays()
+
+ # verify
+ strays = cephadm_module.health_checks.get('CEPHADM_STRAY_DAEMON')
+ if not strays:
+ assert len(strays_expected) == 0
+ else:
+ for dt, di in strays_expected:
+ name = '%s.%s' % (dt, di)
+ for detail in strays['detail']:
+ if name in detail:
+ strays['detail'].remove(detail)
+ break
+ assert name in detail
+ assert len(strays['detail']) == 0
+ assert strays['count'] == len(strays_expected)
@mock.patch("cephadm.module.CephadmOrchestrator.mon_command")
def test_find_destroyed_osds_cmd_failure(self, _mon_cmd, cephadm_module):