From: Yehuda Sadeh Date: Fri, 27 Jul 2018 23:18:19 +0000 (-0700) Subject: rgw-admin: add a new lc get command X-Git-Tag: v14.1.0~616^2~30 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dc47ce9f239d74832c3c2dcaae577a2cffad8155;p=ceph.git rgw-admin: add a new lc get command Useful for debugging lifecycle issues Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index f4c7d3f041d3..470261fa47d3 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -191,6 +191,7 @@ void usage() cout << " gc process manually process garbage (specify\n"; cout << " --include-all to process all entries, including unexpired)\n"; cout << " lc list list all bucket lifecycle progress\n"; + cout << " lc get get a lifecycle bucket configuration\n"; cout << " lc process manually process lifecycle\n"; cout << " metadata get get metadata info\n"; cout << " metadata put put metadata info\n"; @@ -431,6 +432,7 @@ enum { OPT_GC_LIST, OPT_GC_PROCESS, OPT_LC_LIST, + OPT_LC_GET, OPT_LC_PROCESS, OPT_ORPHANS_FIND, OPT_ORPHANS_FINISH, @@ -879,6 +881,8 @@ static int get_cmd(const char *cmd, const char *prev_cmd, const char *prev_prev_ } else if (strcmp(prev_cmd, "lc") == 0) { if (strcmp(cmd, "list") == 0) return OPT_LC_LIST; + if (strcmp(cmd, "get") == 0) + return OPT_LC_GET; if (strcmp(cmd, "process") == 0) return OPT_LC_PROCESS; } else if (strcmp(prev_cmd, "orphans") == 0) { @@ -6512,6 +6516,39 @@ next: } + if (opt_cmd == OPT_LC_GET) { + if (bucket_name.empty()) { + cerr << "ERROR: bucket not specified" << std::endl; + return EINVAL; + } + + rgw_bucket bucket; + RGWBucketInfo bucket_info; + map attrs; + RGWLifecycleConfiguration config; + ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket, &attrs); + if (ret < 0) { + cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl; + return -ret; + } + + auto aiter = attrs.find(RGW_ATTR_LC); + if (aiter == attrs.end()) { + return -ENOENT; + } + + bufferlist::const_iterator iter{&aiter->second}; + try { + config.decode(iter); + } catch (const buffer::error& e) { + cerr << "ERROR: decode life cycle config failed" << std::endl; + return -EIO; + } + + encode_json("result", config, formatter); + formatter->flush(cout); + } + if (opt_cmd == OPT_LC_PROCESS) { int ret = store->process_lc(); if (ret < 0) { diff --git a/src/test/cli/radosgw-admin/help.t b/src/test/cli/radosgw-admin/help.t index 3679e3b687a2..d63826026772 100644 --- a/src/test/cli/radosgw-admin/help.t +++ b/src/test/cli/radosgw-admin/help.t @@ -112,6 +112,7 @@ gc process manually process garbage (specify --include-all to process all entries, including unexpired) lc list list all bucket lifecycle progress + lc get get a lifecycle bucket configuration lc process manually process lifecycle metadata get get metadata info metadata put put metadata info