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]nodeProfile
26 type deprecatedConfig struct {
27 Clusters map[string]deprCluster
30 type nodeProfile struct {
31 Controller systemServiceInstance `json:"arvados-controller"`
32 Health systemServiceInstance `json:"arvados-health"`
33 Keepbalance systemServiceInstance `json:"keep-balance"`
34 Keepproxy systemServiceInstance `json:"keepproxy"`
35 Keepstore systemServiceInstance `json:"keepstore"`
36 Keepweb systemServiceInstance `json:"keep-web"`
37 Nodemanager systemServiceInstance `json:"arvados-node-manager"`
38 DispatchCloud systemServiceInstance `json:"arvados-dispatch-cloud"`
39 RailsAPI systemServiceInstance `json:"arvados-api-server"`
40 Websocket systemServiceInstance `json:"arvados-ws"`
41 Workbench1 systemServiceInstance `json:"arvados-workbench"`
44 type systemServiceInstance struct {
50 func applyDeprecatedConfig(cfg *arvados.Config, configdata []byte, log logger) error {
51 var dc deprecatedConfig
52 err := yaml.Unmarshal(configdata, &dc)
56 hostname, err := os.Hostname()
60 for id, dcluster := range dc.Clusters {
61 cluster, ok := cfg.Clusters[id]
63 return fmt.Errorf("can't load legacy config %q that is not present in current config", id)
65 for name, np := range dcluster.NodeProfiles {
66 if name == "*" || name == os.Getenv("ARVADOS_NODE_PROFILE") || name == hostname {
68 } else if log != nil {
69 log.Warnf("overriding Clusters.%s.Services using Clusters.%s.NodeProfiles.%s (guessing %q is a hostname)", id, id, name, name)
71 applyDeprecatedNodeProfile(name, np.RailsAPI, &cluster.Services.RailsAPI)
72 applyDeprecatedNodeProfile(name, np.Controller, &cluster.Services.Controller)
73 applyDeprecatedNodeProfile(name, np.DispatchCloud, &cluster.Services.DispatchCloud)
75 if dst, n := &cluster.API.MaxItemsPerResponse, dcluster.RequestLimits.MaxItemsPerResponse; n != nil && *n != *dst {
78 if dst, n := &cluster.API.MaxRequestAmplification, dcluster.RequestLimits.MultiClusterRequestConcurrency; n != nil && *n != *dst {
81 cfg.Clusters[id] = cluster
86 func applyDeprecatedNodeProfile(hostname string, ssi systemServiceInstance, svc *arvados.Service) {
91 if svc.InternalURLs == nil {
92 svc.InternalURLs = map[arvados.URL]arvados.ServiceInstance{}
98 if strings.HasPrefix(host, ":") {
99 host = hostname + host
101 svc.InternalURLs[arvados.URL{Scheme: scheme, Host: host}] = arvados.ServiceInstance{}