]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/cephadm: fix nfs-rgw stray daemon
authorDaniel Pivonka <dpivonka@redhat.com>
Thu, 8 Apr 2021 19:20:18 +0000 (15:20 -0400)
committerDaniel Pivonka <dpivonka@redhat.com>
Thu, 15 Apr 2021 20:47:24 +0000 (16:47 -0400)
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>
src/pybind/mgr/cephadm/serve.py
src/pybind/mgr/cephadm/tests/test_cephadm.py

index eb5c60fc7f31e17242730b56ab02affa5b956fb3..72a2b85ccdcaba5ca1fdd0783bdd5c8050970e3b 100644 (file)
@@ -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)
index 2bf645de61964a42fba56d69257f5585e0bae2a0..fa9de584bdc811ba3ba7bf010546af32ba5d0c94 100644 (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,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()
-
-            # 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):