@@ -83,9 +83,6 @@ TokenEngine::get_from_keystone(const DoutPrefixProvider* dpp,
8383 validate.set_url (url);
8484
8585 int ret = validate.process (y);
86- if (ret < 0 ) {
87- throw ret;
88- }
8986
9087 /* NULL terminate for debug output. */
9188 token_body_bl.append (static_cast <char >(0 ));
@@ -104,6 +101,10 @@ TokenEngine::get_from_keystone(const DoutPrefixProvider* dpp,
104101 << validate.get_http_status () << dendl;
105102 return boost::none;
106103 }
104+ // throw any other http or connection errors
105+ if (ret < 0 ) {
106+ throw ret;
107+ }
107108
108109 ldpp_dout (dpp, 20 ) << " received response status=" << validate.get_http_status ()
109110 << " , body=" << token_body_bl.c_str () << dendl;
@@ -443,11 +444,6 @@ EC2Engine::get_from_keystone(const DoutPrefixProvider* dpp, const std::string_vi
443444
444445 /* send request */
445446 ret = validate.process (y);
446- if (ret < 0 ) {
447- ldpp_dout (dpp, 2 ) << " s3 keystone: token validation ERROR: "
448- << token_body_bl.c_str () << dendl;
449- throw ret;
450- }
451447
452448 /* if the supplied signature is wrong, we will get 401 from Keystone */
453449 if (validate.get_http_status () ==
@@ -457,6 +453,12 @@ EC2Engine::get_from_keystone(const DoutPrefixProvider* dpp, const std::string_vi
457453 decltype (validate)::HTTP_STATUS_NOTFOUND) {
458454 return std::make_pair (boost::none, -ERR_INVALID_ACCESS_KEY);
459455 }
456+ // throw any other http or connection errors
457+ if (ret < 0 ) {
458+ ldpp_dout (dpp, 2 ) << " s3 keystone: token validation ERROR: "
459+ << token_body_bl.c_str () << dendl;
460+ throw ret;
461+ }
460462
461463 /* now parse response */
462464 rgw::keystone::TokenEnvelope token_envelope;
@@ -521,18 +523,19 @@ auto EC2Engine::get_secret_from_keystone(const DoutPrefixProvider* dpp,
521523
522524 /* send request */
523525 ret = secret.process (y);
526+
527+ /* if the supplied access key isn't found, we will get 404 from Keystone */
528+ if (secret.get_http_status () ==
529+ decltype (secret)::HTTP_STATUS_NOTFOUND) {
530+ return make_pair (boost::none, -ERR_INVALID_ACCESS_KEY);
531+ }
532+ // return any other http or connection errors
524533 if (ret < 0 ) {
525534 ldpp_dout (dpp, 2 ) << " s3 keystone: secret fetching error: "
526535 << token_body_bl.c_str () << dendl;
527536 return make_pair (boost::none, ret);
528537 }
529538
530- /* if the supplied signature is wrong, we will get 401 from Keystone */
531- if (secret.get_http_status () ==
532- decltype (secret)::HTTP_STATUS_NOTFOUND) {
533- return make_pair (boost::none, -EINVAL);
534- }
535-
536539 /* now parse response */
537540
538541 JSONParser parser;
0 commit comments