]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
DaemonServer.cc: fix config show command for RGW daemons 55077/head
authorAishwarya Mathuria <amathuri@redhat.com>
Tue, 6 Sep 2022 14:10:43 +0000 (19:40 +0530)
committerAishwarya Mathuria <amathuri@redhat.com>
Mon, 8 Jan 2024 03:44:47 +0000 (09:14 +0530)
RGW daemons register in the servicemap by gid which allows multiple radosgw instances to share an auth key/identity. The daemon name is sent as part of the metadata.  (https://github.com/ceph/ceph/commit/84c265238b796935b3aa66d191593b2e8655f384).
All other daemons register by the daemon name and the manager stores all daemon state information with daemon name as key. The 'config show' command looks up the daemon_state map with the daemon name the user mentions as key (for example: 'osd.0', 'client.rgw', 'mon.a').
Due to the change in RGW daemon registration, the key used for storing daemon state has become rgw.gid and 'config show client.rgw' no longer works.

This change will take care of going through the daemon metadata to look for the RGW daemon name when a user enters the config show command for a RGW daemon. Once the correct daemon is found, we retrieve the corresponding daemon key (rgw.gid) and use that to query the daemon_state map.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2011756
Signed-off-by: Aishwarya Mathuria <amathuri@redhat.com>
(cherry picked from commit b88cecdc7c3dc048550f634ecadc04f661f0fabc)

qa/suites/rados/singleton/all/mon-config.yaml
qa/workunits/mon/config.sh
src/mgr/DaemonServer.cc

index ab1eb81b0948734048c8427d87e8b4910952c0d2..5e36a34a6c1b38ad116a39b9c4274fcb4f26736f 100644 (file)
@@ -6,7 +6,7 @@ roles:
   - osd.0
   - osd.1
   - osd.2
-  - client.0
+  - client.rgw
 openstack:
   - volumes: # attached to each instance
       count: 3
@@ -18,6 +18,7 @@ tasks:
       - sudo ceph config set mgr mgr_pool false --force
     log-ignorelist:
       - \(POOL_APP_NOT_ENABLED\)
+- rgw: [client.rgw]
 - workunit:
     clients:
       all:
index 1b00201ae48165f8336633065d4350f46bfdc37c..42abcf91e212c6007701781f470dae93603f211e 100755 (executable)
@@ -111,6 +111,13 @@ do
 done
 ceph config rm osd.0 osd_scrub_cost
 
+#RGW daemons test config set
+ceph config set client.rgw debug_rgw 22
+while ! ceph config show client.rgw | grep debug_rgw | grep 22 | grep mon
+do
+    sleep 1
+done
+
 # show-with-defaults
 ceph config show-with-defaults osd.0 | grep debug_asok
 
index 0e9e6be2a959f940d33f4bdf3387e93d125fe9f9..5b2457278f9426271bea1888b4d7296be0526a16 100644 (file)
@@ -1981,6 +1981,37 @@ bool DaemonServer::_handle_command(
       cmdctx->reply(-EINVAL, ss);
       return true;
     }
+    /*
+     *  RGW has the daemon name stored in the daemon metadata
+     *  and uses the GID as key in the service_map.
+     *  We need to match the user's query with the daemon name to
+     *  find the correct key for retrieving daemon state.
+     */
+    string daemon_name = key.name;
+    auto p = daemon_name.find("rgw");
+    if (p != daemon_name.npos) {
+      auto rgw_daemons = daemon_state.get_by_service("rgw");
+      for (auto& rgw_daemon : rgw_daemons) {
+       DaemonStatePtr daemon = rgw_daemon.second;
+       string name = daemon->metadata.find("id")->second;
+       /*
+        * The id stored in the metadata is the port number
+        * for the RGW daemon.
+        * In the case of multiple RGW daemons, the user might
+        * use the port number (rgw.8000) to specify the daemon.
+        */
+       auto p = daemon_name.find('.');
+       if (p == key.name.npos) {
+          key = daemon->key;
+       } else {
+         // if user has specified port number in the query
+         if (daemon_name.substr(p + 1) == name) {
+           key = daemon->key;
+           break;
+         }
+        }
+      }
+    }
     DaemonStatePtr daemon = daemon_state.get(key);
     if (!daemon) {
       ss << "no config state for daemon " << who;