Add madmin package context support (#9172)

This is to improve responsiveness for all
admin API operations and allowing callers
to cancel any on-going admin operations,
if they happen to be waiting too long.
This commit is contained in:
Harshavardhana
2020-03-20 15:00:44 -07:00
committed by GitHub
parent 1ffa983a9d
commit ae654831aa
47 changed files with 398 additions and 213 deletions
+8 -5
View File
@@ -18,6 +18,7 @@
package madmin
import (
"context"
"encoding/json"
"io/ioutil"
"net/http"
@@ -32,15 +33,17 @@ type ServerUpdateStatus struct {
// ServerUpdate - updates and restarts the MinIO cluster to latest version.
// optionally takes an input URL to specify a custom update binary link
func (adm *AdminClient) ServerUpdate(updateURL string) (us ServerUpdateStatus, err error) {
func (adm *AdminClient) ServerUpdate(ctx context.Context, updateURL string) (us ServerUpdateStatus, err error) {
queryValues := url.Values{}
queryValues.Set("updateURL", updateURL)
// Request API to Restart server
resp, err := adm.executeMethod("POST", requestData{
relPath: adminAPIPrefix + "/update",
queryValues: queryValues,
})
resp, err := adm.executeMethod(ctx,
http.MethodPost, requestData{
relPath: adminAPIPrefix + "/update",
queryValues: queryValues,
},
)
defer closeResponse(resp)
if err != nil {
return us, err