Update datamanager to use a configured supported service type instead of hardcoding "disk" type.
// replicasPerService is 1 for disks; unknown or unlimited otherwise
this.replicasPerService = 1
- this.Using_proxy = false
for _, service := range list.Items {
scheme := "http"
listed[url] = true
localRoots[service.Uuid] = url
- if service.SvcType == "proxy" {
- this.Using_proxy = true
- }
-
if service.ReadOnly == false {
writableLocalRoots[service.Uuid] = url
if service.SvcType != "disk" {
type KeepClient struct {
Arvados *arvadosclient.ArvadosClient
Want_replicas int
- Using_proxy bool
localRoots *map[string]string
writableLocalRoots *map[string]string
gatewayRoots *map[string]string
kc := &KeepClient{
Arvados: arv,
Want_replicas: defaultReplicationLevel,
- Using_proxy: false,
Client: &http.Client{Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: arv.ApiInsecure}}},
Retries: 2,
kc, _ := MakeKeepClient(&arv)
kc.Want_replicas = 2
- kc.Using_proxy = true
arv.ApiToken = "abc123"
localRoots := make(map[string]string)
writableLocalRoots := make(map[string]string)
kc, _ := MakeKeepClient(&arv)
kc.Want_replicas = 3
- kc.Using_proxy = true
arv.ApiToken = "abc123"
localRoots := make(map[string]string)
writableLocalRoots := make(map[string]string)
for _, root := range kc.LocalRoots() {
c.Check(root, Matches, "http://localhost:\\d+")
}
- c.Assert(kc.LocalRoots()[blobKeepService["uuid"].(string)], NotNil)
+ c.Assert(kc.LocalRoots()[blobKeepService["uuid"].(string)], Not(Equals), "")
// verify kc.GatewayRoots
c.Check(len(kc.GatewayRoots()), Equals, 3)
for _, root := range kc.GatewayRoots() {
c.Check(root, Matches, "http://localhost:\\d+")
}
- c.Assert(kc.GatewayRoots()[blobKeepService["uuid"].(string)], NotNil)
+ c.Assert(kc.GatewayRoots()[blobKeepService["uuid"].(string)], Not(Equals), "")
// verify kc.WritableLocalRoots
c.Check(len(kc.WritableLocalRoots()), Equals, 3)
for _, root := range kc.WritableLocalRoots() {
c.Check(root, Matches, "http://localhost:\\d+")
}
- c.Assert(kc.WritableLocalRoots()[blobKeepService["uuid"].(string)], NotNil)
+ c.Assert(kc.WritableLocalRoots()[blobKeepService["uuid"].(string)], Not(Equals), "")
c.Assert(kc.replicasPerService, Equals, 0)
c.Assert(kc.foundNonDiskSvc, Equals, true)
keepClient = &keepclient.KeepClient{
Arvados: &arv,
Want_replicas: 2,
- Using_proxy: true,
Client: &http.Client{},
}
"bufio"
"encoding/json"
"errors"
+ "flag"
"fmt"
"git.curoverse.com/arvados.git/sdk/go/arvadosclient"
"git.curoverse.com/arvados.git/sdk/go/blockdigest"
KeepServers []ServerAddress `json:"items"`
}
+var serviceType string
+
+func init() {
+ flag.StringVar(&serviceType,
+ "service-type",
+ "disk",
+ "Supported keepservice type. Default is disk.")
+}
+
// String
// TODO(misha): Change this to include the UUID as well.
func (s ServerAddress) String() string {
}
// Currently, only "disk" types are supported. Stop if any other service types are found.
+ foundSupportedServieType := false
for _, server := range sdkResponse.KeepServers {
- if server.ServiceType != "disk" {
- return results, fmt.Errorf("Unsupported service type %q found for: %v", server.ServiceType, server)
+ if server.ServiceType == serviceType {
+ foundSupportedServieType = true
+ } else {
+ log.Printf("Ignore unsupported service type: %v", server.ServiceType)
}
}
+ if !foundSupportedServieType {
+ return results, fmt.Errorf("Found no keepservices with the supported type %v", serviceType)
+ }
+
if params.Logger != nil {
params.Logger.Update(func(p map[string]interface{}, e map[string]interface{}) {
keepInfo := logger.GetOrCreateMap(p, "keep_info")
}
func (s *KeepSuite) TestGetKeepServers_UnsupportedServiceType(c *C) {
- testGetKeepServersFromAPI(c, APITestData{1, "notadisk", 200}, "Unsupported service type")
+ testGetKeepServersFromAPI(c, APITestData{1, "notadisk", 200}, "Found no keepservices with the supported type disk")
}
func (s *KeepSuite) TestGetKeepServers_ReceivedTooFewServers(c *C) {
}
kc.SetServiceRoots(sr, sr, sr)
kc.Arvados.External = true
- kc.Using_proxy = true
return kc
}
defer closeListener()
hash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
- for _, f := range []func()error {
+ for _, f := range []func() error{
func() error {
_, _, err := kc.Ask(hash)
return err
keepClient := &keepclient.KeepClient{
Arvados: nil,
Want_replicas: 1,
- Using_proxy: true,
Client: &http.Client{},
}
keepClient = &keepclient.KeepClient{
Arvados: &arv,
Want_replicas: 1,
- Using_proxy: true,
Client: &http.Client{},
}