]> git.arvados.org - arvados.git/blob - lib/config/deprecated.go
Merge branch 'pr311-upgrade-thor'
[arvados.git] / lib / config / deprecated.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 package config
6
7 import (
8         "encoding/json"
9         "fmt"
10         "io/ioutil"
11         "net/url"
12         "os"
13         "strings"
14
15         "git.arvados.org/arvados.git/sdk/go/arvados"
16         "github.com/ghodss/yaml"
17 )
18
19 type deprRequestLimits struct {
20         MaxItemsPerResponse            *int
21         MultiClusterRequestConcurrency *int
22 }
23
24 type deprCUDAFeatures struct {
25         DriverVersion      string
26         HardwareCapability string
27         DeviceCount        int
28 }
29
30 type deprInstanceType struct {
31         CUDA *deprCUDAFeatures
32 }
33
34 type deprInstanceTypeMap map[string]deprInstanceType
35
36 type deprCluster struct {
37         RequestLimits deprRequestLimits
38         NodeProfiles  map[string]nodeProfile
39         Login         struct {
40                 GoogleClientID                *string
41                 GoogleClientSecret            *string
42                 GoogleAlternateEmailAddresses *bool
43                 ProviderAppID                 *string
44                 ProviderAppSecret             *string
45         }
46         Mail struct {
47                 SendUserSetupNotificationEmail *bool
48                 SupportEmailAddress            *string
49         }
50         Containers struct {
51                 LSF struct {
52                         BsubCUDAArguments *[]string
53                 }
54         }
55         InstanceTypes deprInstanceTypeMap
56 }
57
58 type deprecatedConfig struct {
59         Clusters map[string]deprCluster
60 }
61
62 type nodeProfile struct {
63         Controller    systemServiceInstance `json:"arvados-controller"`
64         Health        systemServiceInstance `json:"arvados-health"`
65         Keepbalance   systemServiceInstance `json:"keep-balance"`
66         Keepproxy     systemServiceInstance `json:"keepproxy"`
67         Keepstore     systemServiceInstance `json:"keepstore"`
68         Keepweb       systemServiceInstance `json:"keep-web"`
69         DispatchCloud systemServiceInstance `json:"arvados-dispatch-cloud"`
70         RailsAPI      systemServiceInstance `json:"arvados-api-server"`
71         Websocket     systemServiceInstance `json:"arvados-ws"`
72         Workbench1    systemServiceInstance `json:"arvados-workbench"`
73 }
74
75 type systemServiceInstance struct {
76         Listen   string
77         TLS      bool
78         Insecure bool
79 }
80
81 func (ldr *Loader) applyDeprecatedConfig(cfg *arvados.Config) error {
82         var dc deprecatedConfig
83         err := yaml.Unmarshal(ldr.configdata, &dc)
84         if err != nil {
85                 return err
86         }
87         hostname, err := os.Hostname()
88         if err != nil {
89                 return err
90         }
91         for id, dcluster := range dc.Clusters {
92                 cluster, ok := cfg.Clusters[id]
93                 if !ok {
94                         return fmt.Errorf("can't load legacy config %q that is not present in current config", id)
95                 }
96                 for name, np := range dcluster.NodeProfiles {
97                         if name == "*" || name == os.Getenv("ARVADOS_NODE_PROFILE") || name == hostname {
98                                 name = "localhost"
99                         } else if ldr.Logger != nil {
100                                 ldr.Logger.Warnf("overriding Clusters.%s.Services using Clusters.%s.NodeProfiles.%s (guessing %q is a hostname)", id, id, name, name)
101                         }
102                         applyDeprecatedNodeProfile(name, np.RailsAPI, &cluster.Services.RailsAPI)
103                         applyDeprecatedNodeProfile(name, np.Controller, &cluster.Services.Controller)
104                         applyDeprecatedNodeProfile(name, np.DispatchCloud, &cluster.Services.DispatchCloud)
105                 }
106                 if dst, n := &cluster.API.MaxItemsPerResponse, dcluster.RequestLimits.MaxItemsPerResponse; n != nil && *n != *dst {
107                         *dst = *n
108                 }
109                 if dst, n := &cluster.API.MaxRequestAmplification, dcluster.RequestLimits.MultiClusterRequestConcurrency; n != nil && *n != *dst {
110                         *dst = *n
111                 }
112                 if dst, addr := &cluster.Users.SupportEmailAddress, dcluster.Mail.SupportEmailAddress; addr != nil {
113                         *dst = *addr
114                         ldr.Logger.Warnf("using your old config key Mail.SupportEmailAddress -- but you should rename it to Users.SupportEmailAddress")
115                 }
116                 if dst, b := &cluster.Users.SendUserSetupNotificationEmail, dcluster.Mail.SendUserSetupNotificationEmail; b != nil {
117                         *dst = *b
118                         ldr.Logger.Warnf("using your old config key Mail.SendUserSetupNotificationEmail -- but you should rename it to Users.SendUserSetupNotificationEmail")
119                 }
120                 if dst, n := &cluster.Containers.LSF.BsubGPUArguments, dcluster.Containers.LSF.BsubCUDAArguments; n != nil {
121                         *dst = *n
122                         ldr.Logger.Warnf("using your old config key Containers.LSF.BsubCUDAArguments -- but you should rename it to Containers.LSF.BsubGPUArguments")
123                 }
124
125                 // Google* moved to Google.*
126                 if dst, n := &cluster.Login.Google.ClientID, dcluster.Login.GoogleClientID; n != nil && *n != *dst {
127                         *dst = *n
128                         if *n != "" {
129                                 // In old config, non-empty ClientID meant enable
130                                 cluster.Login.Google.Enable = true
131                         }
132                 }
133                 if dst, n := &cluster.Login.Google.ClientSecret, dcluster.Login.GoogleClientSecret; n != nil && *n != *dst {
134                         *dst = *n
135                 }
136                 if dst, n := &cluster.Login.Google.AlternateEmailAddresses, dcluster.Login.GoogleAlternateEmailAddresses; n != nil && *n != *dst {
137                         *dst = *n
138                 }
139
140                 for name, instanceType := range dcluster.InstanceTypes {
141                         if instanceType.CUDA != nil {
142                                 updInstanceType := cluster.InstanceTypes[name]
143                                 updInstanceType.GPU = arvados.GPUFeatures{
144                                         Stack:          "cuda",
145                                         DriverVersion:  instanceType.CUDA.DriverVersion,
146                                         HardwareTarget: instanceType.CUDA.HardwareCapability,
147                                         DeviceCount:    instanceType.CUDA.DeviceCount,
148                                         VRAM:           0,
149                                 }
150                                 cluster.InstanceTypes[name] = updInstanceType
151                                 ldr.Logger.Warnf("InstanceType %q has deprecated CUDA section, should be migrated to GPU section", name)
152                         }
153                 }
154
155                 cfg.Clusters[id] = cluster
156         }
157         return nil
158 }
159
160 func (ldr *Loader) applyDeprecatedVolumeDriverParameters(cfg *arvados.Config) error {
161         for clusterID, cluster := range cfg.Clusters {
162                 for volID, vol := range cluster.Volumes {
163                         if vol.Driver == "S3" {
164                                 var params struct {
165                                         AccessKey       string `json:",omitempty"`
166                                         SecretKey       string `json:",omitempty"`
167                                         AccessKeyID     string
168                                         SecretAccessKey string
169                                 }
170                                 err := json.Unmarshal(vol.DriverParameters, &params)
171                                 if err != nil {
172                                         return fmt.Errorf("error loading %s.Volumes.%s.DriverParameters: %w", clusterID, volID, err)
173                                 }
174                                 if params.AccessKey != "" || params.SecretKey != "" {
175                                         if params.AccessKeyID != "" || params.SecretAccessKey != "" {
176                                                 return fmt.Errorf("cannot use old keys (AccessKey/SecretKey) and new keys (AccessKeyID/SecretAccessKey) at the same time in %s.Volumes.%s.DriverParameters -- you must remove the old config keys", clusterID, volID)
177                                         }
178                                         var allparams map[string]interface{}
179                                         err = json.Unmarshal(vol.DriverParameters, &allparams)
180                                         if err != nil {
181                                                 return fmt.Errorf("error loading %s.Volumes.%s.DriverParameters: %w", clusterID, volID, err)
182                                         }
183                                         for k := range allparams {
184                                                 if lk := strings.ToLower(k); lk == "accesskey" || lk == "secretkey" {
185                                                         delete(allparams, k)
186                                                 }
187                                         }
188                                         ldr.Logger.Warnf("using your old config keys %s.Volumes.%s.DriverParameters.AccessKey/SecretKey -- but you should rename them to AccessKeyID/SecretAccessKey", clusterID, volID)
189                                         allparams["AccessKeyID"] = params.AccessKey
190                                         allparams["SecretAccessKey"] = params.SecretKey
191                                         vol.DriverParameters, err = json.Marshal(allparams)
192                                         if err != nil {
193                                                 return err
194                                         }
195                                         cluster.Volumes[volID] = vol
196                                 }
197                         }
198                 }
199         }
200         return nil
201 }
202
203 func applyDeprecatedNodeProfile(hostname string, ssi systemServiceInstance, svc *arvados.Service) {
204         scheme := "https"
205         if !ssi.TLS {
206                 scheme = "http"
207         }
208         if svc.InternalURLs == nil {
209                 svc.InternalURLs = map[arvados.URL]arvados.ServiceInstance{}
210         }
211         host := ssi.Listen
212         if host == "" {
213                 return
214         }
215         if strings.HasPrefix(host, ":") {
216                 host = hostname + host
217         }
218         svc.InternalURLs[arvados.URL{Scheme: scheme, Host: host, Path: "/"}] = arvados.ServiceInstance{}
219 }
220
221 func (ldr *Loader) loadOldConfigHelper(component, path string, target interface{}) error {
222         if path == "" {
223                 return nil
224         }
225         buf, err := ioutil.ReadFile(path)
226         if err != nil {
227                 return err
228         }
229
230         ldr.Logger.Warnf("you should remove the legacy %v config file (%s) after migrating all config keys to the cluster configuration file (%s)", component, path, ldr.Path)
231
232         err = yaml.Unmarshal(buf, target)
233         if err != nil {
234                 return fmt.Errorf("%s: %s", path, err)
235         }
236         return nil
237 }
238
239 type oldCrunchDispatchSlurmConfig struct {
240         Client *arvados.Client
241
242         SbatchArguments *[]string
243         PollPeriod      *arvados.Duration
244         PrioritySpread  *int64
245
246         // crunch-run command to invoke. The container UUID will be
247         // appended. If nil, []string{"crunch-run"} will be used.
248         //
249         // Example: []string{"crunch-run", "--cgroup-parent-subsystem=memory"}
250         CrunchRunCommand *[]string
251
252         // Extra RAM to reserve (in Bytes) for SLURM job, in addition
253         // to the amount specified in the container's RuntimeConstraints
254         ReserveExtraRAM *int64
255
256         // Minimum time between two attempts to run the same container
257         MinRetryPeriod *arvados.Duration
258
259         // Batch size for container queries
260         BatchSize *int64
261 }
262
263 const defaultCrunchDispatchSlurmConfigPath = "/etc/arvados/crunch-dispatch-slurm/crunch-dispatch-slurm.yml"
264
265 func loadOldClientConfig(cluster *arvados.Cluster, client *arvados.Client) {
266         if client == nil {
267                 return
268         }
269         if client.APIHost != "" {
270                 cluster.Services.Controller.ExternalURL.Host = client.APIHost
271                 cluster.Services.Controller.ExternalURL.Path = "/"
272         }
273         if client.Scheme != "" {
274                 cluster.Services.Controller.ExternalURL.Scheme = client.Scheme
275         } else {
276                 cluster.Services.Controller.ExternalURL.Scheme = "https"
277         }
278         if client.AuthToken != "" {
279                 cluster.SystemRootToken = client.AuthToken
280         }
281         cluster.TLS.Insecure = client.Insecure
282         ks := ""
283         for i, u := range client.KeepServiceURIs {
284                 if i > 0 {
285                         ks += " "
286                 }
287                 ks += u
288         }
289         cluster.Containers.SLURM.SbatchEnvironmentVariables = map[string]string{"ARVADOS_KEEP_SERVICES": ks}
290 }
291
292 // update config using values from an crunch-dispatch-slurm config file.
293 func (ldr *Loader) loadOldCrunchDispatchSlurmConfig(cfg *arvados.Config) error {
294         if ldr.CrunchDispatchSlurmPath == "" {
295                 return nil
296         }
297         var oc oldCrunchDispatchSlurmConfig
298         err := ldr.loadOldConfigHelper("crunch-dispatch-slurm", ldr.CrunchDispatchSlurmPath, &oc)
299         if os.IsNotExist(err) && (ldr.CrunchDispatchSlurmPath == defaultCrunchDispatchSlurmConfigPath) {
300                 return nil
301         } else if err != nil {
302                 return err
303         }
304
305         cluster, err := cfg.GetCluster("")
306         if err != nil {
307                 return err
308         }
309
310         loadOldClientConfig(cluster, oc.Client)
311
312         if oc.SbatchArguments != nil {
313                 cluster.Containers.SLURM.SbatchArgumentsList = *oc.SbatchArguments
314         }
315         if oc.PollPeriod != nil {
316                 cluster.Containers.CloudVMs.PollInterval = *oc.PollPeriod
317         }
318         if oc.PrioritySpread != nil {
319                 cluster.Containers.SLURM.PrioritySpread = *oc.PrioritySpread
320         }
321         if oc.CrunchRunCommand != nil {
322                 if len(*oc.CrunchRunCommand) >= 1 {
323                         cluster.Containers.CrunchRunCommand = (*oc.CrunchRunCommand)[0]
324                 }
325                 if len(*oc.CrunchRunCommand) >= 2 {
326                         cluster.Containers.CrunchRunArgumentsList = (*oc.CrunchRunCommand)[1:]
327                 }
328         }
329         if oc.ReserveExtraRAM != nil {
330                 cluster.Containers.ReserveExtraRAM = arvados.ByteSize(*oc.ReserveExtraRAM)
331         }
332         if oc.MinRetryPeriod != nil {
333                 cluster.Containers.MinRetryPeriod = *oc.MinRetryPeriod
334         }
335         if oc.BatchSize != nil {
336                 cluster.API.MaxItemsPerResponse = int(*oc.BatchSize)
337         }
338
339         cfg.Clusters[cluster.ClusterID] = *cluster
340         return nil
341 }
342
343 type oldWsConfig struct {
344         Client       *arvados.Client
345         Postgres     *arvados.PostgreSQLConnection
346         PostgresPool *int
347         Listen       *string
348         LogLevel     *string
349         LogFormat    *string
350
351         PingTimeout      *arvados.Duration
352         ClientEventQueue *int
353         ServerEventQueue *int
354
355         ManagementToken *string
356 }
357
358 const defaultWebsocketConfigPath = "/etc/arvados/ws/ws.yml"
359
360 // update config using values from an crunch-dispatch-slurm config file.
361 func (ldr *Loader) loadOldWebsocketConfig(cfg *arvados.Config) error {
362         if ldr.WebsocketPath == "" {
363                 return nil
364         }
365         var oc oldWsConfig
366         err := ldr.loadOldConfigHelper("arvados-ws", ldr.WebsocketPath, &oc)
367         if os.IsNotExist(err) && ldr.WebsocketPath == defaultWebsocketConfigPath {
368                 return nil
369         } else if err != nil {
370                 return err
371         }
372
373         cluster, err := cfg.GetCluster("")
374         if err != nil {
375                 return err
376         }
377
378         loadOldClientConfig(cluster, oc.Client)
379
380         if oc.Postgres != nil {
381                 cluster.PostgreSQL.Connection = *oc.Postgres
382         }
383         if oc.PostgresPool != nil {
384                 cluster.PostgreSQL.ConnectionPool = *oc.PostgresPool
385         }
386         if oc.Listen != nil {
387                 cluster.Services.Websocket.InternalURLs[arvados.URL{Host: *oc.Listen, Path: "/"}] = arvados.ServiceInstance{}
388         }
389         if oc.LogLevel != nil {
390                 cluster.SystemLogs.LogLevel = *oc.LogLevel
391         }
392         if oc.LogFormat != nil {
393                 cluster.SystemLogs.Format = *oc.LogFormat
394         }
395         if oc.PingTimeout != nil {
396                 cluster.API.SendTimeout = *oc.PingTimeout
397         }
398         if oc.ClientEventQueue != nil {
399                 cluster.API.WebsocketClientEventQueue = *oc.ClientEventQueue
400         }
401         if oc.ServerEventQueue != nil {
402                 cluster.API.WebsocketServerEventQueue = *oc.ServerEventQueue
403         }
404         if oc.ManagementToken != nil {
405                 cluster.ManagementToken = *oc.ManagementToken
406         }
407
408         cfg.Clusters[cluster.ClusterID] = *cluster
409         return nil
410 }
411
412 type oldKeepProxyConfig struct {
413         Client          *arvados.Client
414         Listen          *string
415         DisableGet      *bool
416         DisablePut      *bool
417         DefaultReplicas *int
418         Timeout         *arvados.Duration
419         PIDFile         *string
420         Debug           *bool
421         ManagementToken *string
422 }
423
424 const defaultKeepproxyConfigPath = "/etc/arvados/keepproxy/keepproxy.yml"
425
426 func (ldr *Loader) loadOldKeepproxyConfig(cfg *arvados.Config) error {
427         if ldr.KeepproxyPath == "" {
428                 return nil
429         }
430         var oc oldKeepProxyConfig
431         err := ldr.loadOldConfigHelper("keepproxy", ldr.KeepproxyPath, &oc)
432         if os.IsNotExist(err) && ldr.KeepproxyPath == defaultKeepproxyConfigPath {
433                 return nil
434         } else if err != nil {
435                 return err
436         }
437
438         cluster, err := cfg.GetCluster("")
439         if err != nil {
440                 return err
441         }
442
443         loadOldClientConfig(cluster, oc.Client)
444
445         if oc.Listen != nil {
446                 cluster.Services.Keepproxy.InternalURLs[arvados.URL{Host: *oc.Listen, Path: "/"}] = arvados.ServiceInstance{}
447         }
448         if oc.DefaultReplicas != nil {
449                 cluster.Collections.DefaultReplication = *oc.DefaultReplicas
450         }
451         if oc.Timeout != nil {
452                 cluster.API.KeepServiceRequestTimeout = *oc.Timeout
453         }
454         if oc.Debug != nil {
455                 if *oc.Debug && cluster.SystemLogs.LogLevel != "debug" {
456                         cluster.SystemLogs.LogLevel = "debug"
457                 } else if !*oc.Debug && cluster.SystemLogs.LogLevel != "info" {
458                         cluster.SystemLogs.LogLevel = "info"
459                 }
460         }
461         if oc.ManagementToken != nil {
462                 cluster.ManagementToken = *oc.ManagementToken
463         }
464
465         // The following legacy options are no longer supported. If they are set to
466         // true or PIDFile has a value, error out and notify the user
467         unsupportedEntry := func(cfgEntry string) error {
468                 return fmt.Errorf("the keepproxy %s configuration option is no longer supported, please remove it from your configuration file", cfgEntry)
469         }
470         if oc.DisableGet != nil && *oc.DisableGet {
471                 return unsupportedEntry("DisableGet")
472         }
473         if oc.DisablePut != nil && *oc.DisablePut {
474                 return unsupportedEntry("DisablePut")
475         }
476         if oc.PIDFile != nil && *oc.PIDFile != "" {
477                 return unsupportedEntry("PIDFile")
478         }
479
480         cfg.Clusters[cluster.ClusterID] = *cluster
481         return nil
482 }
483
484 const defaultKeepWebConfigPath = "/etc/arvados/keep-web/keep-web.yml"
485
486 type oldKeepWebConfig struct {
487         Client *arvados.Client
488
489         Listen *string
490
491         AnonymousTokens    *[]string
492         AttachmentOnlyHost *string
493         TrustAllContent    *bool
494
495         Cache struct {
496                 TTL                  *arvados.Duration
497                 UUIDTTL              *arvados.Duration
498                 MaxCollectionEntries *int
499                 MaxCollectionBytes   *int64
500                 MaxUUIDEntries       *int
501         }
502
503         // Hack to support old command line flag, which is a bool
504         // meaning "get actual token from environment".
505         deprecatedAllowAnonymous *bool
506
507         // Authorization token to be included in all health check requests.
508         ManagementToken *string
509 }
510
511 func (ldr *Loader) loadOldKeepWebConfig(cfg *arvados.Config) error {
512         if ldr.KeepWebPath == "" {
513                 return nil
514         }
515         var oc oldKeepWebConfig
516         err := ldr.loadOldConfigHelper("keep-web", ldr.KeepWebPath, &oc)
517         if os.IsNotExist(err) && ldr.KeepWebPath == defaultKeepWebConfigPath {
518                 return nil
519         } else if err != nil {
520                 return err
521         }
522
523         cluster, err := cfg.GetCluster("")
524         if err != nil {
525                 return err
526         }
527
528         loadOldClientConfig(cluster, oc.Client)
529
530         if oc.Listen != nil {
531                 cluster.Services.WebDAV.InternalURLs[arvados.URL{Host: *oc.Listen, Path: "/"}] = arvados.ServiceInstance{}
532                 cluster.Services.WebDAVDownload.InternalURLs[arvados.URL{Host: *oc.Listen, Path: "/"}] = arvados.ServiceInstance{}
533         }
534         if oc.AttachmentOnlyHost != nil {
535                 cluster.Services.WebDAVDownload.ExternalURL = arvados.URL{Host: *oc.AttachmentOnlyHost, Path: "/"}
536         }
537         if oc.ManagementToken != nil {
538                 cluster.ManagementToken = *oc.ManagementToken
539         }
540         if oc.TrustAllContent != nil {
541                 cluster.Collections.TrustAllContent = *oc.TrustAllContent
542         }
543         if oc.Cache.TTL != nil {
544                 cluster.Collections.WebDAVCache.TTL = *oc.Cache.TTL
545         }
546         if oc.Cache.MaxCollectionBytes != nil {
547                 cluster.Collections.WebDAVCache.MaxCollectionBytes = arvados.ByteSize(*oc.Cache.MaxCollectionBytes)
548         }
549         if oc.AnonymousTokens != nil {
550                 if len(*oc.AnonymousTokens) > 0 {
551                         cluster.Users.AnonymousUserToken = (*oc.AnonymousTokens)[0]
552                         if len(*oc.AnonymousTokens) > 1 {
553                                 ldr.Logger.Warn("More than 1 anonymous tokens configured, using only the first and discarding the rest.")
554                         }
555                 }
556         }
557
558         cfg.Clusters[cluster.ClusterID] = *cluster
559         return nil
560 }
561
562 const defaultKeepBalanceConfigPath = "/etc/arvados/keep-balance/keep-balance.yml"
563
564 type oldKeepBalanceConfig struct {
565         Client              *arvados.Client
566         Listen              *string
567         KeepServiceTypes    *[]string
568         KeepServiceList     *arvados.KeepServiceList
569         RunPeriod           *arvados.Duration
570         CollectionBatchSize *int
571         CollectionBuffers   *int
572         RequestTimeout      *arvados.Duration
573         LostBlocksFile      *string
574         ManagementToken     *string
575 }
576
577 func (ldr *Loader) loadOldKeepBalanceConfig(cfg *arvados.Config) error {
578         if ldr.KeepBalancePath == "" {
579                 return nil
580         }
581         var oc oldKeepBalanceConfig
582         err := ldr.loadOldConfigHelper("keep-balance", ldr.KeepBalancePath, &oc)
583         if os.IsNotExist(err) && ldr.KeepBalancePath == defaultKeepBalanceConfigPath {
584                 return nil
585         } else if err != nil {
586                 return err
587         }
588
589         cluster, err := cfg.GetCluster("")
590         if err != nil {
591                 return err
592         }
593
594         loadOldClientConfig(cluster, oc.Client)
595
596         if oc.Listen != nil {
597                 cluster.Services.Keepbalance.InternalURLs[arvados.URL{Host: *oc.Listen}] = arvados.ServiceInstance{}
598         }
599         if oc.ManagementToken != nil {
600                 cluster.ManagementToken = *oc.ManagementToken
601         }
602         if oc.RunPeriod != nil {
603                 cluster.Collections.BalancePeriod = *oc.RunPeriod
604         }
605         if oc.LostBlocksFile != nil {
606                 cluster.Collections.BlobMissingReport = *oc.LostBlocksFile
607         }
608         if oc.CollectionBatchSize != nil {
609                 cluster.Collections.BalanceCollectionBatch = *oc.CollectionBatchSize
610         }
611         if oc.CollectionBuffers != nil {
612                 cluster.Collections.BalanceCollectionBuffers = *oc.CollectionBuffers
613         }
614         if oc.RequestTimeout != nil {
615                 cluster.API.KeepServiceRequestTimeout = *oc.RequestTimeout
616         }
617
618         msg := "The %s configuration option is no longer supported. Please remove it from your configuration file. See the keep-balance upgrade notes at https://doc.arvados.org/admin/upgrading.html for more details."
619
620         // If the keep service type provided is "disk" silently ignore it, since
621         // this is what ends up being done anyway.
622         if oc.KeepServiceTypes != nil {
623                 numTypes := len(*oc.KeepServiceTypes)
624                 if numTypes != 0 && !(numTypes == 1 && (*oc.KeepServiceTypes)[0] == "disk") {
625                         return fmt.Errorf(msg, "KeepServiceTypes")
626                 }
627         }
628
629         if oc.KeepServiceList != nil {
630                 return fmt.Errorf(msg, "KeepServiceList")
631         }
632
633         cfg.Clusters[cluster.ClusterID] = *cluster
634         return nil
635 }
636
637 func (ldr *Loader) loadOldEnvironmentVariables(cfg *arvados.Config) error {
638         if os.Getenv("ARVADOS_API_TOKEN") == "" && os.Getenv("ARVADOS_API_HOST") == "" {
639                 return nil
640         }
641         cluster, err := cfg.GetCluster("")
642         if err != nil {
643                 return err
644         }
645         if tok := os.Getenv("ARVADOS_API_TOKEN"); tok != "" && cluster.SystemRootToken == "" {
646                 ldr.Logger.Warn("SystemRootToken missing from cluster config, falling back to ARVADOS_API_TOKEN environment variable")
647                 cluster.SystemRootToken = tok
648         }
649         if apihost := os.Getenv("ARVADOS_API_HOST"); apihost != "" && cluster.Services.Controller.ExternalURL.Host == "" {
650                 ldr.Logger.Warn("Services.Controller.ExternalURL missing from cluster config, falling back to ARVADOS_API_HOST(_INSECURE) environment variables")
651                 u, err := url.Parse("https://" + apihost)
652                 if err != nil {
653                         return fmt.Errorf("cannot parse ARVADOS_API_HOST: %s", err)
654                 }
655                 cluster.Services.Controller.ExternalURL = arvados.URL(*u)
656                 if i := os.Getenv("ARVADOS_API_HOST_INSECURE"); i != "" && i != "0" {
657                         cluster.TLS.Insecure = true
658                 }
659         }
660         cfg.Clusters[cluster.ClusterID] = *cluster
661         return nil
662 }