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:
Daniel Pivonka 2021-04-08 15:20:18 -04:00
parent 9d7a42e709
commit f94e0baf9e
2 changed files with 43 additions and 30 deletions

View File

@ -410,11 +410,15 @@ 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:
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(
@ -422,9 +426,6 @@ class CephadmServe:
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)

View File

@ -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,6 +454,11 @@ class TestCephadm(object):
dm[dd.name()] = dd
cephadm_module.cache.update_host_daemons('host1', dm)
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()