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 {
47 applyDeprecatedNodeProfile(hostname, np.RailsAPI, &cluster.Services.RailsAPI)
48 applyDeprecatedNodeProfile(hostname, np.Controller, &cluster.Services.Controller)
49 applyDeprecatedNodeProfile(hostname, np.DispatchCloud, &cluster.Services.DispatchCloud)
52 if dst, n := &cluster.API.MaxItemsPerResponse, dcluster.RequestLimits.MaxItemsPerResponse; n != nil && *n != *dst {
53 log.Warnf("overriding Clusters.%s.API.MaxItemsPerResponse with deprecated config RequestLimits.MultiClusterRequestConcurrency = %d", id, *n)
56 if dst, n := &cluster.API.MaxRequestAmplification, dcluster.RequestLimits.MultiClusterRequestConcurrency; n != nil && *n != *dst {
57 log.Warnf("overriding Clusters.%s.API.MaxRequestAmplification with deprecated config RequestLimits.MultiClusterRequestConcurrency = %d", id, *n)
60 cfg.Clusters[id] = cluster
65 func applyDeprecatedNodeProfile(hostname string, ssi arvados.SystemServiceInstance, svc *arvados.Service) {
70 if svc.InternalURLs == nil {
71 svc.InternalURLs = map[arvados.URL]arvados.ServiceInstance{}
77 if strings.HasPrefix(host, ":") {
78 host = hostname + host
80 svc.InternalURLs[arvados.URL{Scheme: scheme, Host: host}] = arvados.ServiceInstance{}