]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Don't crash on exceptions from pool listing
authorAdam Emerson <aemerson@redhat.com>
Thu, 9 Jan 2025 16:46:32 +0000 (11:46 -0500)
committerYuri Weinstein <yweinste@redhat.com>
Fri, 10 Jan 2025 15:38:17 +0000 (15:38 +0000)
Fixes: https://tracker.ceph.com/issues/69303
Signed-off-by: Adam Emerson <aemerson@redhat.com>
(cherry picked from commit 4318b188740634ead65a986680f9186541c9d1b0)

Fixes: https://tracker.ceph.com/issues/69476
Signed-off-by: Adam Emerson <aemerson@redhat.com>
(cherry picked from commit 84d7d71b43fe5d3c90ec7078ebecd5a1fcb58fc4)

src/rgw/driver/rados/rgw_tools.cc

index 1d131f8d74d8c4abe25d1206ba5dcb4af6ab6863..2d20577a4ec7695d93a375fcc152f03db002d67f 100644 (file)
@@ -354,21 +354,35 @@ int rgw_list_pool(const DoutPrefixProvider *dpp,
     ldpp_dout(dpp, 10) << "failed to parse cursor: " << marker << dendl;
     return -EINVAL;
   }
-
-  auto iter = ioctx.nobjects_begin(oc);
+  librados::NObjectIterator iter;
+  try {
+    iter = ioctx.nobjects_begin(oc);
+  } catch (const std::system_error& e) {
+    ldpp_dout(dpp, 1) << "rgw_list_pool: Failed to begin iteration of pool "
+                     << ioctx.get_pool_name() << " with error "
+                     << e.what() << dendl;
+    return ceph::from_error_code(e.code());
+  }
   /// Pool_iterate
   if (iter == ioctx.nobjects_end())
     return -ENOENT;
 
-  for (; oids->size() < max && iter != ioctx.nobjects_end(); ++iter) {
-    string oid = iter->get_oid();
-    ldpp_dout(dpp, 20) << "RGWRados::pool_iterate: got " << oid << dendl;
+  try {
+    for (; oids->size() < max && iter != ioctx.nobjects_end(); ++iter) {
+      string oid = iter->get_oid();
+      ldpp_dout(dpp, 20) << "RGWRados::pool_iterate: got " << oid << dendl;
 
-    // fill it in with initial values; we may correct later
-    if (filter && !filter(oid, oid))
-      continue;
+      // fill it in with initial values; we may correct later
+      if (filter && !filter(oid, oid))
+       continue;
 
-    oids->push_back(oid);
+      oids->push_back(oid);
+    }
+  } catch (const std::system_error& e) {
+    ldpp_dout(dpp, 1) << "rgw_list_pool: Failed iterating pool "
+                     << ioctx.get_pool_name() << " with error "
+                     << e.what() << dendl;
+    return ceph::from_error_code(e.code());
   }
 
   marker = iter.get_cursor().to_str();