mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
add correct HostId instead of deploymentId for error responses (#16686)
This commit is contained in:
parent
663a0b7783
commit
5c98223c89
@ -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))
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
})
|
})
|
||||||
|
@ -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.
|
||||||
}
|
}
|
||||||
|
@ -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"
|
||||||
|
Loading…
Reference in New Issue
Block a user