From 18d9a20ff6ee3958a4d514ea9ca6606de30a07f7 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 17 Oct 2018 17:25:16 -0700 Subject: [PATCH] Enable admin users API on gateway (#6659) This is only enabled when etcd is enabled, healing is only enabled for erasure coded backend. --- cmd/admin-router.go | 15 ++++++++++----- cmd/gateway-main.go | 13 ++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/cmd/admin-router.go b/cmd/admin-router.go index 7cd505d12..4657bbccb 100644 --- a/cmd/admin-router.go +++ b/cmd/admin-router.go @@ -53,12 +53,14 @@ func registerAdminRouter(router *mux.Router) { // Info operations adminV1Router.Methods(http.MethodGet).Path("/info").HandlerFunc(httpTraceAll(adminAPI.ServerInfoHandler)) - /// Heal operations + if globalIsDistXL || globalIsXL { + /// Heal operations - // Heal processing endpoint. - adminV1Router.Methods(http.MethodPost).Path("/heal/").HandlerFunc(httpTraceAll(adminAPI.HealHandler)) - adminV1Router.Methods(http.MethodPost).Path("/heal/{bucket}").HandlerFunc(httpTraceAll(adminAPI.HealHandler)) - adminV1Router.Methods(http.MethodPost).Path("/heal/{bucket}/{prefix:.*}").HandlerFunc(httpTraceAll(adminAPI.HealHandler)) + // Heal processing endpoint. + adminV1Router.Methods(http.MethodPost).Path("/heal/").HandlerFunc(httpTraceAll(adminAPI.HealHandler)) + adminV1Router.Methods(http.MethodPost).Path("/heal/{bucket}").HandlerFunc(httpTraceAll(adminAPI.HealHandler)) + adminV1Router.Methods(http.MethodPost).Path("/heal/{bucket}/{prefix:.*}").HandlerFunc(httpTraceAll(adminAPI.HealHandler)) + } // Profiling operations adminV1Router.Methods(http.MethodPost).Path("/profiling/start").HandlerFunc(httpTraceAll(adminAPI.StartProfilingHandler)). @@ -102,4 +104,7 @@ func registerAdminRouter(router *mux.Router) { // List policies adminV1Router.Methods(http.MethodGet).Path("/list-canned-policies").HandlerFunc(httpTraceHdrs(adminAPI.ListCannedPolicies)) + + // If none of the routes match. + adminV1Router.NotFoundHandler = http.HandlerFunc(httpTraceHdrs(notFoundHandler)) } diff --git a/cmd/gateway-main.go b/cmd/gateway-main.go index 372a74d4a..b7336a5e3 100644 --- a/cmd/gateway-main.go +++ b/cmd/gateway-main.go @@ -169,6 +169,14 @@ func StartGateway(ctx *cli.Context, gw Gateway) { router := mux.NewRouter().SkipClean(true) + if globalEtcdClient != nil { + // Enable STS router if etcd is enabled. + registerSTSRouter(router) + + // Enable admin router if etcd is enabled. + registerAdminRouter(router) + } + // Add healthcheck router registerHealthCheckRouter(router) @@ -180,11 +188,6 @@ func StartGateway(ctx *cli.Context, gw Gateway) { logger.FatalIf(registerWebRouter(router), "Unable to configure web browser") } - // Enable STS router if etcd is enabled. - if globalEtcdClient != nil { - registerSTSRouter(router) - } - // Add API router. registerAPIRouter(router)