Add more context to rpc version mismatch errors (#8271)

Fixes #5665
This commit is contained in:
Praveen raj Mani
2019-10-03 12:38:12 +05:30
committed by Harshavardhana
parent 83066f953c
commit e48005ddc7
7 changed files with 36 additions and 4 deletions

View File

@@ -385,6 +385,21 @@ func notFoundHandler(w http.ResponseWriter, r *http.Request) {
writeErrorResponse(context.Background(), w, errorCodes.ToAPIErr(ErrMethodNotAllowed), r.URL, guessIsBrowserReq(r))
}
// If the API version does not match with current version.
func versionMismatchHandler(w http.ResponseWriter, r *http.Request) {
path := r.URL.Path
switch {
case strings.HasPrefix(path, minioReservedBucketPath+"/peer/"):
writeVersionMismatchResponse(r.Context(), w, errorCodes.ToAPIErr(ErrInvalidAPIVersion), r.URL, false)
case strings.HasPrefix(path, minioReservedBucketPath+"/storage/"):
writeVersionMismatchResponse(r.Context(), w, errorCodes.ToAPIErr(ErrInvalidAPIVersion), r.URL, false)
case strings.HasPrefix(path, minioReservedBucketPath+"/lock/"):
writeVersionMismatchResponse(r.Context(), w, errorCodes.ToAPIErr(ErrInvalidAPIVersion), r.URL, false)
default:
writeVersionMismatchResponse(r.Context(), w, errorCodes.ToAPIErr(ErrInvalidAPIVersion), r.URL, true)
}
}
// gets host name for current node
func getHostName(r *http.Request) (hostName string) {
if globalIsDistXL {