diff options
| author | Alexander Smirnov <[email protected]> | 2025-02-18 00:51:31 +0000 |
|---|---|---|
| committer | Alexander Smirnov <[email protected]> | 2025-02-18 00:51:31 +0000 |
| commit | d46fe70ab3363efe215e4c7b142fb2e25e772f8e (patch) | |
| tree | 1931cba78c3a24456f8f0dca6d80ba3cbc147acd /yt/cpp | |
| parent | c25b7ee30559ef027fbc049354af1debffb6c1c6 (diff) | |
| parent | 8fe93946bc369873a7ffbb3a7403463aa80e3117 (diff) | |
Merge branch 'rightlib' into merge-libs-250218-0050
Diffstat (limited to 'yt/cpp')
| -rw-r--r-- | yt/cpp/mapreduce/common/retry_lib.cpp | 11 | ||||
| -rw-r--r-- | yt/cpp/mapreduce/http/http.cpp | 11 | ||||
| -rw-r--r-- | yt/cpp/mapreduce/http/http_client.cpp | 13 | ||||
| -rw-r--r-- | yt/cpp/mapreduce/interface/errors.cpp | 18 | ||||
| -rw-r--r-- | yt/cpp/mapreduce/interface/errors.h | 3 |
5 files changed, 39 insertions, 17 deletions
diff --git a/yt/cpp/mapreduce/common/retry_lib.cpp b/yt/cpp/mapreduce/common/retry_lib.cpp index 826247cb573..53216bd3f86 100644 --- a/yt/cpp/mapreduce/common/retry_lib.cpp +++ b/yt/cpp/mapreduce/common/retry_lib.cpp @@ -203,16 +203,11 @@ static bool IsRetriableChunkError(const TSet<int>& codes) static TMaybe<TDuration> TryGetBackoffDuration(const TErrorResponse& errorResponse, const TConfigPtr& config) { - int httpCode = errorResponse.GetHttpCode(); - if (httpCode / 100 != 4 && !errorResponse.IsFromTrailers()) { - return config->RetryInterval; - } - auto allCodes = errorResponse.GetError().GetAllErrorCodes(); using namespace NClusterErrorCodes; - if (httpCode == 429 - || allCodes.count(NSecurityClient::RequestQueueSizeLimitExceeded) - || allCodes.count(NRpc::RequestQueueSizeLimitExceeded)) + + if (allCodes.count(NSecurityClient::RequestQueueSizeLimitExceeded) || + allCodes.count(NRpc::RequestQueueSizeLimitExceeded)) { // request rate limit exceeded return config->RateLimitExceededRetryInterval; diff --git a/yt/cpp/mapreduce/http/http.cpp b/yt/cpp/mapreduce/http/http.cpp index 765a96f0420..4bddeab86d1 100644 --- a/yt/cpp/mapreduce/http/http.cpp +++ b/yt/cpp/mapreduce/http/http.cpp @@ -768,21 +768,21 @@ THttpResponse::THttpResponse( ErrorResponse_ = TErrorResponse(HttpCode_, Context_.RequestId); - auto logAndSetError = [&] (const TString& rawError) { + auto logAndSetError = [&] (int code, const TString& rawError) { YT_LOG_ERROR("RSP %v - HTTP %v - %v", Context_.RequestId, HttpCode_, rawError.data()); - ErrorResponse_->SetRawError(rawError); + ErrorResponse_->SetError(TYtError(code, rawError)); }; switch (HttpCode_) { case 429: - logAndSetError("request rate limit exceeded"); + logAndSetError(NClusterErrorCodes::NSecurityClient::RequestQueueSizeLimitExceeded, "request rate limit exceeded"); break; case 500: - logAndSetError(::TStringBuilder() << "internal error in proxy " << Context_.HostName); + logAndSetError(NClusterErrorCodes::NRpc::Unavailable, ::TStringBuilder() << "internal error in proxy " << Context_.HostName); break; default: { @@ -803,6 +803,9 @@ THttpResponse::THttpResponse( if (auto parsedResponse = ParseError(HttpInput_->Headers())) { ErrorResponse_ = parsedResponse.GetRef(); + if (HttpCode_ == 503) { + ExtendGenericError(*ErrorResponse_, NClusterErrorCodes::NBus::TransportError, "transport error"); + } } else { ErrorResponse_->SetRawError( errorString + " - X-YT-Error is missing in headers"); diff --git a/yt/cpp/mapreduce/http/http_client.cpp b/yt/cpp/mapreduce/http/http_client.cpp index 7e9d761c3cf..34be58daab6 100644 --- a/yt/cpp/mapreduce/http/http_client.cpp +++ b/yt/cpp/mapreduce/http/http_client.cpp @@ -7,6 +7,7 @@ #include <yt/cpp/mapreduce/interface/config.h> +#include <yt/cpp/mapreduce/interface/error_codes.h> #include <yt/cpp/mapreduce/interface/logging/yt_log.h> #include <yt/yt/core/concurrency/thread_pool_poller.h> @@ -42,21 +43,22 @@ TMaybe<TErrorResponse> GetErrorResponse(const TString& hostName, const TString& TErrorResponse errorResponse(static_cast<int>(httpCode), requestId); - auto logAndSetError = [&] (const TString& rawError) { + auto logAndSetError = [&] (int code, const TString& rawError) { YT_LOG_ERROR("RSP %v - HTTP %v - %v", requestId, httpCode, rawError.data()); - errorResponse.SetRawError(rawError); + errorResponse.SetError(TYtError(code, rawError)); }; + switch (httpCode) { case NHttp::EStatusCode::TooManyRequests: - logAndSetError("request rate limit exceeded"); + logAndSetError(NClusterErrorCodes::NSecurityClient::RequestQueueSizeLimitExceeded, "request rate limit exceeded"); break; case NHttp::EStatusCode::InternalServerError: - logAndSetError("internal error in proxy " + hostName); + logAndSetError(NClusterErrorCodes::NRpc::Unavailable, "internal error in proxy " + hostName); break; default: { @@ -80,6 +82,9 @@ TMaybe<TErrorResponse> GetErrorResponse(const TString& hostName, const TString& if (errorResponse.IsOk()) { return Nothing(); } + if (httpCode == NHttp::EStatusCode::ServiceUnavailable) { + ExtendGenericError(errorResponse, NClusterErrorCodes::NBus::TransportError, "transport error"); + } return errorResponse; } diff --git a/yt/cpp/mapreduce/interface/errors.cpp b/yt/cpp/mapreduce/interface/errors.cpp index 42c7466dcb5..fcc23fb3acb 100644 --- a/yt/cpp/mapreduce/interface/errors.cpp +++ b/yt/cpp/mapreduce/interface/errors.cpp @@ -332,7 +332,7 @@ bool TErrorResponse::IsFromTrailers() const bool TErrorResponse::IsTransportError() const { - return HttpCode_ == 503; + return Error_.ContainsErrorCode(NClusterErrorCodes::NBus::TransportError); } TString TErrorResponse::GetRequestId() const @@ -355,6 +355,22 @@ bool TErrorResponse::IsAccessDenied() const return Error_.ContainsErrorCode(NClusterErrorCodes::NSecurityClient::AuthorizationError); } +bool TErrorResponse::IsUnauthorized() const +{ + const auto allCodes = Error_.GetAllErrorCodes(); + for (auto code : { + NClusterErrorCodes::NRpc::AuthenticationError, + NClusterErrorCodes::NRpc::InvalidCsrfToken, + NClusterErrorCodes::NRpc::InvalidCredentials, + NClusterErrorCodes::NSecurityClient::AuthenticationError, + }) { + if (allCodes.contains(code)) { + return true; + } + } + return false; +} + bool TErrorResponse::IsConcurrentTransactionLockConflict() const { return Error_.ContainsErrorCode(NClusterErrorCodes::NCypressClient::ConcurrentTransactionLockConflict); diff --git a/yt/cpp/mapreduce/interface/errors.h b/yt/cpp/mapreduce/interface/errors.h index 749b294f0fd..a008ff07b87 100644 --- a/yt/cpp/mapreduce/interface/errors.h +++ b/yt/cpp/mapreduce/interface/errors.h @@ -182,6 +182,9 @@ public: /// Check if error was caused by lack of permissions to execute request. bool IsAccessDenied() const; + /// Check if error was caused by authorization issues. + bool IsUnauthorized() const; + /// Check if error was caused by failure to lock object because of another transaction is holding lock. bool IsConcurrentTransactionLockConflict() const; |
