From 53011606a5d934364f7bfdb4181a5529dc738df7 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Tue, 2 Apr 2019 20:25:34 +0100 Subject: [PATCH] Show 401 unauthorized msg when nodes are started with different creds (#7433) Before this commit, nodes wait indefinitely without showing any indicate error message when a node is started with different access and secret keys. This PR will show '401 Unauthorized' in this case. --- cmd/rest/client.go | 5 ++++- cmd/storage-rest-client.go | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/rest/client.go b/cmd/rest/client.go index 5afc2d462..670a06b61 100644 --- a/cmd/rest/client.go +++ b/cmd/rest/client.go @@ -66,7 +66,10 @@ func (c *Client) Call(method string, values url.Values, body io.Reader, length i if err != nil { return nil, err } - return nil, errors.New(string(b)) + if len(b) > 0 { + return nil, errors.New(string(b)) + } + return nil, errors.New(resp.Status) } return resp.Body, nil } diff --git a/cmd/storage-rest-client.go b/cmd/storage-rest-client.go index 97a4ca817..07f759ce9 100644 --- a/cmd/storage-rest-client.go +++ b/cmd/storage-rest-client.go @@ -353,6 +353,14 @@ func (client *storageRESTClient) RenameFile(srcVolume, srcPath, dstVolume, dstPa // Gets peer storage server's instanceID - to be used with every REST call for validation. func (client *storageRESTClient) getInstanceID() (err error) { + // getInstanceID() does not use storageRESTClient.call() + // function so we need to update lastError field here. + defer func() { + if err != nil { + client.lastError = err + } + }() + respBody, err := client.restClient.Call(storageRESTMethodGetInstanceID, nil, nil, -1) if err != nil { return err