From 87cf51d5ab1f8a399cdb893143e2503b3bbc3928 Mon Sep 17 00:00:00 2001 From: kannappanr <30541348+kannappanr@users.noreply.github.com> Date: Wed, 20 Mar 2019 18:09:57 -0700 Subject: [PATCH] unused code: Remove LoadCredentials function (#7369) It is required to set the environment variable in the case of distributed minio. LoadCredentials is used to notify peers of the change and will not work if environment variable is set. so, this function will never be called. --- cmd/admin-handlers.go | 8 -------- cmd/notification.go | 13 ------------- cmd/peer-rest-client.go | 10 ---------- cmd/peer-rest-common.go | 1 - cmd/peer-rest-server.go | 30 ------------------------------ cmd/web-handlers.go | 17 ++++------------- 6 files changed, 4 insertions(+), 75 deletions(-) diff --git a/cmd/admin-handlers.go b/cmd/admin-handlers.go index 9d3d8ba41..4c76219a9 100644 --- a/cmd/admin-handlers.go +++ b/cmd/admin-handlers.go @@ -1480,14 +1480,6 @@ func (a adminAPIHandlers) UpdateAdminCredentialsHandler(w http.ResponseWriter, return } - // Notify all other Minio peers to update credentials - for _, nerr := range globalNotificationSys.LoadCredentials() { - if nerr.Err != nil { - logger.GetReqInfo(ctx).SetTags("peerAddress", nerr.Host.String()) - logger.LogIf(ctx, nerr.Err) - } - } - // Reply to the client before restarting minio server. writeSuccessResponseHeadersOnly(w) } diff --git a/cmd/notification.go b/cmd/notification.go index 7366370cc..0a72874bf 100644 --- a/cmd/notification.go +++ b/cmd/notification.go @@ -169,19 +169,6 @@ func (sys *NotificationSys) LoadUsers() []NotificationPeerErr { return ng.Wait() } -// LoadCredentials - calls LoadCredentials RPC call on all peers. -func (sys *NotificationSys) LoadCredentials() []NotificationPeerErr { - ng := WithNPeers(len(sys.peerClients)) - for idx, client := range sys.peerClients { - if client == nil { - continue - } - client := client - ng.Go(context.Background(), client.LoadCredentials, idx, *client.host) - } - return ng.Wait() -} - // StartProfiling - start profiling on remote peers, by initiating a remote RPC. func (sys *NotificationSys) StartProfiling(profiler string) []NotificationPeerErr { ng := WithNPeers(len(sys.peerClients)) diff --git a/cmd/peer-rest-client.go b/cmd/peer-rest-client.go index 260bbda01..523e352df 100644 --- a/cmd/peer-rest-client.go +++ b/cmd/peer-rest-client.go @@ -347,16 +347,6 @@ func (client *peerRESTClient) LoadUsers() (err error) { return nil } -// LoadCredentials - send load credentials command to peer nodes. -func (client *peerRESTClient) LoadCredentials() (err error) { - respBody, err := client.call(peerRESTMethodLoadCredentials, nil, nil, -1) - if err != nil { - return - } - defer http.DrainBody(respBody) - return nil -} - // SignalService - sends signal to peer nodes. func (client *peerRESTClient) SignalService(sig serviceSignal) error { values := make(url.Values) diff --git a/cmd/peer-rest-common.go b/cmd/peer-rest-common.go index 1c573525c..7c3c2e031 100644 --- a/cmd/peer-rest-common.go +++ b/cmd/peer-rest-common.go @@ -31,7 +31,6 @@ const ( peerRESTMethodLoadUsers = "loadusers" peerRESTMethodStartProfiling = "startprofiling" peerRESTMethodDownloadProfilingData = "downloadprofilingdata" - peerRESTMethodLoadCredentials = "loadcredentials" peerRESTMethodBucketPolicySet = "setbucketpolicy" peerRESTMethodBucketNotificationPut = "putbucketnotification" peerRESTMethodBucketNotificationListen = "listenbucketnotification" diff --git a/cmd/peer-rest-server.go b/cmd/peer-rest-server.go index 9f734d282..937099560 100644 --- a/cmd/peer-rest-server.go +++ b/cmd/peer-rest-server.go @@ -22,7 +22,6 @@ import ( "errors" "fmt" "net/http" - "path" "sort" "strings" "time" @@ -244,34 +243,6 @@ func (s *peerRESTServer) MemUsageInfoHandler(w http.ResponseWriter, r *http.Requ logger.LogIf(ctx, gob.NewEncoder(w).Encode(info)) } -// LoadCredentialsHandler - loads credentials. -func (s *peerRESTServer) LoadCredentialsHandler(w http.ResponseWriter, r *http.Request) { - if !s.IsValid(w, r) { - s.writeErrorResponse(w, errors.New("Invalid request")) - return - } - - // Construct path to config.json for the given bucket. - configFile := path.Join(bucketConfigPrefix, minioConfigFile) - transactionConfigFile := configFile + ".transaction" - - // As object layer's GetObject() and PutObject() take respective lock on minioMetaBucket - // and configFile, take a transaction lock to avoid race. - objLock := globalNSMutex.NewNSLock(minioMetaBucket, transactionConfigFile) - if err := objLock.GetRLock(globalOperationTimeout); err != nil { - s.writeErrorResponse(w, err) - return - } - objLock.RUnlock() - - if err := globalConfigSys.Load(newObjectLayerFn()); err != nil { - s.writeErrorResponse(w, err) - return - } - - w.(http.Flusher).Flush() -} - // DeleteBucketHandler - Delete notification and policies related to the bucket. func (s *peerRESTServer) DeleteBucketHandler(w http.ResponseWriter, r *http.Request) { if !s.IsValid(w, r) { @@ -609,7 +580,6 @@ func registerPeerRESTHandlers(router *mux.Router) { subrouter.Methods(http.MethodPost).Path("/" + peerRESTMethodStartProfiling).HandlerFunc(httpTraceAll(server.StartProfilingHandler)).Queries(restQueries(peerRESTProfiler)...) subrouter.Methods(http.MethodPost).Path("/" + peerRESTMethodDownloadProfilingData).HandlerFunc(httpTraceHdrs(server.DownloadProflingDataHandler)) - subrouter.Methods(http.MethodPost).Path("/" + peerRESTMethodLoadCredentials).HandlerFunc(httpTraceHdrs(server.LoadCredentialsHandler)) subrouter.Methods(http.MethodPost).Path("/" + peerRESTMethodTargetExists).HandlerFunc(httpTraceHdrs(server.TargetExistsHandler)).Queries(restQueries(peerRESTBucket)...) subrouter.Methods(http.MethodPost).Path("/" + peerRESTMethodSendEvent).HandlerFunc(httpTraceHdrs(server.SendEventHandler)).Queries(restQueries(peerRESTBucket)...) subrouter.Methods(http.MethodPost).Path("/" + peerRESTMethodBucketNotificationPut).HandlerFunc(httpTraceHdrs(server.PutBucketNotificationHandler)).Queries(restQueries(peerRESTBucket)...) diff --git a/cmd/web-handlers.go b/cmd/web-handlers.go index 67cbda433..267e8da4c 100644 --- a/cmd/web-handlers.go +++ b/cmd/web-handlers.go @@ -764,20 +764,11 @@ func (web *webAPIHandlers) SetAuth(r *http.Request, args *SetAuthArgs, reply *Se return toJSONError(err) } - if errs := globalNotificationSys.LoadCredentials(); len(errs) != 0 { - reply.PeerErrMsgs = make(map[string]string) - for _, nerr := range errs { - err = fmt.Errorf("Unable to update credentials on server %v: %v", nerr.Host, nerr.Err) - logger.LogIf(context.Background(), err) - reply.PeerErrMsgs[nerr.Host.String()] = err.Error() - } - } else { - reply.Token, err = authenticateWeb(creds.AccessKey, creds.SecretKey) - if err != nil { - return toJSONError(err) - } - reply.UIVersion = browser.UIVersion + reply.Token, err = authenticateWeb(creds.AccessKey, creds.SecretKey) + if err != nil { + return toJSONError(err) } + reply.UIVersion = browser.UIVersion return nil }