Keep ServiceV1 admin stop/restart API and mark as deprecated (#18932)

This commit is contained in:
Anis Eleuch 2024-01-31 21:20:33 +01:00 committed by GitHub
parent 0ae4915a93
commit 24ecc44bac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -430,6 +430,8 @@ func (a adminAPIHandlers) ServerUpdateHandler(w http.ResponseWriter, r *http.Req
// ServiceHandler - POST /minio/admin/v3/service?action={action} // ServiceHandler - POST /minio/admin/v3/service?action={action}
// ---------- // ----------
// Supports following actions: // Supports following actions:
// - restart (restarts all the MinIO instances in a setup)
// - stop (stops all the MinIO instances in a setup)
// - freeze (freezes all incoming S3 API calls) // - freeze (freezes all incoming S3 API calls)
// - unfreeze (unfreezes previously frozen S3 API calls) // - unfreeze (unfreezes previously frozen S3 API calls)
func (a adminAPIHandlers) ServiceHandler(w http.ResponseWriter, r *http.Request) { func (a adminAPIHandlers) ServiceHandler(w http.ResponseWriter, r *http.Request) {
@ -439,25 +441,30 @@ func (a adminAPIHandlers) ServiceHandler(w http.ResponseWriter, r *http.Request)
action := vars["action"] action := vars["action"]
var serviceSig serviceSignal var serviceSig serviceSignal
switch act := madmin.ServiceAction(action); act { switch madmin.ServiceAction(action) {
case madmin.ServiceActionRestart:
serviceSig = serviceRestart
case madmin.ServiceActionStop:
serviceSig = serviceStop
case madmin.ServiceActionFreeze: case madmin.ServiceActionFreeze:
serviceSig = serviceFreeze serviceSig = serviceFreeze
case madmin.ServiceActionUnfreeze: case madmin.ServiceActionUnfreeze:
serviceSig = serviceUnFreeze serviceSig = serviceUnFreeze
default: default:
process := act == madmin.ServiceActionRestart || act == madmin.ServiceActionStop
if process {
apiErr := errorCodes.ToAPIErr(ErrMalformedPOSTRequest)
apiErr.Description = "process actions are not supported via this API anymore, please upgrade 'mc' or madmin-go to use ServiceV2() API"
writeErrorResponseJSON(ctx, w, apiErr, r.URL)
return
}
logger.LogIf(ctx, fmt.Errorf("Unrecognized service action %s requested", action), logger.Application) logger.LogIf(ctx, fmt.Errorf("Unrecognized service action %s requested", action), logger.Application)
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrMalformedPOSTRequest), r.URL) writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrMalformedPOSTRequest), r.URL)
return return
} }
objectAPI, _ := validateAdminReq(ctx, w, r, policy.ServiceFreezeAdminAction) var objectAPI ObjectLayer
switch serviceSig {
case serviceRestart:
objectAPI, _ = validateAdminReq(ctx, w, r, policy.ServiceRestartAdminAction)
case serviceStop:
objectAPI, _ = validateAdminReq(ctx, w, r, policy.ServiceStopAdminAction)
case serviceFreeze, serviceUnFreeze:
objectAPI, _ = validateAdminReq(ctx, w, r, policy.ServiceFreezeAdminAction)
}
if objectAPI == nil { if objectAPI == nil {
return return
} }
@ -478,6 +485,8 @@ func (a adminAPIHandlers) ServiceHandler(w http.ResponseWriter, r *http.Request)
freezeServices() freezeServices()
case serviceUnFreeze: case serviceUnFreeze:
unfreezeServices() unfreezeServices()
case serviceRestart, serviceStop:
globalServiceSignalCh <- serviceSig
} }
} }