Skip to content

Commit 7c9338d

Browse files
authored
Merge pull request ceph#61288 from adamemerson/wip-69303
rgw: Don't crash on exceptions from pool listing Reviewed-by: Casey Bodley <[email protected]>
2 parents 3383af5 + 4318b18 commit 7c9338d

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

src/rgw/driver/rados/rgw_tools.cc

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -339,21 +339,35 @@ int rgw_list_pool(const DoutPrefixProvider *dpp,
339339
ldpp_dout(dpp, 10) << "failed to parse cursor: " << marker << dendl;
340340
return -EINVAL;
341341
}
342-
343-
auto iter = ioctx.nobjects_begin(oc);
342+
librados::NObjectIterator iter;
343+
try {
344+
iter = ioctx.nobjects_begin(oc);
345+
} catch (const std::system_error& e) {
346+
ldpp_dout(dpp, 1) << "rgw_list_pool: Failed to begin iteration of pool "
347+
<< ioctx.get_pool_name() << " with error "
348+
<< e.what() << dendl;
349+
return ceph::from_error_code(e.code());
350+
}
344351
/// Pool_iterate
345352
if (iter == ioctx.nobjects_end())
346353
return -ENOENT;
347354

348-
for (; oids->size() < max && iter != ioctx.nobjects_end(); ++iter) {
349-
string oid = iter->get_oid();
350-
ldpp_dout(dpp, 20) << "RGWRados::pool_iterate: got " << oid << dendl;
355+
try {
356+
for (; oids->size() < max && iter != ioctx.nobjects_end(); ++iter) {
357+
string oid = iter->get_oid();
358+
ldpp_dout(dpp, 20) << "RGWRados::pool_iterate: got " << oid << dendl;
351359

352-
// fill it in with initial values; we may correct later
353-
if (filter && !filter(oid, oid))
354-
continue;
360+
// fill it in with initial values; we may correct later
361+
if (filter && !filter(oid, oid))
362+
continue;
355363

356-
oids->push_back(oid);
364+
oids->push_back(oid);
365+
}
366+
} catch (const std::system_error& e) {
367+
ldpp_dout(dpp, 1) << "rgw_list_pool: Failed iterating pool "
368+
<< ioctx.get_pool_name() << " with error "
369+
<< e.what() << dendl;
370+
return ceph::from_error_code(e.code());
357371
}
358372

359373
marker = iter.get_cursor().to_str();

0 commit comments

Comments
 (0)