From 2680772d4b1d9a7bed303959a5a1c746997a9bfe Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Thu, 28 Jan 2021 13:38:12 -0800 Subject: [PATCH] Don't mark remotes online when shutting down (#11368) Shutting down will mark remotes online when the shutdown has started since the context is canceled. For example: ``` API: SYSTEM() Time: 16:21:31 CET 01/28/2021 DeploymentID: 313b0065-c5a1-4aa3-9233-07223e77a730 Error: Storage resources are insufficient for the write operation .minio.sys/tmp/ced455c4-3d27-4bdd-95fc-b4707a179b8a/fd934ef3-8fc8-4330-abc1-f039fbbb9700/part.1 (cmd.InsufficientWriteQuorum) 1: d:\minio\minio\cmd\data-usage.go:56:cmd.storeDataUsageInBackend() Exiting on signal: INTERRUPT Client http://127.0.0.1:9002/minio/lock/v5 online Client http://127.0.0.1:9002/minio/storage/data/distxl/s2/d3/v24 online Client http://127.0.0.1:9002/minio/storage/data/distxl/s2/d2/v24 online Client http://127.0.0.1:9002/minio/storage/data/distxl/s2/d1/v24 online Client http://127.0.0.1:9002/minio/peer/v12 online Client http://127.0.0.1:9002/minio/storage/data/distxl/s2/d4/v24 online ``` Use a fresh context for health checks. --- cmd/lock-rest-client.go | 2 +- cmd/peer-rest-client.go | 2 +- cmd/storage-rest-client.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/lock-rest-client.go b/cmd/lock-rest-client.go index ca3ed977a..c3eecc5f4 100644 --- a/cmd/lock-rest-client.go +++ b/cmd/lock-rest-client.go @@ -161,7 +161,7 @@ func newlockRESTClient(endpoint Endpoint) *lockRESTClient { healthClient := rest.NewClient(serverURL, globalInternodeTransport, newAuthToken) healthClient.ExpectTimeouts = true restClient.HealthCheckFn = func() bool { - ctx, cancel := context.WithTimeout(GlobalContext, restClient.HealthCheckTimeout) + ctx, cancel := context.WithTimeout(context.Background(), restClient.HealthCheckTimeout) defer cancel() respBody, err := healthClient.Call(ctx, lockRESTMethodHealth, nil, nil, -1) xhttp.DrainBody(respBody) diff --git a/cmd/peer-rest-client.go b/cmd/peer-rest-client.go index 0cd35e107..fdb836052 100644 --- a/cmd/peer-rest-client.go +++ b/cmd/peer-rest-client.go @@ -881,7 +881,7 @@ func newPeerRESTClient(peer *xnet.Host) *peerRESTClient { // Construct a new health function. restClient.HealthCheckFn = func() bool { - ctx, cancel := context.WithTimeout(GlobalContext, restClient.HealthCheckTimeout) + ctx, cancel := context.WithTimeout(context.Background(), restClient.HealthCheckTimeout) defer cancel() respBody, err := healthClient.Call(ctx, peerRESTMethodHealth, nil, nil, -1) xhttp.DrainBody(respBody) diff --git a/cmd/storage-rest-client.go b/cmd/storage-rest-client.go index a78ebc0b8..2417507de 100644 --- a/cmd/storage-rest-client.go +++ b/cmd/storage-rest-client.go @@ -662,7 +662,7 @@ func newStorageRESTClient(endpoint Endpoint, healthcheck bool) *storageRESTClien healthClient := rest.NewClient(serverURL, globalInternodeTransport, newAuthToken) healthClient.ExpectTimeouts = true restClient.HealthCheckFn = func() bool { - ctx, cancel := context.WithTimeout(GlobalContext, restClient.HealthCheckTimeout) + ctx, cancel := context.WithTimeout(context.Background(), restClient.HealthCheckTimeout) defer cancel() respBody, err := healthClient.Call(ctx, storageRESTMethodHealth, nil, nil, -1) xhttp.DrainBody(respBody)