1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
14 "git.arvados.org/arvados.git/sdk/go/config"
17 var DefaultConfigFile = func() string {
18 if path := os.Getenv("ARVADOS_CONFIG"); path != "" {
21 return "/etc/arvados/config.yml"
25 Clusters map[string]Cluster
29 // GetConfig returns the current system config, loading it from
30 // configFile if needed.
31 func GetConfig(configFile string) (*Config, error) {
33 err := config.LoadFile(&cfg, configFile)
37 // GetCluster returns the cluster ID and config for the given
38 // cluster, or the default/only configured cluster if clusterID is "".
39 func (sc *Config) GetCluster(clusterID string) (*Cluster, error) {
41 if len(sc.Clusters) == 0 {
42 return nil, fmt.Errorf("no clusters configured")
43 } else if len(sc.Clusters) > 1 {
44 return nil, fmt.Errorf("multiple clusters configured, cannot choose")
46 for id, cc := range sc.Clusters {
52 cc, ok := sc.Clusters[clusterID]
54 return nil, fmt.Errorf("cluster %q is not configured", clusterID)
56 cc.ClusterID = clusterID
60 type WebDAVCacheConfig struct {
64 MaxCollectionEntries int
65 MaxCollectionBytes int64
66 MaxPermissionEntries int
72 ClusterID string `json:"-"`
73 ManagementToken string
74 SystemRootToken string
76 InstanceTypes InstanceTypeMap
77 Containers ContainersConfig
78 RemoteClusters map[string]RemoteCluster
82 AsyncPermissionsUpdateInterval Duration
83 DisabledAPIs StringSet
84 MaxIndexDatabaseRead int
85 MaxItemsPerResponse int
86 MaxConcurrentRequests int
87 MaxKeepBlobBuffers int
88 MaxRequestAmplification int
90 RequestTimeout Duration
92 WebsocketClientEventQueue int
93 WebsocketServerEventQueue int
94 KeepServiceRequestTimeout Duration
99 UnloggedAttributes StringSet
103 BlobSigningKey string
104 BlobSigningTTL Duration
106 BlobTrashLifetime Duration
107 BlobTrashCheckInterval Duration
108 BlobTrashConcurrency int
109 BlobDeleteConcurrency int
110 BlobReplicateConcurrency int
111 CollectionVersioning bool
112 DefaultTrashLifetime Duration
113 DefaultReplication int
114 ManagedProperties map[string]struct {
119 PreserveVersionIfIdle Duration
120 TrashSweepInterval Duration
122 ForwardSlashNameSubstitution string
125 BlobMissingReport string
126 BalancePeriod Duration
127 BalanceCollectionBatch int
128 BalanceCollectionBuffers int
129 BalanceTimeout Duration
131 WebDAVCache WebDAVCacheConfig
146 SearchAttribute string
147 SearchBindUser string
148 SearchBindPassword string
151 EmailAttribute string
152 UsernameAttribute string
158 AlternateEmailAddresses bool
159 AuthenticationRequestParameters map[string]string
161 OpenIDConnect struct {
167 EmailVerifiedClaim string
169 AuthenticationRequestParameters map[string]string
174 DefaultEmailDomain string
179 ProviderAppSecret string
183 Users map[string]TestUser
186 RemoteTokenRefresh Duration
187 TokenLifetime Duration
188 TrustedClients map[string]struct{}
191 MailchimpAPIKey string
192 MailchimpListID string
193 SendUserSetupNotificationEmail bool
194 IssueReporterEmailFrom string
195 IssueReporterEmailTo string
196 SupportEmailAddress string
202 MaxRequestLogParamsSize int
210 AnonymousUserToken string
211 AdminNotifierEmailFrom string
212 AutoAdminFirstUser bool
213 AutoAdminUserWithEmail string
214 AutoSetupNewUsers bool
215 AutoSetupNewUsersWithRepository bool
216 AutoSetupNewUsersWithVmUUID string
217 AutoSetupUsernameBlacklist StringSet
218 EmailSubjectPrefix string
219 NewInactiveUserNotificationRecipients StringSet
220 NewUserNotificationRecipients StringSet
221 NewUsersAreActive bool
222 UserNotifierEmailFrom string
223 UserProfileNotificationAddress string
224 PreferDomainForUsername string
225 UserSetupMailText string
227 Volumes map[string]Volume
229 ActivationContactLink string
230 APIClientConnectTimeout Duration
231 APIClientReceiveTimeout Duration
232 APIResponseCompression bool
233 ApplicationMimetypesWithViewIcon StringSet
234 ArvadosDocsite string
235 ArvadosPublicDataDocURL string
236 DefaultOpenIdPrefix string
237 EnableGettingStartedPopup bool
238 EnablePublicProjectsPage bool
239 FileViewersConfigURL string
240 LogViewerMaxBytes ByteSize
241 MultiSiteSearch string
242 ProfilingEnabled bool
244 RepositoryCache string
245 RunningJobLogRecordsToFetch int
247 ShowRecentCollectionsOnDashboard bool
248 ShowUserAgreementInline bool
249 ShowUserNotifications bool
252 UserProfileFormFields map[string]struct {
254 FormFieldTitle string
255 FormFieldDescription string
258 Options map[string]struct{}
260 UserProfileFormMessage string
262 WelcomePageHTML string
263 InactivePageHTML string
264 SSHHelpPageHTML string
265 SSHHelpHostSuffix string
269 ForceLegacyAPI14 bool
273 AccessViaHosts map[URL]VolumeAccess
276 StorageClasses map[string]bool
278 DriverParameters json.RawMessage
281 type S3VolumeDriverParameters struct {
288 LocationConstraint bool
290 UseAWSS3v2Driver bool
292 ConnectTimeout Duration
298 type AzureVolumeDriverParameters struct {
299 StorageAccountName string
300 StorageAccountKey string
301 StorageBaseURL string
303 RequestTimeout Duration
304 ListBlobsRetryDelay Duration
305 ListBlobsMaxAttempts int
308 type DirectoryVolumeDriverParameters struct {
313 type VolumeAccess struct {
317 type Services struct {
320 DispatchCloud Service
329 WebDAVDownload Service
337 type Service struct {
338 InternalURLs map[URL]ServiceInstance
342 type TestUser struct {
347 // URL is a url.URL that is also usable as a JSON key/value.
350 // UnmarshalText implements encoding.TextUnmarshaler so URL can be
351 // used as a JSON key/value.
352 func (su *URL) UnmarshalText(text []byte) error {
353 u, err := url.Parse(string(text))
356 if su.Path == "" && su.Host != "" {
357 // http://example really means http://example/
364 func (su URL) MarshalText() ([]byte, error) {
365 return []byte(fmt.Sprintf("%s", (*url.URL)(&su).String())), nil
368 func (su URL) String() string {
369 return (*url.URL)(&su).String()
372 type ServiceInstance struct {
373 Rendezvous string `json:",omitempty"`
376 type PostgreSQL struct {
377 Connection PostgreSQLConnection
381 type PostgreSQLConnection map[string]string
383 type RemoteCluster struct {
391 type InstanceType struct {
397 IncludedScratch ByteSize
398 AddedScratch ByteSize
403 type ContainersConfig struct {
404 CloudVMs CloudVMsConfig
405 CrunchRunCommand string
406 CrunchRunArgumentsList []string
407 DefaultKeepCacheRAM ByteSize
408 DispatchPrivateKey string
409 LogReuseDecisions bool
411 MaxDispatchAttempts int
413 MinRetryPeriod Duration
414 ReserveExtraRAM ByteSize
415 StaleLockTimeout Duration
416 SupportedDockerImageFormats StringSet
417 UsePreemptibleInstances bool
421 GitInternalDir string
426 LogSecondsBetweenEvents Duration
427 LogThrottlePeriod Duration
430 LimitLogBytesPerJob int
431 LogPartialLineThrottlePeriod Duration
432 LogUpdatePeriod Duration
433 LogUpdateSize ByteSize
437 SbatchArgumentsList []string
438 SbatchEnvironmentVariables map[string]string
440 DNSServerConfDir string
441 DNSServerConfTemplate string
442 DNSServerReloadCommand string
443 DNSServerUpdateCommand string
444 ComputeNodeDomain string
445 ComputeNodeNameservers StringSet
446 AssignNodeHostname string
451 type CloudVMsConfig struct {
454 BootProbeCommand string
455 DeployRunnerBinary string
457 MaxCloudOpsPerSecond int
458 MaxProbesPerSecond int
459 MaxConcurrentInstanceCreateOps int
460 PollInterval Duration
461 ProbeInterval Duration
463 SyncInterval Duration
464 TimeoutBooting Duration
466 TimeoutProbe Duration
467 TimeoutShutdown Duration
468 TimeoutSignal Duration
469 TimeoutStaleRunLock Duration
471 ResourceTags map[string]string
475 DriverParameters json.RawMessage
478 type InstanceTypeMap map[string]InstanceType
480 var errDuplicateInstanceTypeName = errors.New("duplicate instance type name")
482 // UnmarshalJSON handles old config files that provide an array of
483 // instance types instead of a hash.
484 func (it *InstanceTypeMap) UnmarshalJSON(data []byte) error {
485 fixup := func(t InstanceType) (InstanceType, error) {
486 if t.ProviderType == "" {
487 t.ProviderType = t.Name
490 t.Scratch = t.IncludedScratch + t.AddedScratch
491 } else if t.AddedScratch == 0 {
492 t.AddedScratch = t.Scratch - t.IncludedScratch
493 } else if t.IncludedScratch == 0 {
494 t.IncludedScratch = t.Scratch - t.AddedScratch
497 if t.Scratch != (t.IncludedScratch + t.AddedScratch) {
498 return t, fmt.Errorf("InstanceType %q: Scratch != (IncludedScratch + AddedScratch)", t.Name)
503 if len(data) > 0 && data[0] == '[' {
504 var arr []InstanceType
505 err := json.Unmarshal(data, &arr)
513 *it = make(map[string]InstanceType, len(arr))
514 for _, t := range arr {
515 if _, ok := (*it)[t.Name]; ok {
516 return errDuplicateInstanceTypeName
526 var hash map[string]InstanceType
527 err := json.Unmarshal(data, &hash)
531 // Fill in Name field (and ProviderType field, if not
532 // specified) using hash key.
533 *it = InstanceTypeMap(hash)
534 for name, t := range *it {
545 type StringSet map[string]struct{}
547 // UnmarshalJSON handles old config files that provide an array of
548 // instance types instead of a hash.
549 func (ss *StringSet) UnmarshalJSON(data []byte) error {
550 if len(data) > 0 && data[0] == '[' {
552 err := json.Unmarshal(data, &arr)
560 *ss = make(map[string]struct{}, len(arr))
561 for _, t := range arr {
562 (*ss)[t] = struct{}{}
566 var hash map[string]struct{}
567 err := json.Unmarshal(data, &hash)
571 *ss = make(map[string]struct{}, len(hash))
572 for t := range hash {
573 (*ss)[t] = struct{}{}
579 type ServiceName string
582 ServiceNameRailsAPI ServiceName = "arvados-api-server"
583 ServiceNameController ServiceName = "arvados-controller"
584 ServiceNameDispatchCloud ServiceName = "arvados-dispatch-cloud"
585 ServiceNameHealth ServiceName = "arvados-health"
586 ServiceNameWorkbench1 ServiceName = "arvados-workbench1"
587 ServiceNameWorkbench2 ServiceName = "arvados-workbench2"
588 ServiceNameWebsocket ServiceName = "arvados-ws"
589 ServiceNameKeepbalance ServiceName = "keep-balance"
590 ServiceNameKeepweb ServiceName = "keep-web"
591 ServiceNameKeepproxy ServiceName = "keepproxy"
592 ServiceNameKeepstore ServiceName = "keepstore"
595 // Map returns all services as a map, suitable for iterating over all
596 // services or looking up a service by name.
597 func (svcs Services) Map() map[ServiceName]Service {
598 return map[ServiceName]Service{
599 ServiceNameRailsAPI: svcs.RailsAPI,
600 ServiceNameController: svcs.Controller,
601 ServiceNameDispatchCloud: svcs.DispatchCloud,
602 ServiceNameHealth: svcs.Health,
603 ServiceNameWorkbench1: svcs.Workbench1,
604 ServiceNameWorkbench2: svcs.Workbench2,
605 ServiceNameWebsocket: svcs.Websocket,
606 ServiceNameKeepbalance: svcs.Keepbalance,
607 ServiceNameKeepweb: svcs.WebDAV,
608 ServiceNameKeepproxy: svcs.Keepproxy,
609 ServiceNameKeepstore: svcs.Keepstore,