1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
12 "git.curoverse.com/arvados.git/sdk/go/arvados"
13 "github.com/ghodss/yaml"
16 type deprRequestLimits struct {
17 MaxItemsPerResponse *int
18 MultiClusterRequestConcurrency *int
21 type deprCluster struct {
22 RequestLimits deprRequestLimits
23 NodeProfiles map[string]arvados.NodeProfile
26 type deprecatedConfig struct {
27 Clusters map[string]deprCluster
30 func applyDeprecatedConfig(cfg *arvados.Config, configdata []byte, log logger) error {
31 var dc deprecatedConfig
32 err := yaml.Unmarshal(configdata, &dc)
36 hostname, err := os.Hostname()
40 for id, dcluster := range dc.Clusters {
41 cluster, ok := cfg.Clusters[id]
43 return fmt.Errorf("can't load legacy config %q that is not present in current config", id)
45 for name, np := range dcluster.NodeProfiles {
46 if name == "*" || name == os.Getenv("ARVADOS_NODE_PROFILE") || name == hostname {
48 } else if log != nil {
49 log.Warnf("overriding Clusters.%s.Services using Clusters.%s.NodeProfiles.%s (guessing %q is a hostname)", id, id, name, name)
51 applyDeprecatedNodeProfile(name, np.RailsAPI, &cluster.Services.RailsAPI)
52 applyDeprecatedNodeProfile(name, np.Controller, &cluster.Services.Controller)
53 applyDeprecatedNodeProfile(name, np.DispatchCloud, &cluster.Services.DispatchCloud)
55 if dst, n := &cluster.API.MaxItemsPerResponse, dcluster.RequestLimits.MaxItemsPerResponse; n != nil && *n != *dst {
58 if dst, n := &cluster.API.MaxRequestAmplification, dcluster.RequestLimits.MultiClusterRequestConcurrency; n != nil && *n != *dst {
61 cfg.Clusters[id] = cluster
66 func applyDeprecatedNodeProfile(hostname string, ssi arvados.SystemServiceInstance, svc *arvados.Service) {
71 if svc.InternalURLs == nil {
72 svc.InternalURLs = map[arvados.URL]arvados.ServiceInstance{}
78 if strings.HasPrefix(host, ":") {
79 host = hostname + host
81 svc.InternalURLs[arvados.URL{Scheme: scheme, Host: host}] = arvados.ServiceInstance{}