Skip to content

Commit

Permalink
Deprecate and remove service stop API. (minio#3578)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshavardhana authored Jan 14, 2017
1 parent 2959c10 commit caecd75
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 156 deletions.
18 changes: 0 additions & 18 deletions cmd/admin-handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
// ----------
Expand Down
9 changes: 0 additions & 9 deletions cmd/admin-handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ func (c cmdType) apiMethod() string {
switch c {
case statusCmd:
return "GET"
case stopCmd:
return "POST"
case restartCmd:
return "POST"
}
Expand All @@ -70,8 +68,6 @@ func (c cmdType) toServiceSignal() serviceSignal {
switch c {
case statusCmd:
return serviceStatus
case stopCmd:
return serviceStop
case restartCmd:
return serviceRestart
}
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions cmd/admin-router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
23 changes: 3 additions & 20 deletions cmd/admin-rpc-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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{}
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 0 additions & 10 deletions cmd/admin-rpc-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 1 addition & 9 deletions cmd/admin-rpc-server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,20 @@ 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)
}
}
}

func TestAdminShutdown(t *testing.T) {
testAdminCmd(stopCmd, t)
}

func TestAdminRestart(t *testing.T) {
testAdminCmd(restartCmd, t)
}
18 changes: 0 additions & 18 deletions pkg/madmin/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func main() {
| Service operations|LockInfo operations|Healing operations|
|:---|:---|:---|
|[`ServiceStatus`](#ServiceStatus)| | |
|[`ServiceStop`](#ServiceStop)| | |
|[`ServiceRestart`](#ServiceRestart)| | |

## 1. Constructor
Expand Down Expand Up @@ -98,23 +97,6 @@ Fetch service status, replies disk space used, backend type and total disks offl

```

<a name="ServiceStop"></a>
### ServiceStop() (error)
If successful shuts down the running minio service, for distributed setup stops all remote minio servers.

__Example__


```go

st, err := madmClnt.ServiceStop()
if err != nil {
log.Fatalln(err)
}
log.Printf("Succes")

```

<a name="ServiceRestart"></a>
### ServiceRestart() (error)
If successful restarts the running minio service, for distributed setup restarts all remote minio servers.
Expand Down
2 changes: 0 additions & 2 deletions pkg/madmin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,13 @@ go run service-status.go
### API Reference : Service Operations
* [`ServiceStatus`](./API.md#ServiceStatus)
* [`ServiceStop`](./API.md#ServiceStop)
* [`ServiceRestart`](./API.md#ServiceRestart)
## Full Examples
#### Full Examples : Service Operations
* [service-status.go](https://github.com/minio/minio/blob/master/pkg/madmin/examples/service-status.go)
* [service-stop.go](https://github.com/minio/minio/blob/master/pkg/madmin/examples/service-stop.go)
* [service-restart.go](https://github.com/minio/minio/blob/master/pkg/madmin/examples/service-restart.go)
## Contribute
Expand Down
44 changes: 0 additions & 44 deletions pkg/madmin/examples/service-stop.go

This file was deleted.

24 changes: 0 additions & 24 deletions pkg/madmin/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,30 +95,6 @@ func (adm *AdminClient) ServiceStatus() (ServiceStatusMetadata, error) {
return storageInfo, nil
}

// ServiceStop - Call Service Stop Management API to stop a specified Minio server
func (adm *AdminClient) ServiceStop() error {
//
reqData := requestData{}
reqData.queryValues = make(url.Values)
reqData.queryValues.Set("service", "")
reqData.customHeaders = make(http.Header)
reqData.customHeaders.Set(minioAdminOpHeader, "stop")

// Execute GET on bucket to list objects.
resp, err := adm.executeMethod("POST", reqData)

defer closeResponse(resp)
if err != nil {
return err
}

if resp.StatusCode != http.StatusOK {
return errors.New("Got HTTP Status: " + resp.Status)
}

return nil
}

// ServiceRestart - Call Service Restart API to restart a specified Minio server
func (adm *AdminClient) ServiceRestart() error {
//
Expand Down

0 comments on commit caecd75

Please sign in to comment.