]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/role: use CreateDate from forwarded CreateRole response
authorCasey Bodley <cbodley@redhat.com>
Thu, 15 Feb 2024 23:53:16 +0000 (18:53 -0500)
committerCasey Bodley <cbodley@redhat.com>
Fri, 12 Apr 2024 19:34:29 +0000 (15:34 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 53c4339d7d877d6cbe863a59f0d0dab096e30707)

src/rgw/driver/rados/rgw_sal_rados.cc
src/rgw/rgw_rest_role.cc

index e26c48bac52156a175b19ef62567d47906770521..92244196295c46bc17645e4ac5726ca8ead101cf 100644 (file)
@@ -4355,18 +4355,20 @@ int RadosRole::create(const DoutPrefixProvider *dpp, bool exclusive, const std::
   std::string_view account = !info.account_id.empty() ? info.account_id : info.tenant;
   info.arn = string_cat_reserve(role_arn_prefix, account, ":role", info.path, info.name);
 
-  // Creation time
-  real_clock::time_point t = real_clock::now();
-
-  struct timeval tv;
-  real_clock::to_timeval(t, tv);
-
-  char buf[30];
-  struct tm result;
-  gmtime_r(&tv.tv_sec, &result);
-  strftime(buf,30,"%Y-%m-%dT%H:%M:%S", &result);
-  sprintf(buf + strlen(buf),".%03dZ",(int)tv.tv_usec/1000);
-  info.creation_date.assign(buf, strlen(buf));
+  if (info.creation_date.empty()) {
+    // Creation time
+    real_clock::time_point t = real_clock::now();
+
+    struct timeval tv;
+    real_clock::to_timeval(t, tv);
+
+    char buf[30];
+    struct tm result;
+    gmtime_r(&tv.tv_sec, &result);
+    strftime(buf,30,"%Y-%m-%dT%H:%M:%S", &result);
+    sprintf(buf + strlen(buf),".%03dZ",(int)tv.tv_usec/1000);
+    info.creation_date.assign(buf, strlen(buf));
+  }
 
   auto& pool = store->svc()->zone->get_zone_params().roles_pool;
   ret = store_info(dpp, exclusive, y);
index d9def5cb520cc899897e95759bb33e0dc41f02af..295881ce9b9d24158e4386217802afea1b5bf6b5 100644 (file)
@@ -308,13 +308,14 @@ void RGWCreateRole::execute(optional_yield y)
     try {
       if (role_obj) {
         RGWXMLDecoder::decode_xml("RoleId", role_id, role_obj, true);
+        RGWXMLDecoder::decode_xml("CreateDate", role->get_info().creation_date, role_obj);
       }
     } catch (RGWXMLDecoder::err& err) {
       ldpp_dout(this, 5) << "ERROR: unexpected xml: RoleId" << dendl;
       op_ret = -EINVAL;
       return;
     }
-    ldpp_dout(this, 0) << "role_id decoded from master zonegroup response is" << role_id << dendl;
+    ldpp_dout(this, 0) << "role_id decoded from master zonegroup response is " << role_id << dendl;
   }
 
   op_ret = role->create(s, true, role_id, y);