This is an automated email from the ASF dual-hosted git repository.
mgreber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push:
new 7f20a7fcd [rest] Return HTTP 503 for non-leader masters
7f20a7fcd is described below
commit 7f20a7fcd598581ea4a72ef6f5481df06e868cb2
Author: Gabriella Lotz <[email protected]>
AuthorDate: Fri Nov 21 11:54:04 2025 +0100
[rest] Return HTTP 503 for non-leader masters
Non-leader masters now return HTTP 503 (Service Unavailable) instead
of HTTP 500 (Internal Server Error) when handling REST API requests.
This change provides more semantically correct HTTP status codes:
- HTTP 500 suggests an internal malfunction or unexpected error
- HTTP 503 indicates the service exists but is temporarily unavailable
at this particular server instance
The non-leader master is functioning correctly; it simply cannot
service the request because it's not in the leader role. This is a
temporary condition that can change during leader elections, making
503 the appropriate status code.
Change-Id: I62fa177f93b40daae542000aff64b6b432e38467
Reviewed-on: http://gerrit.cloudera.org:8080/23702
Reviewed-by: Zoltan Chovan <[email protected]>
Reviewed-by: Marton Greber <[email protected]>
Tested-by: Marton Greber <[email protected]>
---
src/kudu/master/rest_catalog_path_handlers.cc | 2 +-
src/kudu/master/spnego_rest_catalog-test.cc | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/kudu/master/rest_catalog_path_handlers.cc
b/src/kudu/master/rest_catalog_path_handlers.cc
index 98a7cd4a3..e91b5cb27 100644
--- a/src/kudu/master/rest_catalog_path_handlers.cc
+++ b/src/kudu/master/rest_catalog_path_handlers.cc
@@ -92,7 +92,7 @@ static bool CheckIsInitializedAndIsLeader(JsonWriter& jw, //
NOLINT JsonWriter
}
if (!l.leader_status().ok()) {
RETURN_JSON_ERROR_VAL(
- jw, "Master is not the leader", status_code,
HttpStatusCode::InternalServerError, false);
+ jw, "Master is not the leader", status_code,
HttpStatusCode::ServiceUnavailable, false);
}
return true;
}
diff --git a/src/kudu/master/spnego_rest_catalog-test.cc
b/src/kudu/master/spnego_rest_catalog-test.cc
index 9696d5fb4..d19bd2b0d 100644
--- a/src/kudu/master/spnego_rest_catalog-test.cc
+++ b/src/kudu/master/spnego_rest_catalog-test.cc
@@ -437,7 +437,7 @@ TEST_F(MultiMasterSpnegoTest,
TestRequestsToFormerLeaderAfterElection) {
c.set_auth(CurlAuthType::SPNEGO);
Status s = c.FetchURL(Substitute("http://$0$1", original_leader_addr,
path), &buf);
- ASSERT_STR_CONTAINS(s.ToString(), "HTTP 500");
+ ASSERT_STR_CONTAINS(s.ToString(), "HTTP 503");
ASSERT_STR_CONTAINS(buf.ToString(), "\"error\"");
ASSERT_STR_CONTAINS(buf.ToString(), "Master is not the leader");
}