add correct HostId instead of deploymentId for error responses (#16686)

This commit is contained in:
Harshavardhana 2023-02-22 02:11:09 -08:00 committed by GitHub
parent 663a0b7783
commit 5c98223c89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 7 deletions

View File

@ -1013,7 +1013,7 @@ func (a adminAPIHandlers) HealHandler(w http.ResponseWriter, r *http.Request) {
if hr.errBody == "" { if hr.errBody == "" {
errorRespJSON = encodeResponseJSON(getAPIErrorResponse(ctx, hr.apiErr, errorRespJSON = encodeResponseJSON(getAPIErrorResponse(ctx, hr.apiErr,
r.URL.Path, w.Header().Get(xhttp.AmzRequestID), r.URL.Path, w.Header().Get(xhttp.AmzRequestID),
globalDeploymentID)) w.Header().Get(xhttp.AmzRequestHostID)))
} else { } else {
errorRespJSON = encodeResponseJSON(APIErrorResponse{ errorRespJSON = encodeResponseJSON(APIErrorResponse{
Code: hr.apiErr.Code, Code: hr.apiErr.Code,
@ -2302,7 +2302,7 @@ func (a adminAPIHandlers) HealthInfoHandler(w http.ResponseWriter, r *http.Reque
errResp := func(err error) { errResp := func(err error) {
errorResponse := getAPIErrorResponse(ctx, toAdminAPIErr(ctx, err), r.URL.String(), 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) encodedErrorResponse := encodeResponse(errorResponse)
healthInfo.Error = string(encodedErrorResponse) healthInfo.Error = string(encodedErrorResponse)
logger.LogIf(ctx, enc.Encode(healthInfo)) logger.LogIf(ctx, enc.Encode(healthInfo))

View File

@ -875,7 +875,7 @@ func writeErrorResponse(ctx context.Context, w http.ResponseWriter, err APIError
// Generate error response. // Generate error response.
errorResponse := getAPIErrorResponse(ctx, err, reqURL.Path, 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) encodedErrorResponse := encodeResponse(errorResponse)
writeResponse(w, err.HTTPStatusCode, encodedErrorResponse, mimeXML) writeResponse(w, err.HTTPStatusCode, encodedErrorResponse, mimeXML)
} }
@ -893,7 +893,7 @@ func writeErrorResponseString(ctx context.Context, w http.ResponseWriter, err AP
// useful for admin APIs. // useful for admin APIs.
func writeErrorResponseJSON(ctx context.Context, w http.ResponseWriter, err APIError, reqURL *url.URL) { func writeErrorResponseJSON(ctx context.Context, w http.ResponseWriter, err APIError, reqURL *url.URL) {
// Generate error response. // 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) encodedErrorResponse := encodeResponseJSON(errorResponse)
writeResponse(w, err.HTTPStatusCode, encodedErrorResponse, mimeJSON) writeResponse(w, err.HTTPStatusCode, encodedErrorResponse, mimeJSON)
} }

View File

@ -552,7 +552,7 @@ func addCustomHeaders(h http.Handler) http.Handler {
// Set custom headers such as x-amz-request-id for each request. // Set custom headers such as x-amz-request-id for each request.
w.Header().Set(xhttp.AmzRequestID, mustGetRequestID(UTCNow())) w.Header().Set(xhttp.AmzRequestID, mustGetRequestID(UTCNow()))
if globalLocalNodeName != "" { if globalLocalNodeName != "" {
w.Header().Set(xhttp.AmzRequestNodeID, globalLocalNodeNameHex) w.Header().Set(xhttp.AmzRequestHostID, globalLocalNodeNameHex)
} }
h.ServeHTTP(xhttp.NewResponseRecorder(w), r) h.ServeHTTP(xhttp.NewResponseRecorder(w), r)
}) })

View File

@ -242,7 +242,7 @@ func extractRespElements(w http.ResponseWriter) map[string]string {
} }
return map[string]string{ return map[string]string{
"requestId": w.Header().Get(xhttp.AmzRequestID), "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), "content-length": w.Header().Get(xhttp.ContentLength),
// Add more fields here. // Add more fields here.
} }

View File

@ -146,7 +146,7 @@ const (
// Response request id. // Response request id.
AmzRequestID = "x-amz-request-id" AmzRequestID = "x-amz-request-id"
AmzRequestNodeID = "x-amz-id-2" AmzRequestHostID = "x-amz-id-2"
// Deployment id. // Deployment id.
MinioDeploymentID = "x-minio-deployment-id" MinioDeploymentID = "x-minio-deployment-id"