Skip to content

Commit c834352

Browse files
rgw/sts: replacing load_stats with list_buckets
to correctly create a federated user in oidc namespace. The idea was to check if the federated user had any buckets associated with it from the time when the logic for creating a shadow user was not in place, and this was done by calling read_stats which returned -ENOENT when the user did not exist, which was erroneously interpreted as buckets not existing for the user - but this logic correctly led to creation of user in oidc namespace. Later read_stats() was replaced by load_stats() and load_stats() does not return -ENOENT when a user does not exist, hence according to the code, the federated user was not getting created in 'oidc' namespace. Hence replaced load_stats() with list_buckets() and corrected the code to create a user in oidc namespace if the user did not own any bucket. Fixes: https://tracker.ceph.com/issues/69924 Signed-off-by: Pritha Srivastava <[email protected]>
1 parent cc45b84 commit c834352

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/rgw/rgw_auth.cc

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -672,16 +672,18 @@ auto rgw::auth::WebIdentityApplier::load_acct_info(const DoutPrefixProvider* dpp
672672
}
673673

674674
//Check if user_id.buckets already exists, may have been from the time, when shadow users didnt exist
675-
RGWStorageStats stats;
676-
ceph::real_time last_synced;
677-
ceph::real_time last_updated;
678-
int ret = driver->load_stats(dpp, null_yield, federated_user, stats,
679-
last_synced, last_updated);
680-
if (ret < 0 && ret != -ENOENT) {
681-
ldpp_dout(dpp, 0) << "ERROR: reading stats for the user returned error " << ret << dendl;
675+
federated_user.ns = "";
676+
constexpr bool need_stats = false;
677+
const std::string marker; // empty
678+
constexpr uint32_t max_items = 1;
679+
rgw::sal::BucketList buckets;
680+
auto ret = driver->list_buckets(dpp, federated_user, federated_user.tenant, marker, marker,
681+
max_items, need_stats, buckets, null_yield);
682+
if (ret < 0) {
683+
ldpp_dout(dpp, 0) << "ERROR: list buckets for the user returned error " << ret << dendl;
682684
return user;
683685
}
684-
if (ret == -ENOENT) { /* in case of ENOENT, which means user doesnt have buckets */
686+
if (buckets.buckets.empty()) { /* no buckets */
685687
//In this case user will be created in oidc namespace
686688
ldpp_dout(dpp, 5) << "NOTICE: incoming user has no buckets " << federated_user << dendl;
687689
federated_user.ns = "oidc";

0 commit comments

Comments
 (0)