server-info: Change Error type to string (#4346)

Golang std error type doesn't marshal/unmarshal with json. So errors
are not actually being sent when a client calls ServerInfo() API.
This commit is contained in:
Anis Elleuch 2017-05-15 16:28:47 +02:00 committed by Harshavardhana
parent 87fb911d38
commit 465274cd21
3 changed files with 6 additions and 6 deletions

View File

@ -241,9 +241,9 @@ type ServerInfoData struct {
// ServerInfo holds server information result of one node // ServerInfo holds server information result of one node
type ServerInfo struct { type ServerInfo struct {
Error error Error string `json:"error"`
Addr string Addr string `json:"addr"`
Data *ServerInfoData Data *ServerInfoData `json:"data"`
} }
// ServerInfoHandler - GET /?info // ServerInfoHandler - GET /?info
@ -276,7 +276,7 @@ func (adminAPI adminAPIHandlers) ServerInfoHandler(w http.ResponseWriter, r *htt
serverInfoData, err := peer.cmdRunner.ServerInfoData() serverInfoData, err := peer.cmdRunner.ServerInfoData()
if err != nil { if err != nil {
errorIf(err, "Unable to get server info from %s.", peer.addr) errorIf(err, "Unable to get server info from %s.", peer.addr)
reply[idx].Error = err reply[idx].Error = err.Error()
return return
} }

View File

@ -1314,7 +1314,7 @@ func TestAdminServerInfo(t *testing.T) {
if len(serverInfo.Addr) == 0 { if len(serverInfo.Addr) == 0 {
t.Error("Expected server address to be non empty") t.Error("Expected server address to be non empty")
} }
if serverInfo.Error != nil { if serverInfo.Error != "" {
t.Errorf("Unexpected error = %v\n", serverInfo.Error) t.Errorf("Unexpected error = %v\n", serverInfo.Error)
} }
if serverInfo.Data.StorageInfo.Free == 0 { if serverInfo.Data.StorageInfo.Free == 0 {

View File

@ -84,7 +84,7 @@ type ServerInfoData struct {
// ServerInfo holds server information result of one node // ServerInfo holds server information result of one node
type ServerInfo struct { type ServerInfo struct {
Error error `json:"error"` Error string `json:"error"`
Addr string `json:"addr"` Addr string `json:"addr"`
Data *ServerInfoData `json:"data"` Data *ServerInfoData `json:"data"`
} }