info.account_id, path, info.name);
}
+// try to parse the xml <ErrorResponse> response body
+bool parse_aws_error_response(const std::string& input, rgw_err& err)
+{
+ RGWXMLParser parser;
+ if (!parser.init()) {
+ return false;
+ }
+ if (!parser.parse(input.c_str(), input.length(), 1)) {
+ return false;
+ }
+ auto error_response = parser.find_first("ErrorResponse");
+ if (!error_response) {
+ return false;
+ }
+ auto error = error_response->find_first("Error");
+ if (!error) {
+ return false;
+ }
+ if (auto code = error->find_first("Code"); code) {
+ err.err_code = code->get_data();
+ }
+ if (auto message = error->find_first("Message"); message) {
+ err.message = message->get_data();
+ }
+ return true;
+}
+
int forward_iam_request_to_master(const DoutPrefixProvider* dpp,
const rgw::SiteConfig& site,
const RGWUserInfo& user,
- bufferlist& indata,
- RGWXMLDecoder::XMLParser& parser,
- req_info& req, optional_yield y)
+ bufferlist& indata, RGWXMLParser& parser,
+ const req_info& req, rgw_err& err,
+ optional_yield y)
{
const auto& period = site.get_period();
if (!period) {
if (!result) {
return result.error();
}
- int ret = rgw_http_error_to_errno(*result);
+ err.http_ret = *result;
+ if (err.is_err() && outdata.length()) { // 4xx or 5xx
+ std::ignore = parse_aws_error_response(rgw_bl_str(outdata), err);
+ }
+ int ret = rgw_http_error_to_errno(err.http_ret);
if (ret < 0) {
return ret;
}
int forward_iam_request_to_master(const DoutPrefixProvider* dpp,
const rgw::SiteConfig& site,
const RGWUserInfo& user,
- bufferlist& indata,
- RGWXMLDecoder::XMLParser& parser,
- req_info& req, optional_yield y);
+ bufferlist& indata, RGWXMLParser& parser,
+ const req_info& req, rgw_err& err,
+ optional_yield y);
/// Perform an atomic read-modify-write operation on the given user metadata.
/// Racing writes are detected here as ECANCELED errors, where we reload the
s->info.args.remove("Version");
int r = forward_iam_request_to_master(this, site, s->user->get_info(),
- post_body, parser, s->info, y);
+ post_body, parser, s->info, s->err, y);
if (r < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << r << dendl;
return r;
s->info.args.remove("Version");
int r = forward_iam_request_to_master(this, site, s->user->get_info(),
- post_body, parser, s->info, y);
+ post_body, parser, s->info, s->err, y);
if (r < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << r << dendl;
return r;
s->info.args.remove("Version");
int r = forward_iam_request_to_master(this, site, s->user->get_info(),
- post_body, parser, s->info, y);
+ post_body, parser, s->info, s->err, y);
if (r < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << r << dendl;
return r;
s->info.args.remove("Version");
int r = forward_iam_request_to_master(this, site, s->user->get_info(),
- post_body, parser, s->info, y);
+ post_body, parser, s->info, s->err, y);
if (r < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << r << dendl;
return r;
s->info.args.remove("Version");
int r = forward_iam_request_to_master(this, site, s->user->get_info(),
- post_body, parser, s->info, y);
+ post_body, parser, s->info, s->err, y);
if (r < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << r << dendl;
return r;
s->info.args.remove("Version");
int r = forward_iam_request_to_master(this, site, s->user->get_info(),
- post_body, parser, s->info, y);
+ post_body, parser, s->info, s->err, y);
if (r < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << r << dendl;
return r;
s->info.args.remove("Version");
int r = forward_iam_request_to_master(this, site, s->user->get_info(),
- post_body, parser, s->info, y);
+ post_body, parser, s->info, s->err, y);
if (r < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << r << dendl;
return r;
s->info.args.remove("Version");
int r = forward_iam_request_to_master(this, site, s->user->get_info(),
- post_body, parser, s->info, y);
+ post_body, parser, s->info, s->err, y);
if (r < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << r << dendl;
return r;
s->info.args.remove("Version");
int r = forward_iam_request_to_master(this, site, s->user->get_info(),
- post_body, parser, s->info, y);
+ post_body, parser, s->info, s->err, y);
if (r < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << r << dendl;
return r;
}
int r = forward_iam_request_to_master(this, site, s->user->get_info(),
- post_body, parser, s->info, y);
+ post_body, parser, s->info, s->err, y);
if (r < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << r << dendl;
return r;
s->info.args.remove("Version");
int r = forward_iam_request_to_master(this, site, s->user->get_info(),
- post_body, parser, s->info, y);
+ post_body, parser, s->info, s->err, y);
if (r < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << r << dendl;
return r;
s->info.args.remove("Version");
int r = forward_iam_request_to_master(this, site, s->user->get_info(),
- post_body, parser, s->info, y);
+ post_body, parser, s->info, s->err, y);
if (r < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << r << dendl;
return r;
s->info.args.remove("Version");
int r = forward_iam_request_to_master(this, site, s->user->get_info(),
- post_body, parser, s->info, y);
+ post_body, parser, s->info, s->err, y);
if (r < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << r << dendl;
return r;
s->info.args.remove("Version");
int r = forward_iam_request_to_master(this, site, s->user->get_info(),
- post_body, parser, s->info, y);
+ post_body, parser, s->info, s->err, y);
if (r < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << r << dendl;
return r;
s->info.args.remove("Version");
int r = forward_iam_request_to_master(this, site, s->user->get_info(),
- post_body, parser, s->info, y);
+ post_body, parser, s->info, s->err, y);
if (r < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << r << dendl;
return r;
}
op_ret = forward_iam_request_to_master(this, site, s->user->get_info(),
- bl_post_body, parser, s->info, y);
+ bl_post_body, parser, s->info, s->err, y);
if (op_ret < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << op_ret << dendl;
return;
s->info.args.remove("Version");
op_ret = forward_iam_request_to_master(this, site, s->user->get_info(),
- bl_post_body, parser, s->info, y);
+ bl_post_body, parser, s->info, s->err, y);
if (op_ret < 0) {
ldpp_dout(this, 0) << "forward_iam_request_to_master returned ret=" << op_ret << dendl;
return;
s->info.args.remove("Version");
op_ret = forward_iam_request_to_master(this, site, s->user->get_info(),
- bl_post_body, parser, s->info, y);
+ bl_post_body, parser, s->info, s->err, y);
if (op_ret < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << op_ret << dendl;
return;
s->info.args.remove("Version");
op_ret = forward_iam_request_to_master(this, site, s->user->get_info(),
- bl_post_body, parser, s->info, y);
+ bl_post_body, parser, s->info, s->err, y);
if (op_ret < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << op_ret << dendl;
return;
s->info.args.remove("Version");
op_ret = forward_iam_request_to_master(this, site, s->user->get_info(),
- bl_post_body, parser, s->info, y);
+ bl_post_body, parser, s->info, s->err, y);
if (op_ret < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << op_ret << dendl;
return;
}
op_ret = forward_iam_request_to_master(this, site, s->user->get_info(),
- bl_post_body, parser, s->info, y);
+ bl_post_body, parser, s->info, s->err, y);
if (op_ret < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << op_ret << dendl;
return;
}
op_ret = forward_iam_request_to_master(this, site, s->user->get_info(),
- bl_post_body, parser, s->info, y);
+ bl_post_body, parser, s->info, s->err, y);
if (op_ret < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << op_ret << dendl;
return;
s->info.args.remove("Version");
op_ret = forward_iam_request_to_master(this, site, s->user->get_info(),
- bl_post_body, parser, s->info, y);
+ bl_post_body, parser, s->info, s->err, y);
if (op_ret < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << op_ret << dendl;
return;
s->info.args.remove("Version");
op_ret = forward_iam_request_to_master(this, site, s->user->get_info(),
- bl_post_body, parser, s->info, y);
+ bl_post_body, parser, s->info, s->err, y);
if (op_ret < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << op_ret << dendl;
return;
s->info.args.remove("Version");
op_ret = forward_iam_request_to_master(this, site, s->user->get_info(),
- bl_post_body, parser, s->info, y);
+ bl_post_body, parser, s->info, s->err, y);
if (op_ret < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << op_ret << dendl;
return;
s->info.args.remove("Version");
int r = forward_iam_request_to_master(this, site, s->user->get_info(),
- post_body, parser, s->info, y);
+ post_body, parser, s->info, s->err, y);
if (r < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << r << dendl;
return r;
s->info.args.remove("Version");
int r = forward_iam_request_to_master(this, site, s->user->get_info(),
- post_body, parser, s->info, y);
+ post_body, parser, s->info, s->err, y);
if (r < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << r << dendl;
return r;
s->info.args.remove("Version");
int r = forward_iam_request_to_master(this, site, s->user->get_info(),
- post_body, parser, s->info, y);
+ post_body, parser, s->info, s->err, y);
if (r < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << r << dendl;
return r;
s->info.args.remove("Version");
int r = forward_iam_request_to_master(this, site, s->user->get_info(),
- post_body, parser, s->info, y);
+ post_body, parser, s->info, s->err, y);
if (r < 0) {
ldpp_dout(this, 20) << "ERROR: forward_iam_request_to_master failed with error code: " << r << dendl;
return r;