7162: Update datamanager code to ask for all non-proxy typed keep services and fail...
authorradhika <radhika@curoverse.com>
Tue, 22 Sep 2015 14:38:26 +0000 (10:38 -0400)
committerradhika <radhika@curoverse.com>
Tue, 22 Sep 2015 14:38:26 +0000 (10:38 -0400)
This needs to be enhanced when we are ready to support keep servers with other service types sub as blob storage.

services/datamanager/keep/keep.go

index 5b855dc61ea1e3df5ea45c2567bbbdb57776664c..86c2b089aa13088d8da8f524ab21dcc8dafc9641 100644 (file)
@@ -23,10 +23,11 @@ import (
 
 // ServerAddress struct
 type ServerAddress struct {
-       SSL  bool   `json:service_ssl_flag`
-       Host string `json:"service_host"`
-       Port int    `json:"service_port"`
-       UUID string `json:"uuid"`
+       SSL         bool   `json:service_ssl_flag`
+       Host        string `json:"service_host"`
+       Port        int    `json:"service_port"`
+       UUID        string `json:"uuid"`
+       ServiceType string `json:"service_type"`
 }
 
 // BlockInfo is info about a particular block returned by the server
@@ -104,7 +105,7 @@ func GetKeepServersAndSummarize(params GetKeepServersParams) (results ReadServer
 // GetKeepServers from api server
 func GetKeepServers(params GetKeepServersParams) (results ReadServers) {
        sdkParams := arvadosclient.Dict{
-               "filters": [][]string{[]string{"service_type", "=", "disk"}},
+               "filters": [][]string{[]string{"service_type", "!=", "proxy"}},
        }
        if params.Limit > 0 {
                sdkParams["limit"] = params.Limit
@@ -118,6 +119,14 @@ func GetKeepServers(params GetKeepServersParams) (results ReadServers) {
                        fmt.Sprintf("Error requesting keep disks from API server: %v", err))
        }
 
+       // Currently, only "disk" types are supported. Stop if any other service types are found.
+       for _, server := range sdkResponse.KeepServers {
+               if server.ServiceType != "disk" {
+                       loggerutil.FatalWithMessage(params.Logger,
+                               fmt.Sprintf("Unsupported service type %q found for: %v", server.ServiceType, server))
+               }
+       }
+
        if params.Logger != nil {
                params.Logger.Update(func(p map[string]interface{}, e map[string]interface{}) {
                        keepInfo := logger.GetOrCreateMap(p, "keep_info")