Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions src/common/options/rgw.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -3983,19 +3983,50 @@ options:
are sent to it for more than the time defined.
Note that the connection will not be considered idle, even if it is down,
as long as there are attempts to send messages to it.
default: 30
If set to zero, connections are never considered idle.
default: 300
services:
- rgw
with_legacy: true
- name: rgw_kafka_sleep_timeout
type: uint
level: advanced
desc: Time in milliseconds to sleep while polling for kafka replies
long_desc: This will be used to prevent busy waiting for the kafka replies
long_desc: This will be used to prevent busy waiting for the kafka replies.
As well as for the cases where the broker is down and we try to reconnect.
The same values times 3 will be used to sleep if there were no messages
sent or received across all kafka connections
The same values times 3, will be used to sleep if there were no messages
sent or received across all kafka connections.
If set to zero, poll will return immediatly, as well as the other sleeeps.
This may raise the CPU consumption of the kafka thread.
default: 10
services:
- rgw
with_legacy: true
- name: rgw_kafka_message_timeout
type: uint
level: advanced
desc: This is the maximum time in milliseconds to deliver a message (including retries)
long_desc: Delivery error occurs when either the retry count or the message timeout are exceeded.
If set to zero, message will time out only based on retries.
default: 5000
services:
- rgw
with_legacy: true
- name: rgw_kafka_check_broker
type: bool
level: advanced
desc: Checking the state of the broker before sending the notification
long_desc: If set to "true" we will check the state of the broker before sending the
actual notification. If the broker is down we will reply with an error to the operation
that triggered the notification (S3, lifecycle, multisiet syncing).
Note that the actual sending may still fail even if the state of the broker was ok.
If set to "true", (the current behavior, and the default) the state of the broker is not checked.
In both cases, failure to actually send the notification will not trigger failure
of the operation that triggered the notification, and will only be logged.
Note that this is applicable only for non-persistent (synchronous) notifications.
Persistent notifications will reply with an error to the operation that triggered them
only if their persistent queue is full, and ignore the state of the broker.
default: false
services:
- rgw
with_legacy: true
8 changes: 1 addition & 7 deletions src/rgw/driver/rados/rgw_cr_rados.cc
Original file line number Diff line number Diff line change
Expand Up @@ -802,13 +802,7 @@ int RGWAsyncFetchRemoteObj::_send_request(const DoutPrefixProvider *dpp)
// NOTE: we create a mutable copy of bucket.get_tenant as the get_notification function expects a std::string&, not const
std::string tenant(dest_bucket.get_tenant());

std::unique_ptr<rgw::sal::Notification> notify
= store->get_notification(dpp, &dest_obj, nullptr, rgw::notify::ObjectSyncedCreate,
&dest_bucket, user_id,
tenant,
req_id, null_yield);

auto notify_res = static_cast<rgw::sal::RadosNotification*>(notify.get())->get_reservation();
rgw::notify::reservation_t notify_res(dpp, store, &dest_obj, nullptr, &dest_bucket, user_id, tenant, req_id, null_yield);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

int ret = rgw::notify::publish_reserve(dpp, rgw::notify::ObjectSyncedCreate, notify_res, &obj_tags);
if (ret < 0) {
ldpp_dout(dpp, 1) << "ERROR: reserving notification failed, with error: " << ret << dendl;
Expand Down
86 changes: 46 additions & 40 deletions src/rgw/driver/rados/rgw_notify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ class Manager : public DoutPrefixProvider {
std::vector<std::string> entryProcessingResultString = {"Failure", "Successful", "Sleeping", "Expired", "Migrating"};

// processing of a specific entry
// return whether processing was successful (true) or not (false)
EntryProcessingResult process_entry(const ConfigProxy& conf, persistency_tracker& entry_persistency_tracker,
const cls_queue_entry& entry, spawn::yield_context yield) {
event_entry_t event_entry;
Expand All @@ -244,7 +243,7 @@ class Manager : public DoutPrefixProvider {
if ( (topic_persistency_ttl != 0 && event_entry.creation_time != ceph::coarse_real_clock::zero() &&
time_now - event_entry.creation_time > std::chrono::seconds(topic_persistency_ttl))
|| ( topic_persistency_max_retries != 0 && entry_persistency_tracker.retires_num > topic_persistency_max_retries) ) {
ldpp_dout(this, 1) << "Expiring entry for topic= "
ldpp_dout(this, 1) << "WARNING: Expiring entry for topic= "
<< event_entry.arn_topic << " bucket_owner= "
<< event_entry.event.bucket_ownerIdentity
<< " bucket= " << event_entry.event.bucket_name
Expand All @@ -261,15 +260,14 @@ class Manager : public DoutPrefixProvider {

++entry_persistency_tracker.retires_num;
entry_persistency_tracker.last_retry_time = time_now;
ldpp_dout(this, 20) << "Processing entry retry_number=" << entry_persistency_tracker.retires_num << " time=" << dendl;
ldpp_dout(this, 20) << "INFO: Processing entry retry_number=" << entry_persistency_tracker.retires_num << " time=" << dendl;
try {
// TODO move endpoint creation to queue level
const auto push_endpoint = RGWPubSubEndpoint::create(event_entry.push_endpoint, event_entry.arn_topic,
RGWHTTPArgs(event_entry.push_endpoint_args, this),
cct);
std::unique_ptr<RGWPubSubEndpoint> endpoint{RGWPubSubEndpoint::create(event_entry.push_endpoint, event_entry.arn_topic,
RGWHTTPArgs(event_entry.push_endpoint_args, this), cct)};
ldpp_dout(this, 20) << "INFO: push endpoint created: " << event_entry.push_endpoint <<
" for entry: " << entry.marker << dendl;
const auto ret = push_endpoint->send_to_completion_async(cct, event_entry.event, optional_yield(io_context, yield));
const auto ret = endpoint->send(cct, event_entry.event, optional_yield(io_context, yield));
if (ret < 0) {
ldpp_dout(this, 5) << "WARNING: push entry: " << entry.marker << " to endpoint: " << event_entry.push_endpoint
<< " failed. error: " << ret << " (will retry)" << dendl;
Expand Down Expand Up @@ -691,15 +689,15 @@ class Manager : public DoutPrefixProvider {
try {
io_context.run();
} catch (const std::exception& err) {
ldpp_dout(this, 10) << "Notification worker failed with error: " << err.what() << dendl;
ldpp_dout(this, 1) << "ERROR: Notification worker failed with error: " << err.what() << dendl;
throw(err);
}
});
const auto rc = ceph_pthread_setname(workers.back().native_handle(),
(WORKER_THREAD_NAME+std::to_string(worker_id)).c_str());
ceph_assert(rc == 0);
}
ldpp_dout(this, 10) << "Started notification manager with: " << worker_count << " workers" << dendl;
ldpp_dout(this, 10) << "INFO: Started notification manager with: " << worker_count << " workers" << dendl;
}

int add_persistent_topic(const std::string& topic_name, optional_yield y) {
Expand Down Expand Up @@ -1025,6 +1023,32 @@ static inline bool notification_match(reservation_t& res,
ldpp_dout(res.dpp, 1) << "ERROR: failed to parse reservation id. error: " << ret << dendl;
return ret;
}
} else {
// no reservation - try to connect to endpoint instead
try {
std::unique_ptr<RGWPubSubEndpoint> endpoint(RGWPubSubEndpoint::create(
topic_cfg.dest.push_endpoint,
topic_cfg.dest.arn_topic,
RGWHTTPArgs(topic_cfg.dest.push_endpoint_args, dpp),
dpp->get_cct()));
ldpp_dout(res.dpp, 20) << "INFO: push endpoint created: "
<< topic_cfg.dest.push_endpoint << dendl;
const auto ret = endpoint->is_alive(dpp->get_cct(), res.yield);
if (ret < 0) {
ldpp_dout(dpp, 1)
<< "ERROR: endpoint " << topic_cfg.dest.push_endpoint
<< " is_alive failed. error: " << ret << dendl;
if (perfcounter) perfcounter->inc(l_rgw_pubsub_push_failed);
return ret;
}
res.endpoint.swap(endpoint);
} catch (const RGWPubSubEndpoint::configuration_error& e) {
ldpp_dout(dpp, 1) << "ERROR: failed to create push endpoint: "
<< topic_cfg.dest.push_endpoint
<< ". error: " << e.what() << dendl;
if (perfcounter) perfcounter->inc(l_rgw_pubsub_push_failed);
return -EINVAL;
}
}
res.topics.emplace_back(topic_filter.s3_id, topic_cfg, res_id);
}
Expand Down Expand Up @@ -1120,39 +1144,21 @@ int publish_commit(rgw::sal::Object* obj,
pcc_arg.release();
completion.release();
} else {
try {
// TODO add endpoint LRU cache
const auto push_endpoint = RGWPubSubEndpoint::create(
topic.cfg.dest.push_endpoint,
topic.cfg.dest.arn_topic,
RGWHTTPArgs(topic.cfg.dest.push_endpoint_args, dpp),
dpp->get_cct());
ldpp_dout(res.dpp, 20) << "INFO: push endpoint created: "
<< topic.cfg.dest.push_endpoint << dendl;
const auto ret = push_endpoint->send_to_completion_async(
dpp->get_cct(), event_entry.event, res.yield);
if (ret < 0) {
ldpp_dout(dpp, 1)
<< "ERROR: push to endpoint " << topic.cfg.dest.push_endpoint
<< " bucket: " << event_entry.event.bucket_name
<< " bucket_owner: " << event_entry.event.bucket_ownerIdentity
<< " object_name: " << event_entry.event.object_key
<< " failed. error: " << ret << dendl;
if (perfcounter) perfcounter->inc(l_rgw_pubsub_push_failed);
return ret;
}
if (perfcounter) perfcounter->inc(l_rgw_pubsub_push_ok);
} catch (const RGWPubSubEndpoint::configuration_error& e) {
ldpp_dout(dpp, 1) << "ERROR: failed to create push endpoint: "
<< topic.cfg.dest.push_endpoint
<< " bucket: " << event_entry.event.bucket_name
<< " bucket_owner: "
<< event_entry.event.bucket_ownerIdentity
<< " object_name: " << event_entry.event.object_key
<< ". error: " << e.what() << dendl;
// "reservation" stage just check that endpoint is ok
// if not, we should not reach the commit stage
ceph_assert(res.endpoint);
const auto ret = res.endpoint->send(dpp->get_cct(), event_entry.event, res.yield);
if (ret < 0) {
ldpp_dout(dpp, 1)
<< "ERROR: push to endpoint " << topic.cfg.dest.push_endpoint
<< " bucket: " << event_entry.event.bucket_name
<< " bucket_owner: " << event_entry.event.bucket_ownerIdentity
<< " object_name: " << event_entry.event.object_key
<< " failed. error: " << ret << dendl;
if (perfcounter) perfcounter->inc(l_rgw_pubsub_push_failed);
return -EINVAL;
return ret;
}
if (perfcounter) perfcounter->inc(l_rgw_pubsub_push_ok);
}
}
return 0;
Expand Down
2 changes: 2 additions & 0 deletions src/rgw/driver/rados/rgw_notify.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace rgw::sal {

class RGWRados;
struct rgw_obj_key;
class RGWPubSubEndpoint;

namespace rgw::notify {

Expand Down Expand Up @@ -72,6 +73,7 @@ struct reservation_t {
const std::string user_tenant;
const std::string req_id;
optional_yield yield;
std::unique_ptr<RGWPubSubEndpoint> endpoint;

/* ctor for rgw_op callers */
reservation_t(const DoutPrefixProvider* _dpp,
Expand Down
28 changes: 21 additions & 7 deletions src/rgw/driver/rados/rgw_pubsub_push.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class RGWPubSubHTTPEndpoint : public RGWPubSubEndpoint {
}
}

int send_to_completion_async(CephContext* cct, const rgw_pubsub_s3_event& event, optional_yield y) override {
int send(CephContext* cct, const rgw_pubsub_s3_event& event, optional_yield y) override {
bufferlist read_bl;
RGWPostHTTPData request(cct, "POST", endpoint, &read_bl, verify_ssl);
const auto post_data = json_format_pubsub_event(event);
Expand All @@ -107,6 +107,11 @@ class RGWPubSubHTTPEndpoint : public RGWPubSubEndpoint {
return rc;
}

int is_alive(CephContext* cct, optional_yield y) override {
// TODO: implement
return 0;
}

std::string to_str() const override {
std::string str("HTTP/S Endpoint");
str += "\nURI: " + endpoint;
Expand Down Expand Up @@ -236,7 +241,7 @@ class RGWPubSubAMQPEndpoint : public RGWPubSubEndpoint {
}
}

int send_to_completion_async(CephContext* cct, const rgw_pubsub_s3_event& event, optional_yield y) override {
int send(CephContext* cct, const rgw_pubsub_s3_event& event, optional_yield y) override {
if (ack_level == ack_level_t::None) {
return amqp::publish(conn_id, topic, json_format_pubsub_event(event));
} else {
Expand All @@ -254,6 +259,11 @@ class RGWPubSubAMQPEndpoint : public RGWPubSubEndpoint {
return w->wait(y);
}
}

int is_alive(CephContext* cct, optional_yield y) override {
// TODO: implement
return 0;
}

std::string to_str() const override {
std::string str("AMQP(0.9.1) Endpoint");
Expand Down Expand Up @@ -309,7 +319,7 @@ class RGWPubSubKafkaEndpoint : public RGWPubSubEndpoint {
}
}

int send_to_completion_async(CephContext* cct, const rgw_pubsub_s3_event& event, optional_yield y) override {
int send(CephContext* cct, const rgw_pubsub_s3_event& event, optional_yield y) override {
if (ack_level == ack_level_t::None) {
return kafka::publish(conn_name, topic, json_format_pubsub_event(event));
} else {
Expand All @@ -326,6 +336,10 @@ class RGWPubSubKafkaEndpoint : public RGWPubSubEndpoint {
return w->wait(y);
}
}

int is_alive(CephContext* cct, optional_yield y) override {
return kafka::check_broker(conn_name, topic);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check_broker() is returning internal error codes like STATUS_CONNECTION_CLOSED that the rest of rgw doesn't understand. should there be some kind of error mapping so we can choose the right http error to return?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to -EIO

}

std::string to_str() const override {
std::string str("Kafka Endpoint");
Expand Down Expand Up @@ -365,13 +379,13 @@ const std::string& get_schema(const std::string& endpoint) {
return UNKNOWN_SCHEMA;
}

RGWPubSubEndpoint::Ptr RGWPubSubEndpoint::create(const std::string& endpoint,
RGWPubSubEndpoint* RGWPubSubEndpoint::create(const std::string& endpoint,
const std::string& topic,
const RGWHTTPArgs& args,
CephContext* cct) {
const auto& schema = get_schema(endpoint);
if (schema == WEBHOOK_SCHEMA) {
return Ptr(new RGWPubSubHTTPEndpoint(endpoint, args));
return new RGWPubSubHTTPEndpoint(endpoint, args);
#ifdef WITH_RADOSGW_AMQP_ENDPOINT
} else if (schema == AMQP_SCHEMA) {
bool exists;
Expand All @@ -380,7 +394,7 @@ RGWPubSubEndpoint::Ptr RGWPubSubEndpoint::create(const std::string& endpoint,
version = AMQP_0_9_1;
}
if (version == AMQP_0_9_1) {
return Ptr(new RGWPubSubAMQPEndpoint(endpoint, topic, args, cct));
return new RGWPubSubAMQPEndpoint(endpoint, topic, args, cct);
} else if (version == AMQP_1_0) {
throw configuration_error("AMQP: v1.0 not supported");
return nullptr;
Expand All @@ -391,7 +405,7 @@ RGWPubSubEndpoint::Ptr RGWPubSubEndpoint::create(const std::string& endpoint,
#endif
#ifdef WITH_RADOSGW_KAFKA_ENDPOINT
} else if (schema == KAFKA_SCHEMA) {
return Ptr(new RGWPubSubKafkaEndpoint(endpoint, topic, args, cct));
return new RGWPubSubKafkaEndpoint(endpoint, topic, args, cct);
#endif
}

Expand Down
12 changes: 6 additions & 6 deletions src/rgw/driver/rados/rgw_pubsub_push.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ class RGWPubSubEndpoint {
RGWPubSubEndpoint(const RGWPubSubEndpoint&) = delete;
const RGWPubSubEndpoint& operator=(const RGWPubSubEndpoint&) = delete;

typedef std::unique_ptr<RGWPubSubEndpoint> Ptr;

// factory method for the actual notification endpoint
// derived class specific arguments are passed in http args format
// may throw a configuration_error if creation fails
static Ptr create(const std::string& endpoint, const std::string& topic, const RGWHTTPArgs& args, CephContext *cct=nullptr);
static RGWPubSubEndpoint* create(const std::string& endpoint, const std::string& topic, const RGWHTTPArgs& args, CephContext *cct=nullptr);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this not return unique_ptr anymore?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no reason. will bring it back


// this method is used in order to send notification (S3 compliant) and wait for completion
// in async manner via a coroutine when invoked in the frontend environment
virtual int send_to_completion_async(CephContext* cct, const rgw_pubsub_s3_event& event, optional_yield y) = 0;
// this method is used in order to send notification to the endpoint
virtual int send(CephContext* cct, const rgw_pubsub_s3_event& event, optional_yield y) = 0;

// this method is used in order to verify connectivity with the endpoint
virtual int is_alive(CephContext* cct, optional_yield y) = 0;

// present as string
virtual std::string to_str() const { return ""; }
Expand Down
4 changes: 0 additions & 4 deletions src/rgw/driver/rados/rgw_sal_rados.h
Original file line number Diff line number Diff line change
Expand Up @@ -713,10 +713,6 @@ class RadosNotification : public StoreNotification {

~RadosNotification() = default;

rgw::notify::reservation_t& get_reservation(void) {
return res;
}

virtual int publish_reserve(const DoutPrefixProvider *dpp, RGWObjTags* obj_tags = nullptr) override;
virtual int publish_commit(const DoutPrefixProvider* dpp, uint64_t size,
const ceph::real_time& mtime, const std::string& etag, const std::string& version) override;
Expand Down
Loading