Skip to content

Commit

Permalink
rgw: cleanup.
Browse files Browse the repository at this point in the history
Signed-off-by: Pritha Srivastava <prsrivas@redhat.com>
  • Loading branch information
pritha-srivastava committed Oct 28, 2021
1 parent ff3c15e commit 2cff0d6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 158 deletions.
112 changes: 3 additions & 109 deletions src/rgw/rgw_role.cc
Expand Up @@ -234,99 +234,23 @@ const string& RGWRole::get_path_oid_prefix()
return role_path_oid_prefix;
}

#if 0
class RGWSI_Role_Module : public RGWSI_MBSObj_Handler_Module {
RGWRoleMetadataHandler::Svc& svc;
const std::string prefix;
public:
RGWSI_Role_Module(RGWRoleMetadataHandler::Svc& _svc): RGWSI_MBSObj_Handler_Module("roles"),
svc(_svc),
prefix(rgw::sal::RGWRole::get_info_oid_prefix()) {}

void get_pool_and_oid(const std::string& key,
rgw_pool *pool,
std::string *oid) override
{
if (pool) {
*pool = svc.zone->get_zone_params().roles_pool;
}

if (oid) {
*oid = key_to_oid(key);
}
}

bool is_valid_oid(const std::string& oid) override {
return boost::algorithm::starts_with(oid, prefix);
}

std::string key_to_oid(const std::string& key) override {
return prefix + key;
}

// This is called after `is_valid_oid` and is assumed to be a valid oid
std::string oid_to_key(const std::string& oid) override {
return oid.substr(prefix.size());
}

const std::string& get_oid_prefix() {
return prefix;
}
};

RGWSI_MetaBackend_Handler* RGWRoleMetadataHandler::get_be_handler()
RGWRoleMetadataHandler::RGWRoleMetadataHandler(Store* store)
{
return be_handler;
}

void RGWRoleMetadataHandler::init(RGWSI_Zone *_zone_svc,
RGWSI_Meta *_meta_svc,
RGWSI_MetaBackend *_meta_be_svc,
RGWSI_SysObj *_sysobj_svc)
{
svc.zone = _zone_svc;
svc.meta = _meta_svc;
svc.meta_be = _meta_be_svc;
svc.sysobj = _sysobj_svc;
}

int RGWRoleMetadataHandler::do_start(optional_yield y, const DoutPrefixProvider *dpp)
{

int r = svc.meta->create_be_handler(RGWSI_MetaBackend::Type::MDBE_SOBJ,
&be_handler);
if (r < 0) {
//ldout(ctx(), 0) << "ERROR: failed to create be_handler for Roles: r="
// << r <<dendl;
return r;
}

auto module = new RGWSI_Role_Module(svc);
RGWSI_MetaBackend_Handler_SObj* bh= static_cast<RGWSI_MetaBackend_Handler_SObj *>(be_handler);
be_module.reset(module);
bh->set_module(module);
return 0;
}
#endif

RGWRoleMetadataHandler::RGWRoleMetadataHandler(CephContext *cct, Store* store)
{
//base_init(cct, get_be_handler());
store = store;
}

void RGWRoleCompleteInfo::dump(ceph::Formatter *f) const
{
info->dump(f);
if (has_attrs) {
encode_json("attrs", attrs, f);
encode_json("attrs", info->get_attrs(), f);
}
}

void RGWRoleCompleteInfo::decode_json(JSONObj *obj)
{
decode_json_obj(*info, obj);
has_attrs = JSONDecoder::decode_json("attrs", attrs, obj);
has_attrs = JSONDecoder::decode_json("attrs", info->get_attrs(), obj);
}


Expand All @@ -352,16 +276,6 @@ int RGWRoleMetadataHandler::do_get(RGWSI_MetaBackend_Handler::Op *op,
const DoutPrefixProvider *dpp)
{
RGWRoleCompleteInfo rci;
#if 0
int ret = svc.role->read_info(op->ctx(),
entry,
&rci.info,
&objv_tracker,
&mtime,
&rci.attrs,
y,
dpp);
#endif
rci.info = store->get_role(entry).get();
int ret = rci.info->read_info(dpp, y);
if (ret < 0) {
Expand All @@ -384,14 +298,6 @@ int RGWRoleMetadataHandler::do_remove(RGWSI_MetaBackend_Handler::Op *op,
optional_yield y,
const DoutPrefixProvider *dpp)
{
#if 0
int ret = svc.role->read_info(op->ctx(), entry, &info, &objv_tracker,
&_mtime, nullptr, y, dpp);
if (ret < 0) {
return ret == -ENOENT ? 0 : ret;
}
return svc.role->delete_role(op->ctx(), info, &objv_tracker, y, dpp);
#endif
std::unique_ptr<rgw::sal::RGWRole> role = store->get_role(entry);
int ret = role->read_info(dpp, y);
if (ret < 0) {
Expand Down Expand Up @@ -422,18 +328,6 @@ class RGWMetadataHandlerPut_Role : public RGWMetadataHandlerPut_SObj
int put_checked(const DoutPrefixProvider *dpp) override {
auto& rci = mdo->get_rci();
auto mtime = mdo->get_mtime();
#if 0
int ret = rhandler->role->create(op->ctx(),
rci.info,
&objv_tracker,
mtime,
false,
pattrs,
y,
dpp);

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;
Expand Down
33 changes: 2 additions & 31 deletions src/rgw/rgw_role.h
Expand Up @@ -13,11 +13,7 @@
#include "rgw/rgw_rados.h"
#include "rgw_metadata.h"

class RGWCtl;
class RGWRados;
class RGWSI_Role;
class RGWSI_MetaBackend_Handler;
class RGWRoleCtl;

namespace rgw { namespace sal {
class RGWRole
Expand All @@ -33,8 +29,6 @@ class RGWRole
static constexpr uint64_t SESSION_DURATION_MAX = 43200; // in seconds
protected:

RGWRoleCtl *role_ctl;

std::string id;
std::string name;
std::string path;
Expand Down Expand Up @@ -128,11 +122,9 @@ class RGWRole
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; }
std::map<std::string, bufferlist>& get_attrs() { return attrs; }

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;
Expand All @@ -159,7 +151,6 @@ WRITE_CLASS_ENCODER(RGWRole)

struct RGWRoleCompleteInfo {
RGWRole* info;
std::map<std::string, bufferlist> attrs;
bool has_attrs;

void dump(Formatter *f) const;
Expand All @@ -186,25 +177,7 @@ class RGWRoleMetadataObject: public RGWMetadataObject {
class RGWRoleMetadataHandler: public RGWMetadataHandler_GenericMetaBE
{
public:
#if 0
struct Svc {
RGWSI_Zone *zone{nullptr};
RGWSI_Meta *meta{nullptr};
RGWSI_MetaBackend *meta_be{nullptr};
RGWSI_SysObj *sysobj{nullptr};
} svc;

void init(RGWSI_Zone *_zone_svc,
RGWSI_Meta *_meta_svc,
RGWSI_MetaBackend *_meta_be_svc,
RGWSI_SysObj *_sysobj_svc);

RGWSI_MetaBackend_Handler * get_be_handler();

int do_start(optional_yield y, const DoutPrefixProvider *dpp);
#endif

RGWRoleMetadataHandler(CephContext *cct, Store* store);
RGWRoleMetadataHandler(Store* store);

std::string get_type() final { return "roles"; }

Expand Down Expand Up @@ -234,8 +207,6 @@ class RGWRoleMetadataHandler: public RGWMetadataHandler_GenericMetaBE
bool from_remote_zone) override;

private:
RGWSI_MetaBackend_Handler *be_handler;
std::unique_ptr<RGWSI_MetaBackend::Module> be_module;
std::unique_ptr<Store> store;
};
} } // namespace rgw::sal
Expand Down
12 changes: 1 addition & 11 deletions src/rgw/rgw_service.cc
Expand Up @@ -77,7 +77,6 @@ int RGWServices_Def::init(CephContext *cct,
sysobj = std::make_unique<RGWSI_SysObj>(cct);
sysobj_core = std::make_unique<RGWSI_SysObj_Core>(cct);
user_rados = std::make_unique<RGWSI_User_RADOS>(cct);
//role_rados = std::make_unique<rgw::sal::RadosRole>(store);

if (have_cache) {
sysobj_cache = std::make_unique<RGWSI_SysObj_Cache>(dpp, cct);
Expand Down Expand Up @@ -117,7 +116,6 @@ int RGWServices_Def::init(CephContext *cct,
}
user_rados->init(rados.get(), zone.get(), sysobj.get(), sysobj_cache.get(),
meta.get(), meta_be_sobj.get(), sync_modules.get());
//role_rados->init(zone.get(), meta.get(), meta_be_sobj.get(), sysobj.get());

can_shutdown = true;

Expand Down Expand Up @@ -250,11 +248,6 @@ int RGWServices_Def::init(CephContext *cct,
return r;
}

//r = role_rados->start(y, dpp);
if (r < 0) {
ldout(cct, 0) << "ERROR: failed to start role_rados service (" << cpp_strerror(-r) << dendl;
return r;
}
}

/* cache or core services will be started by sysobj */
Expand Down Expand Up @@ -324,7 +317,6 @@ int RGWServices::do_init(CephContext *_cct, bool have_cache, bool raw, bool run_
cache = _svc.sysobj_cache.get();
core = _svc.sysobj_core.get();
user = _svc.user_rados.get();
//role = _svc.role_rados.get();

return 0;
}
Expand Down Expand Up @@ -372,15 +364,14 @@ int RGWCtlDef::init(RGWServices& svc, rgw::sal::Store* store, const DoutPrefixPr
}

meta.otp.reset(RGWOTPMetaHandlerAllocator::alloc());
meta.role = std::make_unique<rgw::sal::RGWRoleMetadataHandler>(svc.cct, store);
meta.role = std::make_unique<rgw::sal::RGWRoleMetadataHandler>(store);

user.reset(new RGWUserCtl(svc.zone, svc.user, (RGWUserMetadataHandler *)meta.user.get()));
bucket.reset(new RGWBucketCtl(svc.zone,
svc.bucket,
svc.bucket_sync,
svc.bi));
otp.reset(new RGWOTPCtl(svc.zone, svc.otp));
//role = std::make_unique<RGWRoleCtl>(svc.role, static_cast<RGWRoleMetadataHandler*>(meta.role.get()));

RGWBucketMetadataHandlerBase *bucket_meta_handler = static_cast<RGWBucketMetadataHandlerBase *>(meta.bucket.get());
RGWBucketInstanceMetadataHandlerBase *bi_meta_handler = static_cast<RGWBucketInstanceMetadataHandlerBase *>(meta.bucket_instance.get());
Expand Down Expand Up @@ -424,7 +415,6 @@ int RGWCtl::init(RGWServices *_svc, rgw::sal::Store* store, const DoutPrefixProv
user = _ctl.user.get();
bucket = _ctl.bucket.get();
otp = _ctl.otp.get();
//role = _ctl.role.get();

r = meta.user->attach(meta.mgr);
if (r < 0) {
Expand Down
7 changes: 0 additions & 7 deletions src/rgw/rgw_service.h
Expand Up @@ -12,7 +12,6 @@
#include "common/async/yield_context.h"

#include "rgw/rgw_common.h"
//#include "rgw/rgw_sal_rados.h"

struct RGWServices_Def;

Expand Down Expand Up @@ -66,8 +65,6 @@ class RGWSI_MetaBackend_OTP;
class RGWSI_Notify;
class RGWSI_OTP;
class RGWSI_RADOS;
//class RGWSI_Role;
//class RGWSI_Role_RADOS;
class RGWSI_Zone;
class RGWSI_ZoneUtils;
class RGWSI_Quota;
Expand Down Expand Up @@ -108,7 +105,6 @@ struct RGWServices_Def
std::unique_ptr<RGWSI_SysObj_Cache> sysobj_cache;
std::unique_ptr<RGWSI_User_RADOS> user_rados;
std::unique_ptr<RGWDataChangesLog> datalog_rados;
//std::unique_ptr<rgw::sal::RadosRole> role_rados;

RGWServices_Def();
~RGWServices_Def();
Expand Down Expand Up @@ -172,7 +168,6 @@ class RGWMetadataHandler;
class RGWUserCtl;
class RGWBucketCtl;
class RGWOTPCtl;
//class RGWRoleCtl;

struct RGWCtlDef {
struct _meta {
Expand All @@ -190,7 +185,6 @@ struct RGWCtlDef {
std::unique_ptr<RGWUserCtl> user;
std::unique_ptr<RGWBucketCtl> bucket;
std::unique_ptr<RGWOTPCtl> otp;
//std::unique_ptr<RGWRoleCtl> role;

RGWCtlDef();
~RGWCtlDef();
Expand All @@ -217,7 +211,6 @@ struct RGWCtl {
RGWUserCtl *user{nullptr};
RGWBucketCtl *bucket{nullptr};
RGWOTPCtl *otp{nullptr};
//RGWRoleCtl *role{nullptr};

int init(RGWServices *_svc, rgw::sal::Store* store, const DoutPrefixProvider *dpp);
};
Expand Down

0 comments on commit 2cff0d6

Please sign in to comment.