Repository navigation
rgw/kafka: reply with an error when broker is down #55051
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
|
|
@@ -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; | ||
|
|
@@ -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 { | ||
|
|
@@ -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"); | ||
|
|
@@ -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 { | ||
|
|
@@ -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); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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"); | ||
|
|
@@ -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; | ||
|
|
@@ -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; | ||
|
|
@@ -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 | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why does this not return unique_ptr anymore?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ""; } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍