mirror of
https://github.com/ceph/ceph
synced 2025-04-01 23:02:17 +00:00
mgr/cephadm: fix nfs-rgw stray daemon
nfs-rgw registers under a gid cephadm needs covert that to its known name during the stray daemon check Signed-off-by: Daniel Pivonka <dpivonka@redhat.com>
This commit is contained in:
parent
9d7a42e709
commit
f94e0baf9e
@ -410,21 +410,22 @@ class CephadmServe:
|
||||
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)
|
||||
|
@ -386,39 +386,45 @@ class TestCephadm(object):
|
||||
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'}},
|
||||
),
|
||||
]
|
||||
)
|
||||
@ -427,7 +433,8 @@ class TestCephadm(object):
|
||||
cephadm_module,
|
||||
ceph_services,
|
||||
cephadm_daemons,
|
||||
strays_expected
|
||||
strays_expected,
|
||||
metadata
|
||||
):
|
||||
# mock ceph service-map
|
||||
services = []
|
||||
@ -447,23 +454,28 @@ class TestCephadm(object):
|
||||
dm[dd.name()] = dd
|
||||
cephadm_module.cache.update_host_daemons('host1', dm)
|
||||
|
||||
# test
|
||||
CephadmServe(cephadm_module)._check_for_strays()
|
||||
def get_metadata_mock(svc_type, svc_id, default):
|
||||
return metadata[svc_id]
|
||||
|
||||
# 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)
|
||||
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):
|
||||
|
Loading…
Reference in New Issue
Block a user