rgw: code for handling mtime, object tracker and attrs

needed for RGWRoleMetadataHandler.

Signed-off-by: Pritha Srivastava <prsrivas@redhat.com>
This commit is contained in:
Pritha Srivastava 2021-10-27 11:12:12 +05:30
parent 3f574a39a4
commit a100026281
3 changed files with 17 additions and 9 deletions

View File

@ -370,9 +370,6 @@ int RGWRoleMetadataHandler::do_get(RGWSI_MetaBackend_Handler::Op *op,
const DoutPrefixProvider *dpp)
{
RGWRoleCompleteInfo rci;
RGWObjVersionTracker objv_tracker;
real_time mtime;
#if 0
int ret = svc.role->read_info(op->ctx(),
entry,
@ -389,6 +386,9 @@ int RGWRoleMetadataHandler::do_get(RGWSI_MetaBackend_Handler::Op *op,
return ret;
}
RGWObjVersionTracker objv_tracker = rci.info->get_objv_tracker();
real_time mtime = rci.info->get_mtime();
RGWRoleMetadataObject *rdo = new RGWRoleMetadataObject(rci, objv_tracker.read_version,
mtime);
*obj = rdo;
@ -440,7 +440,6 @@ public:
int put_checked(const DoutPrefixProvider *dpp) override {
auto& rci = mdo->get_rci();
auto mtime = mdo->get_mtime();
map<std::string, bufferlist> *pattrs = rci.has_attrs ? &rci.attrs : nullptr;
#if 0
int ret = rhandler->role->create(op->ctx(),
rci.info,
@ -453,6 +452,7 @@ public:
return ret < 0 ? ret : STATUS_APPLIED;
#endif
rci.info->set_mtime(mtime);
int ret = rci.info->create(dpp, true, y);
return ret < 0 ? ret : STATUS_APPLIED;
}

View File

@ -45,6 +45,9 @@ protected:
std::string tenant;
uint64_t max_session_duration;
std::multimap<std::string,std::string> tags;
std::map<std::string, bufferlist> attrs;
RGWObjVersionTracker objv_tracker;
real_time mtime;
public:
virtual int store_info(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y) = 0;
@ -75,6 +78,7 @@ public:
} else {
max_session_duration = std::stoull(max_session_duration_str);
}
mtime = real_time();
}
RGWRole(std::string id) : id(std::move(id)) {}
@ -122,11 +126,14 @@ public:
const std::string& get_create_date() const { return creation_date; }
const std::string& get_assume_role_policy() const { return trust_policy;}
const uint64_t& get_max_session_duration() const { return max_session_duration; }
const RGWObjVersionTracker& get_objv_tracker() const { return objv_tracker; }
const real_time& get_mtime() const { return mtime; }
void set_id(const std::string& id) { this->id = id; }
//TODO: Remove the following two
void set_arn(const std::string& arn) { this->arn = arn; }
void set_creation_date(const std::string& creation_date) { this->creation_date = creation_date; }
void set_mtime(const real_time& mtime) { this->mtime = mtime; }
virtual int create(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y) = 0;
virtual int delete_obj(const DoutPrefixProvider *dpp, optional_yield y) = 0;

View File

@ -3073,12 +3073,14 @@ int RadosRole::store_info(const DoutPrefixProvider *dpp, bool exclusive, optiona
if (!this->tags.empty()) {
bufferlist bl_tags;
encode(this->tags, bl_tags);
map<string, bufferlist> attrs;
attrs.emplace("tagging", bl_tags);
return rgw_put_system_obj(dpp, obj_ctx, store->svc()->zone->get_zone_params().roles_pool, oid, bl, exclusive, nullptr, real_time(), y, &attrs);
}
return rgw_put_system_obj(dpp, obj_ctx, store->svc()->zone->get_zone_params().roles_pool, oid, bl, exclusive, nullptr, real_time(), y);
if (!attrs.empty()) {
return rgw_put_system_obj(dpp, obj_ctx, store->get_zone()->get_params().roles_pool, oid, bl, exclusive, nullptr, mtime, y, &attrs);
}
return rgw_put_system_obj(dpp, obj_ctx, store->get_zone()->get_params().roles_pool, oid, bl, exclusive, nullptr, mtime, y);
}
int RadosRole::store_name(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y)
@ -3162,8 +3164,7 @@ int RadosRole::read_info(const DoutPrefixProvider *dpp, optional_yield y)
std::string oid = get_info_oid_prefix() + id;
bufferlist bl;
map<string, bufferlist> attrs;
int ret = rgw_get_system_obj(obj_ctx, store->svc()->zone->get_zone_params().roles_pool, oid, bl, nullptr, nullptr, null_yield, dpp, &attrs, nullptr, boost::none, true);
int ret = rgw_get_system_obj(obj_ctx, store->get_zone()->get_params().roles_pool, oid, bl, &objv_tracker, &mtime, null_yield, dpp, &attrs, nullptr, boost::none, true);
if (ret < 0) {
ldpp_dout(dpp, 0) << "ERROR: failed reading role info from Role pool: " << id << ": " << cpp_strerror(-ret) << dendl;
return ret;