Deprecate and remove service stop API. (#3578)

Fixes #3570
This commit is contained in:
Harshavardhana
2017-01-14 14:48:52 -08:00
committed by GitHub
parent 2959c104b3
commit caecd75a2a
10 changed files with 5 additions and 156 deletions

View File

@@ -50,24 +50,6 @@ func (adminAPI adminAPIHandlers) ServiceStatusHandler(w http.ResponseWriter, r *
writeSuccessResponseJSON(w, jsonBytes)
}
// ServiceStopHandler - POST /?service
// HTTP header x-minio-operation: stop
// ----------
// Stops minio server gracefully. In a distributed setup, stops all the
// servers in the cluster.
func (adminAPI adminAPIHandlers) ServiceStopHandler(w http.ResponseWriter, r *http.Request) {
adminAPIErr := checkRequestAuthType(r, "", "", "")
if adminAPIErr != ErrNone {
writeErrorResponse(w, adminAPIErr, r.URL)
return
}
// Reply to the client before stopping minio server.
w.WriteHeader(http.StatusOK)
sendServiceCmd(globalAdminPeers, serviceStop)
}
// ServiceRestartHandler - POST /?service
// HTTP header x-minio-operation: restart
// ----------

View File

@@ -56,8 +56,6 @@ func (c cmdType) apiMethod() string {
switch c {
case statusCmd:
return "GET"
case stopCmd:
return "POST"
case restartCmd:
return "POST"
}
@@ -70,8 +68,6 @@ func (c cmdType) toServiceSignal() serviceSignal {
switch c {
case statusCmd:
return serviceStatus
case stopCmd:
return serviceStop
case restartCmd:
return serviceRestart
}
@@ -187,11 +183,6 @@ func TestServiceStatusHandler(t *testing.T) {
testServicesCmdHandler(statusCmd, t)
}
// Test for service stop management REST API.
func TestServiceStopHandler(t *testing.T) {
testServicesCmdHandler(stopCmd, t)
}
// Test for service restart management REST API.
func TestServiceRestartHandler(t *testing.T) {
testServicesCmdHandler(restartCmd, t)

View File

@@ -33,8 +33,7 @@ func registerAdminRouter(mux *router.Router) {
// Service status
adminRouter.Methods("GET").Queries("service", "").Headers(minioAdminOpHeader, "status").HandlerFunc(adminAPI.ServiceStatusHandler)
// Service stop
adminRouter.Methods("POST").Queries("service", "").Headers(minioAdminOpHeader, "stop").HandlerFunc(adminAPI.ServiceStopHandler)
// Service restart
adminRouter.Methods("POST").Queries("service", "").Headers(minioAdminOpHeader, "restart").HandlerFunc(adminAPI.ServiceRestartHandler)

View File

@@ -36,18 +36,10 @@ type remoteAdminClient struct {
// adminCmdRunner - abstracts local and remote execution of admin
// commands like service stop and service restart.
type adminCmdRunner interface {
Stop() error
Restart() error
ListLocks(bucket, prefix string, relTime time.Duration) ([]VolumeLockInfo, error)
}
// Stop - Sends a message over channel to the go-routine responsible
// for stopping the process.
func (lc localAdminClient) Stop() error {
globalServiceSignalCh <- serviceStop
return nil
}
// Restart - Sends a message over channel to the go-routine
// responsible for restarting the process.
func (lc localAdminClient) Restart() error {
@@ -60,13 +52,6 @@ func (lc localAdminClient) ListLocks(bucket, prefix string, relTime time.Duratio
return listLocksInfo(bucket, prefix, relTime), nil
}
// Stop - Sends stop command to remote server via RPC.
func (rc remoteAdminClient) Stop() error {
args := AuthRPCArgs{}
reply := AuthRPCReply{}
return rc.Call("Admin.Shutdown", &args, &reply)
}
// Restart - Sends restart command to remote server via RPC.
func (rc remoteAdminClient) Restart() error {
args := AuthRPCArgs{}
@@ -88,7 +73,7 @@ func (rc remoteAdminClient) ListLocks(bucket, prefix string, relTime time.Durati
return reply.volLocks, nil
}
// adminPeer - represents an entity that implements Stop and Restart methods.
// adminPeer - represents an entity that implements Restart methods.
type adminPeer struct {
addr string
cmdRunner adminCmdRunner
@@ -146,18 +131,16 @@ func initGlobalAdminPeers(eps []*url.URL) {
globalAdminPeers = makeAdminPeers(eps)
}
// invokeServiceCmd - Invoke Stop/Restart command.
// invokeServiceCmd - Invoke Restart command.
func invokeServiceCmd(cp adminPeer, cmd serviceSignal) (err error) {
switch cmd {
case serviceStop:
err = cp.cmdRunner.Stop()
case serviceRestart:
err = cp.cmdRunner.Restart()
}
return err
}
// sendServiceCmd - Invoke Stop/Restart command on remote peers
// sendServiceCmd - Invoke Restart command on remote peers
// adminPeer followed by on the local peer.
func sendServiceCmd(cps adminPeers, cmd serviceSignal) {
// Send service command like stop or restart to all remote nodes and finally run on local node.

View File

@@ -45,16 +45,6 @@ type ListLocksReply struct {
volLocks []VolumeLockInfo
}
// Shutdown - Shutdown this instance of minio server.
func (s *adminCmd) Shutdown(args *AuthRPCArgs, reply *AuthRPCReply) error {
if err := args.IsAuthenticated(); err != nil {
return err
}
globalServiceSignalCh <- serviceStop
return nil
}
// Restart - Restart this instance of minio server.
func (s *adminCmd) Restart(args *AuthRPCArgs, reply *AuthRPCReply) error {
if err := args.IsAuthenticated(); err != nil {

View File

@@ -47,17 +47,13 @@ func testAdminCmd(cmd cmdType, t *testing.T) {
}
go func() {
// mocking signal receiver
// A test signal receiver
<-globalServiceSignalCh
}()
ga := AuthRPCArgs{AuthToken: reply.AuthToken, RequestTime: time.Now().UTC()}
genReply := AuthRPCReply{}
switch cmd {
case stopCmd:
if err = adminServer.Shutdown(&ga, &genReply); err != nil {
t.Errorf("stopCmd: Expected: <nil>, got: %v", err)
}
case restartCmd:
if err = adminServer.Restart(&ga, &genReply); err != nil {
t.Errorf("restartCmd: Expected: <nil>, got: %v", err)
@@ -65,10 +61,6 @@ func testAdminCmd(cmd cmdType, t *testing.T) {
}
}
func TestAdminShutdown(t *testing.T) {
testAdminCmd(stopCmd, t)
}
func TestAdminRestart(t *testing.T) {
testAdminCmd(restartCmd, t)
}