mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
Simplify the messaging for internode versions (#14103)
provide a cleaner message instead of cryptic logs, also provide the relevant link on how to do recommended way to upgrade.
This commit is contained in:
parent
a2fd8caa69
commit
7aec38a73e
@ -429,69 +429,8 @@ func extractAPIVersion(r *http.Request) string {
|
|||||||
return "unknown"
|
return "unknown"
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateUnexpectedRPCMsg(rpcPath, subsystem string, expectedVersion, gotVersion string) string {
|
|
||||||
var reason string
|
|
||||||
switch {
|
|
||||||
case expectedVersion != gotVersion:
|
|
||||||
reason = fmt.Sprintf("Server expects '%s' API version '%s', instead found '%s'", subsystem, expectedVersion, gotVersion)
|
|
||||||
default:
|
|
||||||
reason = fmt.Sprintf("Unexpected RPC call at this path '%s'", rpcPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
return fmt.Sprintf("%s - *rolling upgrade is not allowed* - please make sure all servers are running the same MinIO version (%s)", reason, ReleaseTag)
|
|
||||||
}
|
|
||||||
|
|
||||||
func methodNotAllowedHandler(api string) func(w http.ResponseWriter, r *http.Request) {
|
func methodNotAllowedHandler(api string) func(w http.ResponseWriter, r *http.Request) {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return errorResponseHandler
|
||||||
if r.Method == http.MethodOptions {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
version := extractAPIVersion(r)
|
|
||||||
switch {
|
|
||||||
case strings.HasPrefix(r.URL.Path, peerRESTPrefix):
|
|
||||||
desc := generateUnexpectedRPCMsg(r.URL.Path, "peer", peerRESTVersion, version)
|
|
||||||
writeErrorResponseString(r.Context(), w, APIError{
|
|
||||||
Code: "XMinioPeerVersionMismatch",
|
|
||||||
Description: desc,
|
|
||||||
HTTPStatusCode: http.StatusUpgradeRequired,
|
|
||||||
}, r.URL)
|
|
||||||
case strings.HasPrefix(r.URL.Path, storageRESTPrefix):
|
|
||||||
desc := generateUnexpectedRPCMsg(r.URL.Path, "storage", storageRESTVersion, version)
|
|
||||||
writeErrorResponseString(r.Context(), w, APIError{
|
|
||||||
Code: "XMinioStorageVersionMismatch",
|
|
||||||
Description: desc,
|
|
||||||
HTTPStatusCode: http.StatusUpgradeRequired,
|
|
||||||
}, r.URL)
|
|
||||||
case strings.HasPrefix(r.URL.Path, lockRESTPrefix):
|
|
||||||
desc := generateUnexpectedRPCMsg(r.URL.Path, "lock", lockRESTVersion, version)
|
|
||||||
writeErrorResponseString(r.Context(), w, APIError{
|
|
||||||
Code: "XMinioLockVersionMismatch",
|
|
||||||
Description: desc,
|
|
||||||
HTTPStatusCode: http.StatusUpgradeRequired,
|
|
||||||
}, r.URL)
|
|
||||||
case strings.HasPrefix(r.URL.Path, adminPathPrefix):
|
|
||||||
var desc string
|
|
||||||
if version == "v1" {
|
|
||||||
desc = fmt.Sprintf("Server expects client requests with 'admin' API version '%s', found '%s', please upgrade the client to latest releases", madmin.AdminAPIVersion, version)
|
|
||||||
} else if version == madmin.AdminAPIVersion {
|
|
||||||
desc = fmt.Sprintf("This 'admin' API is not supported by server in '%s'", getMinioMode())
|
|
||||||
} else {
|
|
||||||
desc = fmt.Sprintf("Unexpected client 'admin' API version found '%s', expected '%s', please downgrade the client to older releases", version, madmin.AdminAPIVersion)
|
|
||||||
}
|
|
||||||
writeErrorResponseJSON(r.Context(), w, APIError{
|
|
||||||
Code: "XMinioAdminVersionMismatch",
|
|
||||||
Description: desc,
|
|
||||||
HTTPStatusCode: http.StatusUpgradeRequired,
|
|
||||||
}, r.URL)
|
|
||||||
default:
|
|
||||||
writeErrorResponse(r.Context(), w, APIError{
|
|
||||||
Code: "BadRequest",
|
|
||||||
Description: fmt.Sprintf("An error occurred when parsing the HTTP request %s at '%s'",
|
|
||||||
r.Method, r.URL.Path),
|
|
||||||
HTTPStatusCode: http.StatusBadRequest,
|
|
||||||
}, r.URL)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If none of the http routes match respond with appropriate errors
|
// If none of the http routes match respond with appropriate errors
|
||||||
@ -499,24 +438,21 @@ func errorResponseHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
if r.Method == http.MethodOptions {
|
if r.Method == http.MethodOptions {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
version := extractAPIVersion(r)
|
desc := "Do not upgrade one server at a time - please follow the recommended guidelines mentioned here https://github.com/minio/minio#upgrading-minio for your environment"
|
||||||
switch {
|
switch {
|
||||||
case strings.HasPrefix(r.URL.Path, peerRESTPrefix):
|
case strings.HasPrefix(r.URL.Path, peerRESTPrefix):
|
||||||
desc := fmt.Sprintf("Server expects 'peer' API version '%s', instead found '%s' - *rolling upgrade is not allowed* - please make sure all servers are running the same MinIO version (%s)", peerRESTVersion, version, ReleaseTag)
|
|
||||||
writeErrorResponseString(r.Context(), w, APIError{
|
writeErrorResponseString(r.Context(), w, APIError{
|
||||||
Code: "XMinioPeerVersionMismatch",
|
Code: "XMinioPeerVersionMismatch",
|
||||||
Description: desc,
|
Description: desc,
|
||||||
HTTPStatusCode: http.StatusUpgradeRequired,
|
HTTPStatusCode: http.StatusUpgradeRequired,
|
||||||
}, r.URL)
|
}, r.URL)
|
||||||
case strings.HasPrefix(r.URL.Path, storageRESTPrefix):
|
case strings.HasPrefix(r.URL.Path, storageRESTPrefix):
|
||||||
desc := fmt.Sprintf("Server expects 'storage' API version '%s', instead found '%s' - *rolling upgrade is not allowed* - please make sure all servers are running the same MinIO version (%s)", storageRESTVersion, version, ReleaseTag)
|
|
||||||
writeErrorResponseString(r.Context(), w, APIError{
|
writeErrorResponseString(r.Context(), w, APIError{
|
||||||
Code: "XMinioStorageVersionMismatch",
|
Code: "XMinioStorageVersionMismatch",
|
||||||
Description: desc,
|
Description: desc,
|
||||||
HTTPStatusCode: http.StatusUpgradeRequired,
|
HTTPStatusCode: http.StatusUpgradeRequired,
|
||||||
}, r.URL)
|
}, r.URL)
|
||||||
case strings.HasPrefix(r.URL.Path, lockRESTPrefix):
|
case strings.HasPrefix(r.URL.Path, lockRESTPrefix):
|
||||||
desc := fmt.Sprintf("Server expects 'lock' API version '%s', instead found '%s' - *rolling upgrade is not allowed* - please make sure all servers are running the same MinIO version (%s)", lockRESTVersion, version, ReleaseTag)
|
|
||||||
writeErrorResponseString(r.Context(), w, APIError{
|
writeErrorResponseString(r.Context(), w, APIError{
|
||||||
Code: "XMinioLockVersionMismatch",
|
Code: "XMinioLockVersionMismatch",
|
||||||
Description: desc,
|
Description: desc,
|
||||||
@ -524,11 +460,13 @@ func errorResponseHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}, r.URL)
|
}, r.URL)
|
||||||
case strings.HasPrefix(r.URL.Path, adminPathPrefix):
|
case strings.HasPrefix(r.URL.Path, adminPathPrefix):
|
||||||
var desc string
|
var desc string
|
||||||
if version == "v1" {
|
version := extractAPIVersion(r)
|
||||||
|
switch version {
|
||||||
|
case "v1", madmin.AdminAPIVersionV2:
|
||||||
desc = fmt.Sprintf("Server expects client requests with 'admin' API version '%s', found '%s', please upgrade the client to latest releases", madmin.AdminAPIVersion, version)
|
desc = fmt.Sprintf("Server expects client requests with 'admin' API version '%s', found '%s', please upgrade the client to latest releases", madmin.AdminAPIVersion, version)
|
||||||
} else if version == madmin.AdminAPIVersion {
|
case madmin.AdminAPIVersion:
|
||||||
desc = fmt.Sprintf("This 'admin' API is not supported by server in '%s'", getMinioMode())
|
desc = fmt.Sprintf("This 'admin' API is not supported by server in '%s'", getMinioMode())
|
||||||
} else {
|
default:
|
||||||
desc = fmt.Sprintf("Unexpected client 'admin' API version found '%s', expected '%s', please downgrade the client to older releases", version, madmin.AdminAPIVersion)
|
desc = fmt.Sprintf("Unexpected client 'admin' API version found '%s', expected '%s', please downgrade the client to older releases", version, madmin.AdminAPIVersion)
|
||||||
}
|
}
|
||||||
writeErrorResponseJSON(r.Context(), w, APIError{
|
writeErrorResponseJSON(r.Context(), w, APIError{
|
||||||
|
Loading…
Reference in New Issue
Block a user