]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: BILog_List handles requests for generation=0 wip-rgw-multisite-reshard-prebase-2021-04-29
authorCasey Bodley <cbodley@redhat.com>
Thu, 25 Feb 2021 20:39:26 +0000 (15:39 -0500)
committerCasey Bodley <cbodley@redhat.com>
Thu, 25 Feb 2021 20:39:28 +0000 (15:39 -0500)
previous logic treated requests for generation=0 as the latest gen

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_rest_log.cc

index e4f9a4a993e4ab38003dd520237f4a50616b64e1..d2788cdb4e428b9892d48cfc0dfc031da44f1dfd 100644 (file)
@@ -360,12 +360,13 @@ void RGWOp_MDLog_Notify::execute(optional_yield y) {
 }
 
 void RGWOp_BILog_List::execute(optional_yield y) {
+  bool gen_specified = false;
   string tenant_name = s->info.args.get("tenant"),
          bucket_name = s->info.args.get("bucket"),
          marker = s->info.args.get("marker"),
          max_entries_str = s->info.args.get("max-entries"),
          bucket_instance = s->info.args.get("bucket-instance"),
-         gen_str = s->info.args.get("generation"),
+         gen_str = s->info.args.get("generation", &gen_specified),
          format_version_str = s->info.args.get("format-ver");
   RGWBucketInfo bucket_info;
   unsigned max_entries;
@@ -377,11 +378,14 @@ void RGWOp_BILog_List::execute(optional_yield y) {
   }
 
   string err;
-  const uint64_t gen = strict_strtoll(gen_str.c_str(), 10, &err);
-  if (!err.empty()) {
-    ldpp_dout(s, 5) << "Error parsing generation param " << gen_str << dendl;
-    op_ret = -EINVAL;
-    return;
+  std::optional<uint64_t> gen;
+  if (gen_specified) {
+    gen = strict_strtoll(gen_str.c_str(), 10, &err);
+    if (!err.empty()) {
+      ldpp_dout(s, 5) << "Error parsing generation param " << gen_str << dendl;
+      op_ret = -EINVAL;
+      return;
+    }
   }
 
   if (!format_version_str.empty()) {
@@ -418,9 +422,9 @@ void RGWOp_BILog_List::execute(optional_yield y) {
   const auto& logs = bucket_info.layout.logs;
   auto log = std::prev(logs.end());
   if (gen) {
-    log = std::find_if(logs.begin(), logs.end(), rgw::matches_gen(gen));
+    log = std::find_if(logs.begin(), logs.end(), rgw::matches_gen(*gen));
     if (log == logs.end()) {
-      ldpp_dout(s, 5) << "ERROR: no log layout with gen=" << gen << dendl;
+      ldpp_dout(s, 5) << "ERROR: no log layout with gen=" << *gen << dendl;
       op_ret = -ENOENT;
       return;
     }