From: Casey Bodley Date: Thu, 15 Feb 2024 23:53:16 +0000 (-0500) Subject: rgw/role: use CreateDate from forwarded CreateRole response X-Git-Tag: testing/wip-pdonnell-testing-20240416.232051-debug~25^2~63 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=53c4339d7d877d6cbe863a59f0d0dab096e30707;p=ceph-ci.git rgw/role: use CreateDate from forwarded CreateRole response Signed-off-by: Casey Bodley --- diff --git a/src/rgw/driver/rados/rgw_sal_rados.cc b/src/rgw/driver/rados/rgw_sal_rados.cc index e26c48bac52..92244196295 100644 --- a/src/rgw/driver/rados/rgw_sal_rados.cc +++ b/src/rgw/driver/rados/rgw_sal_rados.cc @@ -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); diff --git a/src/rgw/rgw_rest_role.cc b/src/rgw/rgw_rest_role.cc index d9def5cb520..295881ce9b9 100644 --- a/src/rgw/rgw_rest_role.cc +++ b/src/rgw/rgw_rest_role.cc @@ -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);