return -EINVAL;
}
RGWRole role(g_ceph_context, store->getRados()->pctl, role_name, path, assume_role_doc, tenant);
- ret = role.create(true);
+ ret = role.create(true, null_yield);
if (ret < 0) {
return -ret;
}
return -EINVAL;
}
RGWRole role(g_ceph_context, store->getRados()->pctl, role_name, tenant);
- ret = role.delete_obj();
+ ret = role.delete_obj(null_yield);
if (ret < 0) {
return -ret;
}
return -ret;
}
role.update_trust_policy(assume_role_doc);
- ret = role.update();
+ ret = role.update(null_yield);
if (ret < 0) {
return -ret;
}
return -ret;
}
role.set_perm_policy(policy_name, perm_policy_doc);
- ret = role.update();
+ ret = role.update(null_yield);
if (ret < 0) {
return -ret;
}
if (ret < 0) {
return -ret;
}
- ret = role.update();
+ ret = role.update(null_yield);
if (ret < 0) {
return -ret;
}
RGWDataAccess::BucketRef b;
RGWDataAccess::ObjectRef obj;
- int ret = data_access.get_bucket(tenant, bucket_name, bucket_id, &b);
+ int ret = data_access.get_bucket(tenant, bucket_name, bucket_id, &b, null_yield);
if (ret < 0) {
cerr << "ERROR: failed to init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
RGWUserInfo& user_info = user_op.get_user_info();
RGWUserPubSub ups(store, user_info.user_id);
- ret = ups.remove_topic(topic_name);
+ ret = ups.remove_topic(topic_name, null_yield);
if (ret < 0) {
cerr << "ERROR: could not remove topic: " << cpp_strerror(-ret) << std::endl;
return -ret;
RGWUserPubSub ups(store, user_info.user_id);
auto sub = ups.get_sub(sub_name);
- ret = sub->unsubscribe(topic_name);
+ ret = sub->unsubscribe(topic_name, null_yield);
if (ret < 0) {
cerr << "ERROR: could not get subscription info: " << cpp_strerror(-ret) << std::endl;
return -ret;
ceph::encode(script, bl);
const auto rc = rgw_put_system_obj(
- obj_ctx,
- obj.pool,
+ obj_ctx,
+ obj.pool,
obj.oid,
bl,
- false,
+ false,
&objv_tracker,
- real_time());
+ real_time(),
+ y);
if (rc < 0) {
return rc;
const auto rc = rgw_delete_system_obj(
store->svc()->sysobj,
- obj.pool,
+ obj.pool,
obj.oid,
- &objv_tracker);
+ &objv_tracker,
+ y);
if (rc < 0 && rc != -ENOENT) {
return rc;
const string RGWOIDCProvider::oidc_url_oid_prefix = "oidc_url.";
const string RGWOIDCProvider::oidc_arn_prefix = "arn:aws:iam::";
-int RGWOIDCProvider::store_url(const string& url, bool exclusive)
+int RGWOIDCProvider::store_url(const string& url, bool exclusive,
+ optional_yield y)
{
using ceph::encode;
string oid = tenant + get_url_oid_prefix() + url;
encode(*this, bl);
auto obj_ctx = svc->sysobj->init_obj_ctx();
return rgw_put_system_obj(obj_ctx, svc->zone->get_zone_params().oidc_pool, oid,
- bl, exclusive, NULL, real_time(), NULL);
+ bl, exclusive, NULL, real_time(), y);
}
int RGWOIDCProvider::get_tenant_url_from_arn(string& tenant, string& url)
return 0;
}
-int RGWOIDCProvider::create(bool exclusive)
+int RGWOIDCProvider::create(bool exclusive, optional_yield y)
{
int ret;
auto svc = ctl->svc;
auto& pool = svc->zone->get_zone_params().oidc_pool;
- ret = store_url(idp_url, exclusive);
+ ret = store_url(idp_url, exclusive, y);
if (ret < 0) {
ldout(cct, 0) << "ERROR: storing role info in pool: " << pool.name << ": "
<< provider_url << ": " << cpp_strerror(-ret) << dendl;
return 0;
}
-int RGWOIDCProvider::delete_obj()
+int RGWOIDCProvider::delete_obj(optional_yield y)
{
auto svc = ctl->svc;
auto& pool = svc->zone->get_zone_params().oidc_pool;
// Delete url
string oid = tenant + get_url_oid_prefix() + url;
- ret = rgw_delete_system_obj(svc->sysobj, pool, oid, NULL);
+ ret = rgw_delete_system_obj(svc->sysobj, pool, oid, NULL, y);
if (ret < 0) {
ldout(cct, 0) << "ERROR: deleting oidc url from pool: " << pool.name << ": "
<< provider_url << ": " << cpp_strerror(-ret) << dendl;
#include <string>
#include "common/ceph_context.h"
+#include "common/ceph_json.h"
+
+#include "rgw/rgw_rados.h"
class RGWCtl;
vector<string> thumbprints;
int get_tenant_url_from_arn(string& tenant, string& url);
- int store_url(const string& url, bool exclusive);
+ int store_url(const string& url, bool exclusive, optional_yield y);
int read_url(const string& url, const string& tenant);
bool validate_input();
const vector<string>& get_client_ids() const { return client_ids;}
const vector<string>& get_thumbprints() const { return thumbprints; }
- int create(bool exclusive);
- int delete_obj();
+ int create(bool exclusive, optional_yield y);
+ int delete_obj(optional_yield y);
int get();
void dump(Formatter *f) const;
void dump_all(Formatter *f) const;
get_user_meta_obj(&user_meta_obj);
}
-int RGWUserPubSub::remove(const rgw_raw_obj& obj, RGWObjVersionTracker *objv_tracker)
+int RGWUserPubSub::remove(const rgw_raw_obj& obj,
+ RGWObjVersionTracker *objv_tracker,
+ optional_yield y)
{
- int ret = rgw_delete_system_obj(store->svc()->sysobj, obj.pool, obj.oid, objv_tracker);
+ int ret = rgw_delete_system_obj(store->svc()->sysobj, obj.pool, obj.oid, objv_tracker, y);
if (ret < 0) {
return ret;
}
return 0;
}
-int RGWUserPubSub::write_user_topics(const rgw_pubsub_user_topics& topics, RGWObjVersionTracker *objv_tracker)
+int RGWUserPubSub::write_user_topics(const rgw_pubsub_user_topics& topics,
+ RGWObjVersionTracker *objv_tracker, optional_yield y)
{
- int ret = write(user_meta_obj, topics, objv_tracker);
+ int ret = write(user_meta_obj, topics, objv_tracker, y);
if (ret < 0 && ret != -ENOENT) {
ldout(store->ctx(), 1) << "ERROR: failed to write topics info: ret=" << ret << dendl;
return ret;
return 0;
}
-int RGWUserPubSub::Bucket::write_topics(const rgw_pubsub_bucket_topics& topics, RGWObjVersionTracker *objv_tracker)
+int RGWUserPubSub::Bucket::write_topics(const rgw_pubsub_bucket_topics& topics,
+ RGWObjVersionTracker *objv_tracker,
+ optional_yield y)
{
- int ret = ps->write(bucket_meta_obj, topics, objv_tracker);
+ int ret = ps->write(bucket_meta_obj, topics, objv_tracker, y);
if (ret < 0) {
ldout(ps->store->ctx(), 1) << "ERROR: failed to write bucket topics info: ret=" << ret << dendl;
return ret;
return 0;
}
-int RGWUserPubSub::Bucket::create_notification(const string& topic_name, const rgw::notify::EventTypeList& events) {
- return create_notification(topic_name, events, std::nullopt, "");
+int RGWUserPubSub::Bucket::create_notification(const string& topic_name, const rgw::notify::EventTypeList& events, optional_yield y) {
+ return create_notification(topic_name, events, std::nullopt, "", y);
}
-int RGWUserPubSub::Bucket::create_notification(const string& topic_name, const rgw::notify::EventTypeList& events, OptionalFilter s3_filter, const std::string& notif_name) {
+int RGWUserPubSub::Bucket::create_notification(const string& topic_name,const rgw::notify::EventTypeList& events, OptionalFilter s3_filter, const std::string& notif_name, optional_yield y) {
rgw_pubsub_topic_subs user_topic_info;
rgw::sal::RGWRadosStore *store = ps->store;
topic_filter.s3_filter = *s3_filter;
}
- ret = write_topics(bucket_topics, &objv_tracker);
+ ret = write_topics(bucket_topics, &objv_tracker, y);
if (ret < 0) {
ldout(store->ctx(), 1) << "ERROR: failed to write topics to bucket '" << bucket.name << "': ret=" << ret << dendl;
return ret;
return 0;
}
-int RGWUserPubSub::Bucket::remove_notification(const string& topic_name)
+int RGWUserPubSub::Bucket::remove_notification(const string& topic_name, optional_yield y)
{
rgw_pubsub_topic_subs user_topic_info;
rgw::sal::RGWRadosStore *store = ps->store;
bucket_topics.topics.erase(topic_name);
- ret = write_topics(bucket_topics, &objv_tracker);
+ ret = write_topics(bucket_topics, &objv_tracker, y);
if (ret < 0) {
ldout(store->ctx(), 1) << "ERROR: failed to write topics info: ret=" << ret << dendl;
return ret;
return 0;
}
-int RGWUserPubSub::create_topic(const string& name) {
- return create_topic(name, rgw_pubsub_sub_dest(), "", "");
+int RGWUserPubSub::create_topic(const string& name, optional_yield y) {
+ return create_topic(name, rgw_pubsub_sub_dest(), "", "", y);
}
-int RGWUserPubSub::create_topic(const string& name, const rgw_pubsub_sub_dest& dest, const std::string& arn, const std::string& opaque_data) {
+int RGWUserPubSub::create_topic(const string& name, const rgw_pubsub_sub_dest& dest, const std::string& arn, const std::string& opaque_data, optional_yield y) {
RGWObjVersionTracker objv_tracker;
rgw_pubsub_user_topics topics;
new_topic.topic.arn = arn;
new_topic.topic.opaque_data = opaque_data;
- ret = write_user_topics(topics, &objv_tracker);
+ ret = write_user_topics(topics, &objv_tracker, y);
if (ret < 0) {
ldout(store->ctx(), 1) << "ERROR: failed to write topics info: ret=" << ret << dendl;
return ret;
return 0;
}
-int RGWUserPubSub::remove_topic(const string& name)
+int RGWUserPubSub::remove_topic(const string& name, optional_yield y)
{
RGWObjVersionTracker objv_tracker;
rgw_pubsub_user_topics topics;
topics.topics.erase(name);
- ret = write_user_topics(topics, &objv_tracker);
+ ret = write_user_topics(topics, &objv_tracker, y);
if (ret < 0) {
ldout(store->ctx(), 1) << "ERROR: failed to remove topics info: ret=" << ret << dendl;
return ret;
return 0;
}
-int RGWUserPubSub::Sub::write_sub(const rgw_pubsub_sub_config& sub_conf, RGWObjVersionTracker *objv_tracker)
+int RGWUserPubSub::Sub::write_sub(const rgw_pubsub_sub_config& sub_conf,
+ RGWObjVersionTracker *objv_tracker,
+ optional_yield y)
{
- int ret = ps->write(sub_meta_obj, sub_conf, objv_tracker);
+ int ret = ps->write(sub_meta_obj, sub_conf, objv_tracker, y);
if (ret < 0) {
ldout(ps->store->ctx(), 1) << "ERROR: failed to write subscription info: ret=" << ret << dendl;
return ret;
return 0;
}
-int RGWUserPubSub::Sub::remove_sub(RGWObjVersionTracker *objv_tracker)
+int RGWUserPubSub::Sub::remove_sub(RGWObjVersionTracker *objv_tracker,
+ optional_yield y)
{
- int ret = ps->remove(sub_meta_obj, objv_tracker);
+ int ret = ps->remove(sub_meta_obj, objv_tracker, y);
if (ret < 0) {
ldout(ps->store->ctx(), 1) << "ERROR: failed to remove subscription info: ret=" << ret << dendl;
return ret;
return read_sub(result, nullptr);
}
-int RGWUserPubSub::Sub::subscribe(const string& topic, const rgw_pubsub_sub_dest& dest, const std::string& s3_id)
+int RGWUserPubSub::Sub::subscribe(const string& topic, const rgw_pubsub_sub_dest& dest, optional_yield y, const std::string& s3_id)
{
RGWObjVersionTracker user_objv_tracker;
rgw_pubsub_user_topics topics;
t.subs.insert(sub);
- ret = ps->write_user_topics(topics, &user_objv_tracker);
+ ret = ps->write_user_topics(topics, &user_objv_tracker, y);
if (ret < 0) {
ldout(store->ctx(), 1) << "ERROR: failed to write topics info: ret=" << ret << dendl;
return ret;
}
- ret = write_sub(sub_conf, nullptr);
+ ret = write_sub(sub_conf, nullptr, y);
if (ret < 0) {
ldout(store->ctx(), 1) << "ERROR: failed to write subscription info: ret=" << ret << dendl;
return ret;
return 0;
}
-int RGWUserPubSub::Sub::unsubscribe(const string& _topic)
+int RGWUserPubSub::Sub::unsubscribe(const string& _topic, optional_yield y)
{
string topic = _topic;
RGWObjVersionTracker sobjv_tracker;
t.subs.erase(sub);
- ret = ps->write_user_topics(topics, &objv_tracker);
+ ret = ps->write_user_topics(topics, &objv_tracker, y);
if (ret < 0) {
ldout(store->ctx(), 1) << "ERROR: failed to write topics info: ret=" << ret << dendl;
return ret;
}
}
- ret = remove_sub(&sobjv_tracker);
+ ret = remove_sub(&sobjv_tracker, y);
if (ret < 0) {
ldout(store->ctx(), 1) << "ERROR: failed to delete subscription info: ret=" << ret << dendl;
return ret;
int read(const rgw_raw_obj& obj, T *data, RGWObjVersionTracker *objv_tracker);
template <class T>
- int write(const rgw_raw_obj& obj, const T& info, RGWObjVersionTracker *obj_tracker);
+ int write(const rgw_raw_obj& obj, const T& info,
+ RGWObjVersionTracker *obj_tracker, optional_yield y);
- int remove(const rgw_raw_obj& obj, RGWObjVersionTracker *objv_tracker);
+ int remove(const rgw_raw_obj& obj, RGWObjVersionTracker *objv_tracker,
+ optional_yield y);
int read_user_topics(rgw_pubsub_user_topics *result, RGWObjVersionTracker *objv_tracker);
- int write_user_topics(const rgw_pubsub_user_topics& topics, RGWObjVersionTracker *objv_tracker);
+ int write_user_topics(const rgw_pubsub_user_topics& topics,
+ RGWObjVersionTracker *objv_tracker, optional_yield y);
public:
RGWUserPubSub(rgw::sal::RGWRadosStore *_store, const rgw_user& _user);
// set the list of topics associated with a bucket
// use version tacker to enforce atomicity between read/write
// return 0 on success, error code otherwise
- int write_topics(const rgw_pubsub_bucket_topics& topics, RGWObjVersionTracker *objv_tracker);
+ int write_topics(const rgw_pubsub_bucket_topics& topics,
+ RGWObjVersionTracker *objv_tracker, optional_yield y);
public:
Bucket(RGWUserPubSub *_ps, const rgw_bucket& _bucket) : ps(_ps), bucket(_bucket) {
ps->get_bucket_meta_obj(bucket, &bucket_meta_obj);
// for S3 compliant notifications the version with: s3_filter and notif_name should be used
// return -ENOENT if the topic does not exists
// return 0 on success, error code otherwise
- int create_notification(const string& topic_name, const rgw::notify::EventTypeList& events);
- int create_notification(const string& topic_name, const rgw::notify::EventTypeList& events, OptionalFilter s3_filter, const std::string& notif_name);
+ int create_notification(const string& topic_name, const rgw::notify::EventTypeList& events, optional_yield y);
+ int create_notification(const string& topic_name, const rgw::notify::EventTypeList& events, OptionalFilter s3_filter, const std::string& notif_name, optional_yield y);
// remove a topic and filter from bucket
// if the topic does not exists on the bucket it is a no-op (considered success)
// return -ENOENT if the topic does not exists
// return 0 on success, error code otherwise
- int remove_notification(const string& topic_name);
+ int remove_notification(const string& topic_name, optional_yield y);
};
// base class for subscription
rgw_raw_obj sub_meta_obj;
int read_sub(rgw_pubsub_sub_config *result, RGWObjVersionTracker *objv_tracker);
- int write_sub(const rgw_pubsub_sub_config& sub_conf, RGWObjVersionTracker *objv_tracker);
- int remove_sub(RGWObjVersionTracker *objv_tracker);
+ int write_sub(const rgw_pubsub_sub_config& sub_conf,
+ RGWObjVersionTracker *objv_tracker, optional_yield y);
+ int remove_sub(RGWObjVersionTracker *objv_tracker, optional_yield y);
public:
Sub(RGWUserPubSub *_ps, const std::string& _sub) : ps(_ps), sub(_sub) {
ps->get_sub_meta_obj(sub, &sub_meta_obj);
virtual ~Sub() = default;
- int subscribe(const string& topic_name, const rgw_pubsub_sub_dest& dest, const std::string& s3_id="");
- int unsubscribe(const string& topic_name);
+ int subscribe(const string& topic_name, const rgw_pubsub_sub_dest& dest, optional_yield y,
+ const std::string& s3_id="");
+ int unsubscribe(const string& topic_name, optional_yield y);
int get_conf(rgw_pubsub_sub_config* result);
static const int DEFAULT_MAX_EVENTS = 100;
// create a topic with a name only
// if the topic already exists it is a no-op (considered success)
// return 0 on success, error code otherwise
- int create_topic(const string& name);
+ int create_topic(const string& name, optional_yield y);
// create a topic with push destination information and ARN
// if the topic already exists the destination and ARN values may be updated (considered succsess)
// return 0 on success, error code otherwise
- int create_topic(const string& name, const rgw_pubsub_sub_dest& dest, const std::string& arn, const std::string& opaque_data);
+ int create_topic(const string& name, const rgw_pubsub_sub_dest& dest, const std::string& arn, const std::string& opaque_data, optional_yield y);
// remove a topic according to its name
// if the topic does not exists it is a no-op (considered success)
// return 0 on success, error code otherwise
- int remove_topic(const string& name);
+ int remove_topic(const string& name, optional_yield y);
};
}
template <class T>
-int RGWUserPubSub::write(const rgw_raw_obj& obj, const T& info, RGWObjVersionTracker *objv_tracker)
+int RGWUserPubSub::write(const rgw_raw_obj& obj, const T& info,
+ RGWObjVersionTracker *objv_tracker, optional_yield y)
{
bufferlist bl;
encode(info, bl);
int ret = rgw_put_system_obj(obj_ctx, obj.pool, obj.oid,
- bl, false, objv_tracker,
- real_time());
+ bl, false, objv_tracker,
+ real_time(), y);
if (ret < 0) {
return ret;
}
RGWOIDCProvider provider(s->cct, store->getRados()->pctl, provider_url,
s->user->get_tenant(), client_ids, thumbprints);
- op_ret = provider.create(true);
+ op_ret = provider.create(true, y);
if (op_ret == 0) {
s->formatter->open_object_section("CreateOpenIDConnectProviderResponse");
void RGWDeleteOIDCProvider::execute(optional_yield y)
{
RGWOIDCProvider provider(s->cct, store->getRados()->pctl, provider_arn, s->user->get_tenant());
- op_ret = provider.delete_obj();
-
+ op_ret = provider.delete_obj(y);
+
if (op_ret < 0 && op_ret != -ENOENT && op_ret != -EINVAL) {
op_ret = ERR_INTERNAL_ERROR;
}
// generate the internal topic. destination is stored here for the "push-only" case
// when no subscription exists
// ARN is cached to make the "GET" method faster
- op_ret = ups->create_topic(unique_topic_name, topic_info.dest, topic_info.arn, topic_info.opaque_data);
+ op_ret = ups->create_topic(unique_topic_name, topic_info.dest, topic_info.arn, topic_info.opaque_data, y);
if (op_ret < 0) {
ldout(s->cct, 1) << "failed to auto-generate unique topic '" << unique_topic_name <<
"', ret=" << op_ret << dendl;
ldout(s->cct, 20) << "successfully auto-generated unique topic '" << unique_topic_name << "'" << dendl;
// generate the notification
rgw::notify::EventTypeList events;
- op_ret = b->create_notification(unique_topic_name, c.events, std::make_optional(c.filter), notif_name);
+ op_ret = b->create_notification(unique_topic_name, c.events, std::make_optional(c.filter), notif_name, y);
if (op_ret < 0) {
ldout(s->cct, 1) << "failed to auto-generate notification for unique topic '" << unique_topic_name <<
"', ret=" << op_ret << dendl;
// rollback generated topic (ignore return value)
- ups->remove_topic(unique_topic_name);
+ ups->remove_topic(unique_topic_name, y);
return;
}
ldout(s->cct, 20) << "successfully auto-generated notification for unique topic '" << unique_topic_name << "'" << dendl;
dest.bucket_name = data_bucket_prefix + s->owner.get_id().to_str() + "-" + unique_topic_name;
dest.oid_prefix = data_oid_prefix + notif_name + "/";
auto sub = ups->get_sub(notif_name);
- op_ret = sub->subscribe(unique_topic_name, dest, notif_name);
+ op_ret = sub->subscribe(unique_topic_name, dest, y, notif_name);
if (op_ret < 0) {
ldout(s->cct, 1) << "failed to auto-generate subscription '" << notif_name << "', ret=" << op_ret << dendl;
// rollback generated notification (ignore return value)
- b->remove_notification(unique_topic_name);
+ b->remove_notification(unique_topic_name, y);
// rollback generated topic (ignore return value)
- ups->remove_topic(unique_topic_name);
+ ups->remove_topic(unique_topic_name, y);
return;
}
ldout(s->cct, 20) << "successfully auto-generated subscription '" << notif_name << "'" << dendl;
return 0;
}
- void remove_notification_by_topic(const std::string& topic_name, const RGWUserPubSub::BucketRef& b) {
- op_ret = b->remove_notification(topic_name);
+ void remove_notification_by_topic(const std::string& topic_name, const RGWUserPubSub::BucketRef& b, optional_yield y) {
+ op_ret = b->remove_notification(topic_name, y);
if (op_ret < 0) {
ldout(s->cct, 1) << "failed to remove notification of topic '" << topic_name << "', ret=" << op_ret << dendl;
}
- op_ret = ups->remove_topic(topic_name);
+ op_ret = ups->remove_topic(topic_name, y);
if (op_ret < 0) {
ldout(s->cct, 1) << "failed to remove auto-generated topic '" << topic_name << "', ret=" << op_ret << dendl;
}
// remove the auto generated subscription according to notification name (if exist)
const auto unique_topic_name = unique_topic->get().topic.name;
auto sub = ups->get_sub(notif_name);
- op_ret = sub->unsubscribe(unique_topic_name);
+ op_ret = sub->unsubscribe(unique_topic_name, y);
if (op_ret < 0 && op_ret != -ENOENT) {
ldout(s->cct, 1) << "failed to remove auto-generated subscription '" << notif_name << "', ret=" << op_ret << dendl;
return;
}
- remove_notification_by_topic(unique_topic_name, b);
+ remove_notification_by_topic(unique_topic_name, b, y);
return;
}
// notification to be removed is not found - considered success
if (!sub_conf.s3_id.empty()) {
// S3 notification, has autogenerated subscription
const auto& sub_topic_name = sub_conf.topic;
- op_ret = sub->unsubscribe(sub_topic_name);
+ op_ret = sub->unsubscribe(sub_topic_name, y);
if (op_ret < 0) {
ldout(s->cct, 1) << "failed to remove auto-generated subscription '" << topic_sub_name << "', ret=" << op_ret << dendl;
return;
}
}
}
- remove_notification_by_topic(topic.first, b);
+ remove_notification_by_topic(topic.first, b, y);
}
}
}
return false;
}
+
void RGWPSCreateTopicOp::execute(optional_yield y) {
op_ret = get_params();
if (op_ret < 0) {
}
ups.emplace(store, s->owner.get_id());
- op_ret = ups->create_topic(topic_name, dest, topic_arn, opaque_data);
+ op_ret = ups->create_topic(topic_name, dest, topic_arn, opaque_data, y);
if (op_ret < 0) {
ldout(s->cct, 1) << "failed to create topic '" << topic_name << "', ret=" << op_ret << dendl;
return;
return;
}
ups.emplace(store, s->owner.get_id());
- op_ret = ups->remove_topic(topic_name);
+ op_ret = ups->remove_topic(topic_name, y);
if (op_ret < 0) {
ldout(s->cct, 1) << "failed to remove topic '" << topic_name << ", ret=" << op_ret << dendl;
return;
}
ups.emplace(store, s->owner.get_id());
auto sub = ups->get_sub(sub_name);
- op_ret = sub->subscribe(topic_name, dest);
+ op_ret = sub->subscribe(topic_name, dest, y);
if (op_ret < 0) {
ldout(s->cct, 1) << "failed to create subscription '" << sub_name << "', ret=" << op_ret << dendl;
return;
}
ups.emplace(store, s->owner.get_id());
auto sub = ups->get_sub(sub_name);
- op_ret = sub->unsubscribe(topic_name);
+ op_ret = sub->unsubscribe(topic_name, y);
if (op_ret < 0) {
ldout(s->cct, 1) << "failed to remove subscription '" << sub_name << "', ret=" << op_ret << dendl;
return;
}
RGWRole role(s->cct, store->getRados()->pctl, role_name, role_path, trust_policy,
s->user->get_tenant(), max_session_duration);
- op_ret = role.create(true);
+ op_ret = role.create(true, y);
if (op_ret == -EEXIST) {
op_ret = -ERR_ROLE_EXISTS;
return;
}
- op_ret = _role.delete_obj();
+ op_ret = _role.delete_obj(y);
if (op_ret == -ENOENT) {
op_ret = -ERR_NO_ROLE_FOUND;
}
_role.update_trust_policy(trust_policy);
- op_ret = _role.update();
+ op_ret = _role.update(y);
s->formatter->open_object_section("UpdateAssumeRolePolicyResponse");
s->formatter->open_object_section("ResponseMetadata");
}
_role.set_perm_policy(policy_name, perm_policy);
- op_ret = _role.update();
+ op_ret = _role.update(y);
if (op_ret == 0) {
s->formatter->open_object_section("PutRolePolicyResponse");
}
if (op_ret == 0) {
- op_ret = _role.update();
+ op_ret = _role.update(y);
}
s->formatter->open_object_section("DeleteRolePoliciesResponse");
const string RGWRole::role_path_oid_prefix = "role_paths.";
const string RGWRole::role_arn_prefix = "arn:aws:iam::";
-int RGWRole::store_info(bool exclusive)
+int RGWRole::store_info(bool exclusive, optional_yield y)
{
using ceph::encode;
string oid = get_info_oid_prefix() + id;
auto obj_ctx = ctl->svc->sysobj->init_obj_ctx();
return rgw_put_system_obj(obj_ctx, svc->zone->get_zone_params().roles_pool, oid,
- bl, exclusive, NULL, real_time(), NULL);
+ bl, exclusive, NULL, real_time(), y, NULL);
}
-int RGWRole::store_name(bool exclusive)
+int RGWRole::store_name(bool exclusive, optional_yield y)
{
RGWNameToId nameToId;
nameToId.obj_id = id;
auto obj_ctx = svc->sysobj->init_obj_ctx();
return rgw_put_system_obj(obj_ctx, svc->zone->get_zone_params().roles_pool, oid,
- bl, exclusive, NULL, real_time(), NULL);
+ bl, exclusive, NULL, real_time(), y, NULL);
}
-int RGWRole::store_path(bool exclusive)
+int RGWRole::store_path(bool exclusive, optional_yield y)
{
string oid = tenant + get_path_oid_prefix() + path + get_info_oid_prefix() + id;
bufferlist bl;
auto obj_ctx = svc->sysobj->init_obj_ctx();
return rgw_put_system_obj(obj_ctx, svc->zone->get_zone_params().roles_pool, oid,
- bl, exclusive, NULL, real_time(), NULL);
+ bl, exclusive, NULL, real_time(), y, NULL);
}
-int RGWRole::create(bool exclusive)
+int RGWRole::create(bool exclusive, optional_yield y)
{
int ret;
auto svc = ctl->svc;
auto& pool = svc->zone->get_zone_params().roles_pool;
- ret = store_info(exclusive);
+ ret = store_info(exclusive, y);
if (ret < 0) {
ldout(cct, 0) << "ERROR: storing role info in pool: " << pool.name << ": "
<< id << ": " << cpp_strerror(-ret) << dendl;
return ret;
}
- ret = store_name(exclusive);
+ ret = store_name(exclusive, y);
if (ret < 0) {
ldout(cct, 0) << "ERROR: storing role name in pool: " << pool.name << ": "
<< name << ": " << cpp_strerror(-ret) << dendl;
//Delete the role info that was stored in the previous call
string oid = get_info_oid_prefix() + id;
- int info_ret = rgw_delete_system_obj(svc->sysobj, pool, oid, NULL);
+ int info_ret = rgw_delete_system_obj(svc->sysobj, pool, oid, NULL, y);
if (info_ret < 0) {
ldout(cct, 0) << "ERROR: cleanup of role id from pool: " << pool.name << ": "
<< id << ": " << cpp_strerror(-info_ret) << dendl;
return ret;
}
- ret = store_path(exclusive);
+ ret = store_path(exclusive, y);
if (ret < 0) {
ldout(cct, 0) << "ERROR: storing role path in pool: " << pool.name << ": "
<< path << ": " << cpp_strerror(-ret) << dendl;
//Delete the role info that was stored in the previous call
string oid = get_info_oid_prefix() + id;
- int info_ret = rgw_delete_system_obj(svc->sysobj, pool, oid, NULL);
+ int info_ret = rgw_delete_system_obj(svc->sysobj, pool, oid, NULL, y);
if (info_ret < 0) {
ldout(cct, 0) << "ERROR: cleanup of role id from pool: " << pool.name << ": "
<< id << ": " << cpp_strerror(-info_ret) << dendl;
}
//Delete role name that was stored in previous call
oid = tenant + get_names_oid_prefix() + name;
- int name_ret = rgw_delete_system_obj(svc->sysobj, pool, oid, NULL);
+ int name_ret = rgw_delete_system_obj(svc->sysobj, pool, oid, NULL, y);
if (name_ret < 0) {
ldout(cct, 0) << "ERROR: cleanup of role name from pool: " << pool.name << ": "
<< name << ": " << cpp_strerror(-name_ret) << dendl;
return 0;
}
-int RGWRole::delete_obj()
+int RGWRole::delete_obj(optional_yield y)
{
auto svc = ctl->svc;
auto& pool = svc->zone->get_zone_params().roles_pool;
// Delete id
string oid = get_info_oid_prefix() + id;
- ret = rgw_delete_system_obj(svc->sysobj, pool, oid, NULL);
+ ret = rgw_delete_system_obj(svc->sysobj, pool, oid, NULL, y);
if (ret < 0) {
ldout(cct, 0) << "ERROR: deleting role id from pool: " << pool.name << ": "
<< id << ": " << cpp_strerror(-ret) << dendl;
// Delete name
oid = tenant + get_names_oid_prefix() + name;
- ret = rgw_delete_system_obj(svc->sysobj, pool, oid, NULL);
+ ret = rgw_delete_system_obj(svc->sysobj, pool, oid, NULL, y);
if (ret < 0) {
ldout(cct, 0) << "ERROR: deleting role name from pool: " << pool.name << ": "
<< name << ": " << cpp_strerror(-ret) << dendl;
// Delete path
oid = tenant + get_path_oid_prefix() + path + get_info_oid_prefix() + id;
- ret = rgw_delete_system_obj(svc->sysobj, pool, oid, NULL);
+ ret = rgw_delete_system_obj(svc->sysobj, pool, oid, NULL, y);
if (ret < 0) {
ldout(cct, 0) << "ERROR: deleting role path from pool: " << pool.name << ": "
<< path << ": " << cpp_strerror(-ret) << dendl;
return 0;
}
-int RGWRole::update()
+int RGWRole::update(optional_yield y)
{
auto& pool = ctl->svc->zone->get_zone_params().roles_pool;
- int ret = store_info(false);
+ int ret = store_info(false, y);
if (ret < 0) {
ldout(cct, 0) << "ERROR: storing info in pool: " << pool.name << ": "
<< id << ": " << cpp_strerror(-ret) << dendl;
#include <string>
+#include "common/async/yield_context.h"
+
#include "common/ceph_json.h"
#include "common/ceph_context.h"
+#include "rgw/rgw_rados.h"
+
class RGWCtl;
class RGWRole
string tenant;
uint64_t max_session_duration;
- int store_info(bool exclusive);
- int store_name(bool exclusive);
- int store_path(bool exclusive);
+ int store_info(bool exclusive, optional_yield y);
+ int store_name(bool exclusive, optional_yield y);
+ int store_path(bool exclusive, optional_yield y);
int read_id(const string& role_name, const string& tenant, string& role_id);
int read_name();
int read_info();
void set_id(const string& id) { this->id = id; }
- int create(bool exclusive);
- int delete_obj();
+ int create(bool exclusive, optional_yield y);
+ int delete_obj(optional_yield y);
int get();
int get_by_id();
- int update();
+ int update(optional_yield y);
void update_trust_policy(string& trust_policy);
void set_perm_policy(const string& policy_name, const string& perm_policy);
vector<string> get_role_policy_names();
};
WRITE_CLASS_ENCODER(RGWRole)
#endif /* CEPH_RGW_ROLE_H */
-
ups.emplace(store, s->owner.get_id());
auto b = ups->get_bucket(bucket_info.bucket);
- op_ret = b->create_notification(topic_name, events);
+ op_ret = b->create_notification(topic_name, events, y);
if (op_ret < 0) {
ldout(s->cct, 1) << "failed to create notification for topic '" << topic_name << "', ret=" << op_ret << dendl;
return;
ups.emplace(store, s->owner.get_id());
auto b = ups->get_bucket(bucket_info.bucket);
- op_ret = b->remove_notification(topic_name);
+ op_ret = b->remove_notification(topic_name, y);
if (op_ret < 0) {
ldout(s->cct, 1) << "failed to remove notification from topic '" << topic_name << "', ret=" << op_ret << dendl;
return;
return ret;
}
-int rgw_put_system_obj(RGWSysObjectCtx& obj_ctx, const rgw_pool& pool, const string& oid, bufferlist& data, bool exclusive,
- RGWObjVersionTracker *objv_tracker, real_time set_mtime, map<string, bufferlist> *pattrs)
-{
- return rgw_put_system_obj(obj_ctx, pool, oid, data, exclusive,
- objv_tracker, set_mtime, null_yield, pattrs);
-}
-
int rgw_get_system_obj(RGWSysObjectCtx& obj_ctx, const rgw_pool& pool, const string& key, bufferlist& bl,
RGWObjVersionTracker *objv_tracker, real_time *pmtime, optional_yield y, map<string, bufferlist> *pattrs,
rgw_cache_entry_info *cache_info,
}
int rgw_delete_system_obj(RGWSI_SysObj *sysobj_svc, const rgw_pool& pool, const string& oid,
- RGWObjVersionTracker *objv_tracker)
+ RGWObjVersionTracker *objv_tracker, optional_yield y)
{
auto obj_ctx = sysobj_svc->init_obj_ctx();
auto sysobj = obj_ctx.get_obj(rgw_raw_obj{pool, oid});
rgw_raw_obj obj(pool, oid);
return sysobj.wop()
.set_objv_tracker(objv_tracker)
- .remove(null_yield);
+ .remove(y);
}
thread_local bool is_asio_thread = false;
return 0;
}
-int RGWDataAccess::Bucket::init()
+int RGWDataAccess::Bucket::init(optional_yield y)
{
int ret = sd->store->getRados()->get_bucket_info(sd->store->svc(),
tenant, name,
bucket_info,
&mtime,
- null_yield,
+ y,
&attrs);
if (ret < 0) {
return ret;
extern const std::string MP_META_SUFFIX;
-static inline int rgw_shards_max()
+inline int rgw_shards_max()
{
return RGW_SHARDS_PRIME_1;
}
}
// used for logging and tagging
-static inline int rgw_shard_id(const string& key, int max_shards)
+inline int rgw_shard_id(const string& key, int max_shards)
{
return rgw_shards_mod(ceph_str_hash_linux(key.c_str(), key.size()),
max_shards);
int rgw_parse_list_of_flags(struct rgw_name_to_flag *mapping,
const string& str, uint32_t *perm);
-int rgw_put_system_obj(RGWSysObjectCtx& obj_ctx, const rgw_pool& pool, const string& oid, bufferlist& data, bool exclusive,
- RGWObjVersionTracker *objv_tracker, real_time set_mtime, map<string, bufferlist> *pattrs = NULL);
int rgw_put_system_obj(RGWSysObjectCtx& obj_ctx, const rgw_pool& pool, const string& oid, bufferlist& data, bool exclusive,
RGWObjVersionTracker *objv_tracker, real_time set_mtime, optional_yield y, map<string, bufferlist> *pattrs = NULL);
int rgw_get_system_obj(RGWSysObjectCtx& obj_ctx, const rgw_pool& pool, const string& key, bufferlist& bl,
rgw_cache_entry_info *cache_info = NULL,
boost::optional<obj_version> refresh_version = boost::none);
int rgw_delete_system_obj(RGWSI_SysObj *sysobj_svc, const rgw_pool& pool, const string& oid,
- RGWObjVersionTracker *objv_tracker);
+ RGWObjVersionTracker *objv_tracker, optional_yield y);
const char *rgw_find_mime_by_ext(string& ext);
name(_name),
bucket_id(_bucket_id) {}
Bucket(RGWDataAccess *_sd) : sd(_sd) {}
- int init();
+ int init(optional_yield y);
int init(const RGWBucketInfo& _bucket_info, const map<string, bufferlist>& _attrs);
public:
int get_object(const rgw_obj_key& key,
int get_bucket(const string& tenant,
const string name,
const string bucket_id,
- BucketRef *bucket) {
+ BucketRef *bucket,
+ optional_yield y) {
bucket->reset(new Bucket(this, tenant, name, bucket_id));
- return (*bucket)->init();
+ return (*bucket)->init(y);
}
int get_bucket(const RGWBucketInfo& bucket_info,
int RGWSI_MDLog::write_history(const RGWMetadataLogHistory& state,
RGWObjVersionTracker *objv_tracker,
- bool exclusive)
+ optional_yield y, bool exclusive)
{
bufferlist bl;
state.encode(bl);
const auto& oid = RGWMetadataLogHistory::oid;
auto obj_ctx = svc.sysobj->init_obj_ctx();
return rgw_put_system_obj(obj_ctx, pool, oid, bl,
- exclusive, objv_tracker, real_time{});
+ exclusive, objv_tracker, real_time{}, y);
}
namespace mdlog {
state.oldest_period_id = cursor.get_period().get_id();
constexpr bool exclusive = true; // don't overwrite
- int ret = write_history(state, &objv, exclusive);
+ int ret = write_history(state, &objv, y, exclusive);
if (ret < 0 && ret != -EEXIST) {
ldout(cct, 1) << "failed to write mdlog history: "
<< cpp_strerror(ret) << dendl;
state.oldest_realm_epoch = cursor.get_epoch();
state.oldest_period_id = cursor.get_period().get_id();
ldout(cct, 10) << "rewriting mdlog history" << dendl;
- ret = write_history(state, &objv);
+ ret = write_history(state, &objv, y);
if (ret < 0 && ret != -ECANCELED) {
ldout(cct, 1) << "failed to write mdlog history: "
<< cpp_strerror(ret) << dendl;
int read_history(RGWMetadataLogHistory *state, RGWObjVersionTracker *objv_tracker,optional_yield y) const;
int write_history(const RGWMetadataLogHistory& state,
RGWObjVersionTracker *objv_tracker,
- bool exclusive = false);
+ optional_yield y, bool exclusive = false);
int add_entry(const string& hash_key, const string& section, const string& key, bufferlist& bl);