]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: set keys from from master zone on admin api user create
authorAli Maredia <amaredia@redhat.com>
Tue, 18 Oct 2022 18:23:57 +0000 (14:23 -0400)
committerAli Maredia <amaredia@redhat.com>
Tue, 24 Jan 2023 21:01:34 +0000 (16:01 -0500)
When users were being created via the admin_api
on a secondary zone the keys returned in the json
output are not correct.

This commit ensures the proper keys are set to be
returned to the user via the json output.

fixes: https://tracker.ceph.com/issues/57724

Signed-off-by: Ali Maredia <amaredia@redhat.com>
src/rgw/driver/rados/rgw_rest_user.cc

index c2aeece247dbe832f18293957d2ef0b85c4d8013..0befc1ee43a64b1b199187cc5b389d5ab48a6d3e 100644 (file)
@@ -206,9 +206,6 @@ void RGWOp_User_Create::execute(optional_yield y)
   if (s->info.args.exists("exclusive"))
     op_state.set_exclusive(exclusive);
 
-  if (gen_key)
-    op_state.set_generate_key();
-
   if (!default_placement_str.empty()) {
     rgw_placement_rule target_rule;
     target_rule.from_str(default_placement_str);
@@ -226,13 +223,28 @@ void RGWOp_User_Create::execute(optional_yield y)
     op_state.set_placement_tags(placement_tags_list);
   }
 
-  bufferlist data;
-  op_ret = driver->forward_request_to_master(s, s->user.get(), nullptr, data, nullptr, s->info, y);
-  if (op_ret < 0) {
-    ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl;
-    return;
+  if(!(store->is_meta_master())) {
+    bufferlist data;
+    JSONParser jp;
+    RGWUserInfo ui;
+    op_ret = store->forward_request_to_master(s, s->user.get(), nullptr, data, &jp, s->info, y);
+    if (op_ret < 0) {
+      ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl;
+      return;
+    }
+    ui.decode_json(&jp);
+    std::map<std::string, RGWAccessKey> keys = ui.access_keys;
+    auto keys_itr = keys.begin();
+    RGWAccessKey first_key = keys_itr->second;
+    op_state.id = first_key.id;
+    op_state.key = first_key.key;
   }
-  op_ret = RGWUserAdminOp_User::create(s, driver, op_state, flusher, y);
+
+  if (gen_key) {
+    op_state.set_generate_key();
+  }
+
+  op_ret = RGWUserAdminOp_User::create(s, store, op_state, flusher, y);
 }
 
 class RGWOp_User_Modify : public RGWRESTOp {