From 5c98223c89f91061d13e80a8123527d2f1e3bb1e Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 22 Feb 2023 02:11:09 -0800 Subject: [PATCH] add correct HostId instead of deploymentId for error responses (#16686) --- cmd/admin-handlers.go | 4 ++-- cmd/api-response.go | 4 ++-- cmd/generic-handlers.go | 2 +- cmd/handler-utils.go | 2 +- internal/http/headers.go | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/admin-handlers.go b/cmd/admin-handlers.go index 3d047ceda..70b2d45cb 100644 --- a/cmd/admin-handlers.go +++ b/cmd/admin-handlers.go @@ -1013,7 +1013,7 @@ func (a adminAPIHandlers) HealHandler(w http.ResponseWriter, r *http.Request) { if hr.errBody == "" { errorRespJSON = encodeResponseJSON(getAPIErrorResponse(ctx, hr.apiErr, r.URL.Path, w.Header().Get(xhttp.AmzRequestID), - globalDeploymentID)) + w.Header().Get(xhttp.AmzRequestHostID))) } else { errorRespJSON = encodeResponseJSON(APIErrorResponse{ Code: hr.apiErr.Code, @@ -2302,7 +2302,7 @@ func (a adminAPIHandlers) HealthInfoHandler(w http.ResponseWriter, r *http.Reque errResp := func(err error) { errorResponse := getAPIErrorResponse(ctx, toAdminAPIErr(ctx, err), r.URL.String(), - w.Header().Get(xhttp.AmzRequestID), globalDeploymentID) + w.Header().Get(xhttp.AmzRequestID), w.Header().Get(xhttp.AmzRequestHostID)) encodedErrorResponse := encodeResponse(errorResponse) healthInfo.Error = string(encodedErrorResponse) logger.LogIf(ctx, enc.Encode(healthInfo)) diff --git a/cmd/api-response.go b/cmd/api-response.go index 866ebdf8a..3e87983ef 100644 --- a/cmd/api-response.go +++ b/cmd/api-response.go @@ -875,7 +875,7 @@ func writeErrorResponse(ctx context.Context, w http.ResponseWriter, err APIError // Generate error response. errorResponse := getAPIErrorResponse(ctx, err, reqURL.Path, - w.Header().Get(xhttp.AmzRequestID), globalDeploymentID) + w.Header().Get(xhttp.AmzRequestID), w.Header().Get(xhttp.AmzRequestHostID)) encodedErrorResponse := encodeResponse(errorResponse) writeResponse(w, err.HTTPStatusCode, encodedErrorResponse, mimeXML) } @@ -893,7 +893,7 @@ func writeErrorResponseString(ctx context.Context, w http.ResponseWriter, err AP // useful for admin APIs. func writeErrorResponseJSON(ctx context.Context, w http.ResponseWriter, err APIError, reqURL *url.URL) { // Generate error response. - errorResponse := getAPIErrorResponse(ctx, err, reqURL.Path, w.Header().Get(xhttp.AmzRequestID), globalDeploymentID) + errorResponse := getAPIErrorResponse(ctx, err, reqURL.Path, w.Header().Get(xhttp.AmzRequestID), w.Header().Get(xhttp.AmzRequestHostID)) encodedErrorResponse := encodeResponseJSON(errorResponse) writeResponse(w, err.HTTPStatusCode, encodedErrorResponse, mimeJSON) } diff --git a/cmd/generic-handlers.go b/cmd/generic-handlers.go index 0604ca94d..70abff453 100644 --- a/cmd/generic-handlers.go +++ b/cmd/generic-handlers.go @@ -552,7 +552,7 @@ func addCustomHeaders(h http.Handler) http.Handler { // Set custom headers such as x-amz-request-id for each request. w.Header().Set(xhttp.AmzRequestID, mustGetRequestID(UTCNow())) if globalLocalNodeName != "" { - w.Header().Set(xhttp.AmzRequestNodeID, globalLocalNodeNameHex) + w.Header().Set(xhttp.AmzRequestHostID, globalLocalNodeNameHex) } h.ServeHTTP(xhttp.NewResponseRecorder(w), r) }) diff --git a/cmd/handler-utils.go b/cmd/handler-utils.go index 99f74a13e..076407be2 100644 --- a/cmd/handler-utils.go +++ b/cmd/handler-utils.go @@ -242,7 +242,7 @@ func extractRespElements(w http.ResponseWriter) map[string]string { } return map[string]string{ "requestId": w.Header().Get(xhttp.AmzRequestID), - "nodeId": w.Header().Get(xhttp.AmzRequestNodeID), + "nodeId": w.Header().Get(xhttp.AmzRequestHostID), "content-length": w.Header().Get(xhttp.ContentLength), // Add more fields here. } diff --git a/internal/http/headers.go b/internal/http/headers.go index f40b670fa..11844d553 100644 --- a/internal/http/headers.go +++ b/internal/http/headers.go @@ -146,7 +146,7 @@ const ( // Response request id. AmzRequestID = "x-amz-request-id" - AmzRequestNodeID = "x-amz-id-2" + AmzRequestHostID = "x-amz-id-2" // Deployment id. MinioDeploymentID = "x-minio-deployment-id"