]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/admin: add support for 'config help' 39812/head
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 3 Mar 2021 14:21:28 +0000 (14:21 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 3 Mar 2021 14:47:29 +0000 (14:47 +0000)
This commit solves a problem unveiled in teuthology testing
where `ceph --admin-daemon ... config help` were constantly
returning `EINVAL`:

```
2021-03-03T02:43:01.566 DEBUG:tasks.admin_socket:Testing config help with config {'branch': 'master'}
2021-03-03T02:43:01.567 DEBUG:teuthology.orchestra.run.smithi083:> sudo adjust-ulimits ceph-coverage /home/ubuntu/cephtest/archive/coverage ceph --admin-daemon /var/run/ceph/ceph-osd.0.asok config help
2021-03-03T02:43:01.711 INFO:teuthology.orchestra.run.smithi083.stderr:no valid command found; 3 closest matches:
2021-03-03T02:43:01.712 INFO:teuthology.orchestra.run.smithi083.stderr:config get <var>
2021-03-03T02:43:01.712 INFO:teuthology.orchestra.run.smithi083.stderr:config set <var> <val>...
2021-03-03T02:43:01.712 INFO:teuthology.orchestra.run.smithi083.stderr:config show
2021-03-03T02:43:01.713 INFO:teuthology.orchestra.run.smithi083.stderr:admin_socket: invalid command
2021-03-03T02:43:01.714 DEBUG:teuthology.orchestra.run:got remote process result: 22
2021-03-03T02:43:01.714 INFO:tasks.admin_socket:ceph cli returned an error, command not registered yet?
2021-03-03T02:43:01.715 INFO:tasks.admin_socket:sleeping and retrying ...
```

The root cause is no support for `config help` in crimson.
As shown below this command hasn't been registered at all:

```
DEBUG 2021-03-03 02:42:48,242 [shard 0] osd - start: asok socket path=/var/run/ceph/ceph-osd.0.asok
INFO  2021-03-03 02:42:48,242 [shard 0] osd - register_command(): mark_unfound_lost)
INFO  2021-03-03 02:42:48,242 [shard 0] osd - register_command(): query)
INFO  2021-03-03 02:42:48,242 [shard 0] osd - register_command(): perf dump_seastar)
INFO  2021-03-03 02:42:48,242 [shard 0] osd - register_command(): dump_pgstate_history)
INFO  2021-03-03 02:42:48,242 [shard 0] osd - register_command(): flush_pg_stats)
INFO  2021-03-03 02:42:48,243 [shard 0] osd - register_command(): send_beacon)
INFO  2021-03-03 02:42:48,243 [shard 0] osd - register_command(): status)
INFO  2021-03-03 02:42:48,243 [shard 0] osd - register_command(): injectargs)
INFO  2021-03-03 02:42:48,243 [shard 0] osd - register_command(): config show)
INFO  2021-03-03 02:42:48,243 [shard 0] osd - register_command(): config set)
INFO  2021-03-03 02:42:48,243 [shard 0] osd - register_command(): config get)
INFO  2021-03-03 02:42:48,243 [shard 0] osd - register_command(): get_command_descriptions)
INFO  2021-03-03 02:42:48,243 [shard 0] osd - register_command(): help)
INFO  2021-03-03 02:42:48,243 [shard 0] osd - register_command(): git_version)
INFO  2021-03-03 02:42:48,243 [shard 0] osd - register_command(): version)
```

Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/admin/admin_socket.cc

index 852185af18d9547851b74902d20065ae5546f3ba..0c05ce73302b7b83c0bf94994724866f40f9f12c 100644 (file)
@@ -13,6 +13,7 @@
 #include <seastar/core/thread.hh>
 #include <seastar/util/std-compat.hh>
 
+#include "common/options.h"
 #include "common/version.h"
 #include "messages/MCommand.h"
 #include "messages/MCommandReply.h"
@@ -501,6 +502,31 @@ public:
   }
 };
 
+/**
+ * listing the configuration values
+ */
+class ConfigHelpHook : public AdminSocketHook {
+public:
+  ConfigHelpHook() :
+    AdminSocketHook{"config help",
+                    "",
+                    "get config setting schema and descriptions"}
+  {}
+  seastar::future<tell_result_t> call(const cmdmap_t&,
+                                      std::string_view format,
+                                      ceph::bufferlist&& input) const final
+  {
+    unique_ptr<Formatter> f{Formatter::create(format, "json-pretty", "json-pretty")};
+    // Output all
+    f->open_array_section("options");
+    for (const auto &option : ceph_options) {
+      f->dump_object("option", option);
+    }
+    f->close_section();
+    return seastar::make_ready_future<tell_result_t>(std::move(f));
+  }
+};
+
 /// the hooks that are served directly by the admin_socket server
 seastar::future<> AdminSocket::register_admin_commands()
 {
@@ -512,6 +538,7 @@ seastar::future<> AdminSocket::register_admin_commands()
     register_command(std::make_unique<ConfigGetHook>()),
     register_command(std::make_unique<ConfigSetHook>()),
     register_command(std::make_unique<ConfigShowHook>()),
+    register_command(std::make_unique<ConfigHelpHook>()),
     register_command(std::make_unique<InjectArgsHook>())
   ).then_unpack([] {
     return seastar::now();