Skip to content

Commit 41387da

Browse files
authored
Merge pull request #56864 from clwluvw/s3select-err
rgw: set correct requestId and hostId on s3select error Reviewed-by: Gal Salomon <gsalomon@redhat.com>
2 parents b02da3d + 3a103f2 commit 41387da

2 files changed

Lines changed: 19 additions & 26 deletions

File tree

src/rgw/rgw_s3select.cc

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,10 @@ void aws_response_handler::init_end_response()
214214
rgw_flush_formatter_and_reset(s, s->formatter);
215215
}
216216

217-
void aws_response_handler::send_error_response(const char* error_code, const char* error_message, const char* resource_id)
217+
void aws_response_handler::send_error_response(const char* error_code, const char* error_message)
218218
{
219219
m_fp_chunk_encoding();
220-
std::string out_error_msg = std::string(error_code) + " :" + std::string(error_message) + " :" + std::string(resource_id);
220+
std::string out_error_msg = std::string(error_code) + " :" + std::string(error_message) + " :" + s->trans_id;
221221
error_result.resize(header_crc_size, '\0');
222222
get_buffer()->clear();
223223
header_size = create_error_header_records(out_error_msg.data());
@@ -242,8 +242,7 @@ void aws_response_handler::send_success_response()
242242
static constexpr const char* empty_error="--";
243243

244244
void aws_response_handler::send_error_response_rgw_formatter(const char* error_code = empty_error,
245-
const char* error_message = empty_error,
246-
const char* resource_id = empty_error)
245+
const char* error_message = empty_error)
247246
{
248247
set_req_state_err(s, 0);
249248
dump_errno(s, 400);
@@ -252,8 +251,9 @@ void aws_response_handler::send_error_response_rgw_formatter(const char* error_c
252251
s->formatter->open_object_section("Error");
253252
s->formatter->dump_string("Code", error_code);
254253
s->formatter->dump_string("Message", error_message);
255-
s->formatter->dump_string("Resource", "#Resource#");
256-
s->formatter->dump_string("RequestId", resource_id);
254+
if (!s->trans_id.empty())
255+
s->formatter->dump_string("RequestId", s->trans_id);
256+
s->formatter->dump_string("HostId", s->host_id);
257257
s->formatter->close_section();
258258
rgw_flush_formatter_and_reset(s, s->formatter);
259259
}
@@ -436,7 +436,7 @@ int RGWSelectObj_ObjStore_S3::run_s3select_on_csv(const char* query, const char*
436436

437437
if (s3select_syntax.get_error_description().empty() == false) {
438438
//error-flow (syntax-error)
439-
m_aws_response_handler.send_error_response(s3select_syntax_error,s3select_syntax.get_error_description().c_str(),s3select_resource_id);
439+
m_aws_response_handler.send_error_response(s3select_syntax_error,s3select_syntax.get_error_description().c_str());
440440
ldpp_dout(this, 10) << "s3-select query: failed to prase the following query {" << query << "}" << dendl;
441441
ldpp_dout(this, 10) << "s3-select query: syntax-error {" << s3select_syntax.get_error_description() << "}" << dendl;
442442
return -1;
@@ -453,7 +453,7 @@ int RGWSelectObj_ObjStore_S3::run_s3select_on_csv(const char* query, const char*
453453

454454
if (status < 0) {
455455
//error flow(processing-time)
456-
m_aws_response_handler.send_error_response(s3select_processTime_error,m_s3_csv_object.get_error_description().data(),s3select_resource_id);
456+
m_aws_response_handler.send_error_response(s3select_processTime_error,m_s3_csv_object.get_error_description().data());
457457

458458
ldpp_dout(this, 10) << "s3-select query: failed to process query; {" << m_s3_csv_object.get_error_description() << "}" << dendl;
459459
return -1;
@@ -497,7 +497,7 @@ int RGWSelectObj_ObjStore_S3::run_s3select_on_parquet(const char* query)
497497
}
498498
if (s3select_syntax.get_error_description().empty() == false) {
499499
//the SQL statement failed the syntax parser
500-
m_aws_response_handler.send_error_response(s3select_syntax_error,m_s3_parquet_object.get_error_description().c_str(),s3select_resource_id);
500+
m_aws_response_handler.send_error_response(s3select_syntax_error, m_s3_parquet_object.get_error_description().c_str());
501501

502502
ldpp_dout(this, 10) << "s3-select query: failed to prase query; {" << s3select_syntax.get_error_description() << "}" << dendl;
503503
status = -1;
@@ -507,7 +507,7 @@ int RGWSelectObj_ObjStore_S3::run_s3select_on_parquet(const char* query)
507507
status = m_s3_parquet_object.run_s3select_on_object(m_aws_response_handler.get_sql_result());
508508
if (status < 0) {
509509

510-
m_aws_response_handler.send_error_response(s3select_processTime_error,m_s3_parquet_object.get_error_description().c_str(),s3select_resource_id);
510+
m_aws_response_handler.send_error_response(s3select_processTime_error, m_s3_parquet_object.get_error_description().c_str());
511511

512512
return -1;
513513
}
@@ -531,8 +531,7 @@ int RGWSelectObj_ObjStore_S3::run_s3select_on_json(const char* query, const char
531531
if (m_json_datatype.compare("DOCUMENT") != 0) {
532532
const char* s3select_json_error_msg = "s3-select query: wrong json dataType should use DOCUMENT; ";
533533
m_aws_response_handler.send_error_response_rgw_formatter(s3select_json_error,
534-
s3select_json_error_msg,
535-
s3select_resource_id);
534+
s3select_json_error_msg);
536535
ldpp_dout(this, 10) << s3select_json_error_msg << dendl;
537536
return -EINVAL;
538537
}
@@ -542,8 +541,7 @@ int RGWSelectObj_ObjStore_S3::run_s3select_on_json(const char* query, const char
542541
if (s3select_syntax.get_error_description().empty() == false) {
543542
//SQL statement is wrong(syntax).
544543
m_aws_response_handler.send_error_response(s3select_syntax_error,
545-
s3select_syntax.get_error_description().c_str(),
546-
s3select_resource_id);
544+
s3select_syntax.get_error_description().c_str());
547545
ldpp_dout(this, 10) << "s3-select query: failed to prase query; {" << s3select_syntax.get_error_description() << "}" << dendl;
548546
return -EINVAL;
549547
}
@@ -564,17 +562,15 @@ int RGWSelectObj_ObjStore_S3::run_s3select_on_json(const char* query, const char
564562
ldpp_dout(this, 10) << "S3select: failed to process JSON object: " << e.what() << dendl;
565563
m_aws_response_handler.get_sql_result().append(e.what());
566564
m_aws_response_handler.send_error_response(s3select_processTime_error,
567-
e.what(),
568-
s3select_resource_id);
565+
e.what());
569566
return -EINVAL;
570567
}
571568
uint32_t length_post_processing = m_aws_response_handler.get_sql_result().size();
572569
m_aws_response_handler.update_total_bytes_returned(length_post_processing - length_before_processing);
573570
if (status < 0) {
574571
//error flow(processing-time)
575572
m_aws_response_handler.send_error_response(s3select_processTime_error,
576-
m_s3_json_object.get_error_description().c_str(),
577-
s3select_resource_id);
573+
m_s3_json_object.get_error_description().c_str());
578574
ldpp_dout(this, 10) << "s3-select query: failed to process query; {" << m_s3_json_object.get_error_description() << "}" << dendl;
579575
return -EINVAL;
580576
}

src/rgw/rgw_s3select_private.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ class aws_response_handler
153153
void init_stats_response();
154154

155155
void send_error_response(const char* error_code,
156-
const char* error_message,
157-
const char* resource_id);
156+
const char* error_message);
158157

159158
void send_success_response();
160159

@@ -163,8 +162,7 @@ class aws_response_handler
163162
void send_stats_response();
164163

165164
void send_error_response_rgw_formatter(const char* error_code,
166-
const char* error_message,
167-
const char* resource_id);
165+
const char* error_message);
168166

169167
std::string* get_buffer()
170168
{
@@ -238,10 +236,9 @@ class RGWSelectObj_ObjStore_S3 : public RGWGetObj_ObjStore_S3
238236
std::function<void(void)> fp_chunked_transfer_encoding;
239237
int m_header_size;
240238

241-
const char* s3select_processTime_error = "s3select-ProcessingTime-Error";
242-
const char* s3select_syntax_error = "s3select-Syntax-Error";
243-
const char* s3select_resource_id = "resourcse-id";
244-
const char* s3select_json_error = "json-Format-Error";
239+
const char* s3select_processTime_error = "ProcessingTimeError";
240+
const char* s3select_syntax_error = "UnsupportedSyntax";
241+
const char* s3select_json_error = "InvalidJsonType";
245242

246243
public:
247244
unsigned int chunk_number;

0 commit comments

Comments
 (0)