Fix adding bucket forwarder handler in server mode (#14288)

MinIO configuration is loaded after the initialization of the server
handlers, which will miss the initialization of the bucket forwarder
handler.

Though the federation is deprecated, let's fix this for the time being.
This commit is contained in:
Anis Elleuch 2022-02-10 17:49:36 +01:00 committed by GitHub
parent 661ea57907
commit 71bab74148
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View File

@ -371,7 +371,8 @@ func setRequestValidityHandler(h http.Handler) http.Handler {
// is obtained from centralized etcd configuration service. // is obtained from centralized etcd configuration service.
func setBucketForwardingHandler(h http.Handler) http.Handler { func setBucketForwardingHandler(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if guessIsHealthCheckReq(r) || guessIsMetricsReq(r) || if globalDNSConfig == nil || !globalBucketFederation ||
guessIsHealthCheckReq(r) || guessIsMetricsReq(r) ||
guessIsRPCReq(r) || guessIsLoginSTSReq(r) || isAdminReq(r) { guessIsRPCReq(r) || guessIsLoginSTSReq(r) || isAdminReq(r) {
h.ServeHTTP(w, r) h.ServeHTTP(w, r)
return return

View File

@ -58,6 +58,8 @@ var globalHandlers = []mux.MiddlewareFunc{
setRequestValidityHandler, setRequestValidityHandler,
// set x-amz-request-id header. // set x-amz-request-id header.
addCustomHeaders, addCustomHeaders,
// Add bucket forwarding handler
setBucketForwardingHandler,
// Add new handlers here. // Add new handlers here.
} }
@ -87,10 +89,6 @@ func configureServerHandler(endpointServerPools EndpointServerPools) (http.Handl
// Add API router // Add API router
registerAPIRouter(router) registerAPIRouter(router)
// Enable bucket forwarding handler only if bucket federation is enabled.
if globalDNSConfig != nil && globalBucketFederation {
globalHandlers = append(globalHandlers, setBucketForwardingHandler)
}
router.Use(globalHandlers...) router.Use(globalHandlers...)
return router, nil return router, nil