Skip to content
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

rgw: set correct requestId and hostId on s3select error #56864

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 10 additions & 14 deletions src/rgw/rgw_s3select.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,7 @@ void aws_response_handler::send_success_response()
}

void aws_response_handler::send_error_response_rgw_formatter(const char* error_code,
const char* error_message,
const char* resource_id)
const char* error_message)
{
set_req_state_err(s, 0);
dump_errno(s, 400);
Expand All @@ -246,8 +245,9 @@ void aws_response_handler::send_error_response_rgw_formatter(const char* error_c
s->formatter->open_object_section("Error");
s->formatter->dump_string("Code", error_code);
s->formatter->dump_string("Message", error_message);
s->formatter->dump_string("Resource", "#Resource#");
s->formatter->dump_string("RequestId", resource_id);
if (!s->trans_id.empty())
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

s->formatter->dump_string("RequestId", s->trans_id);
s->formatter->dump_string("HostId", s->host_id);
s->formatter->close_section();
rgw_flush_formatter_and_reset(s, s->formatter);
}
Expand Down Expand Up @@ -429,7 +429,7 @@ int RGWSelectObj_ObjStore_S3::run_s3select_on_csv(const char* query, const char*

if (s3select_syntax.get_error_description().empty() == false) {
//error-flow (syntax-error)
m_aws_response_handler.send_error_response_rgw_formatter(s3select_syntax_error,s3select_syntax.get_error_description().c_str(),s3select_resource_id);
m_aws_response_handler.send_error_response_rgw_formatter(s3select_syntax_error,s3select_syntax.get_error_description().c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

please review #56834
this part was changed.
your changes could easily applied to that PR.

ldpp_dout(this, 10) << "s3-select query: failed to prase the following query {" << query << "}" << dendl;
ldpp_dout(this, 10) << "s3-select query: syntax-error {" << s3select_syntax.get_error_description() << "}" << dendl;
return -1;
Expand All @@ -446,7 +446,7 @@ int RGWSelectObj_ObjStore_S3::run_s3select_on_csv(const char* query, const char*

if (status < 0) {
//error flow(processing-time)
m_aws_response_handler.send_error_response_rgw_formatter(s3select_processTime_error,m_s3_csv_object.get_error_description().c_str(),s3select_resource_id);
m_aws_response_handler.send_error_response_rgw_formatter(s3select_processTime_error,m_s3_csv_object.get_error_description().c_str());

ldpp_dout(this, 10) << "s3-select query: failed to process query; {" << m_s3_csv_object.get_error_description() << "}" << dendl;
return -1;
Expand Down Expand Up @@ -527,8 +527,7 @@ int RGWSelectObj_ObjStore_S3::run_s3select_on_json(const char* query, const char
if (m_json_datatype.compare("DOCUMENT") != 0) {
const char* s3select_json_error_msg = "s3-select query: wrong json dataType should use DOCUMENT; ";
m_aws_response_handler.send_error_response_rgw_formatter(s3select_json_error,
s3select_json_error_msg,
s3select_resource_id);
s3select_json_error_msg);
ldpp_dout(this, 10) << s3select_json_error_msg << dendl;
return -EINVAL;
}
Expand All @@ -538,8 +537,7 @@ int RGWSelectObj_ObjStore_S3::run_s3select_on_json(const char* query, const char
if (s3select_syntax.get_error_description().empty() == false) {
//SQL statement is wrong(syntax).
m_aws_response_handler.send_error_response_rgw_formatter(s3select_syntax_error,
s3select_syntax.get_error_description().c_str(),
s3select_resource_id);
s3select_syntax.get_error_description().c_str());
ldpp_dout(this, 10) << "s3-select query: failed to prase query; {" << s3select_syntax.get_error_description() << "}" << dendl;
return -EINVAL;
}
Expand All @@ -560,17 +558,15 @@ int RGWSelectObj_ObjStore_S3::run_s3select_on_json(const char* query, const char
ldpp_dout(this, 10) << "S3select: failed to process JSON object: " << e.what() << dendl;
m_aws_response_handler.get_sql_result().append(e.what());
m_aws_response_handler.send_error_response_rgw_formatter(s3select_processTime_error,
e.what(),
s3select_resource_id);
e.what());
return -EINVAL;
}
uint32_t length_post_processing = m_aws_response_handler.get_sql_result().size();
m_aws_response_handler.update_total_bytes_returned(length_post_processing - length_before_processing);
if (status < 0) {
//error flow(processing-time)
m_aws_response_handler.send_error_response_rgw_formatter(s3select_processTime_error,
m_s3_json_object.get_error_description().c_str(),
s3select_resource_id);
m_s3_json_object.get_error_description().c_str());
ldpp_dout(this, 10) << "s3-select query: failed to process query; {" << m_s3_json_object.get_error_description() << "}" << dendl;
return -EINVAL;
}
Expand Down
10 changes: 4 additions & 6 deletions src/rgw/rgw_s3select_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ class aws_response_handler
void send_stats_response();

void send_error_response_rgw_formatter(const char* error_code,
const char* error_message,
const char* resource_id);
const char* error_message);

std::string* get_buffer()
{
Expand Down Expand Up @@ -234,10 +233,9 @@ class RGWSelectObj_ObjStore_S3 : public RGWGetObj_ObjStore_S3
std::function<void(void)> fp_chunked_transfer_encoding;
int m_header_size;

const char* s3select_processTime_error = "s3select-ProcessingTime-Error";
const char* s3select_syntax_error = "s3select-Syntax-Error";
const char* s3select_resource_id = "resourcse-id";
const char* s3select_json_error = "json-Format-Error";
const char* s3select_processTime_error = "ProcessingTimeError";
const char* s3select_syntax_error = "UnsupportedSyntax";
const char* s3select_json_error = "InvalidJsonType";

public:
unsigned int chunk_number;
Expand Down