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 MaxTokenLifetime Duration
91 RequestTimeout Duration
93 WebsocketClientEventQueue int
94 WebsocketServerEventQueue int
95 KeepServiceRequestTimeout Duration
100 UnloggedAttributes StringSet
104 BlobSigningKey string
105 BlobSigningTTL Duration
107 BlobTrashLifetime Duration
108 BlobTrashCheckInterval Duration
109 BlobTrashConcurrency int
110 BlobDeleteConcurrency int
111 BlobReplicateConcurrency int
112 CollectionVersioning bool
113 DefaultTrashLifetime Duration
114 DefaultReplication int
115 ManagedProperties map[string]struct {
120 PreserveVersionIfIdle Duration
121 TrashSweepInterval Duration
123 ForwardSlashNameSubstitution string
126 BlobMissingReport string
127 BalancePeriod Duration
128 BalanceCollectionBatch int
129 BalanceCollectionBuffers int
130 BalanceTimeout Duration
132 WebDAVCache WebDAVCacheConfig
147 SearchAttribute string
148 SearchBindUser string
149 SearchBindPassword string
152 EmailAttribute string
153 UsernameAttribute string
159 AlternateEmailAddresses bool
160 AuthenticationRequestParameters map[string]string
162 OpenIDConnect struct {
168 EmailVerifiedClaim string
170 AcceptAccessTokenScope string
171 AuthenticationRequestParameters map[string]string
176 DefaultEmailDomain string
181 ProviderAppSecret string
185 Users map[string]TestUser
188 RemoteTokenRefresh Duration
189 TokenLifetime Duration
190 TrustedClients map[string]struct{}
193 MailchimpAPIKey string
194 MailchimpListID string
195 SendUserSetupNotificationEmail bool
196 IssueReporterEmailFrom string
197 IssueReporterEmailTo string
198 SupportEmailAddress string
204 MaxRequestLogParamsSize int
212 AnonymousUserToken string
213 AdminNotifierEmailFrom string
214 AutoAdminFirstUser bool
215 AutoAdminUserWithEmail string
216 AutoSetupNewUsers bool
217 AutoSetupNewUsersWithRepository bool
218 AutoSetupNewUsersWithVmUUID string
219 AutoSetupUsernameBlacklist StringSet
220 EmailSubjectPrefix string
221 NewInactiveUserNotificationRecipients StringSet
222 NewUserNotificationRecipients StringSet
223 NewUsersAreActive bool
224 UserNotifierEmailFrom string
225 UserProfileNotificationAddress string
226 PreferDomainForUsername string
227 UserSetupMailText string
229 Volumes map[string]Volume
231 ActivationContactLink string
232 APIClientConnectTimeout Duration
233 APIClientReceiveTimeout Duration
234 APIResponseCompression bool
235 ApplicationMimetypesWithViewIcon StringSet
236 ArvadosDocsite string
237 ArvadosPublicDataDocURL string
238 DefaultOpenIdPrefix string
239 EnableGettingStartedPopup bool
240 EnablePublicProjectsPage bool
241 FileViewersConfigURL string
242 LogViewerMaxBytes ByteSize
243 MultiSiteSearch string
244 ProfilingEnabled bool
246 RepositoryCache string
247 RunningJobLogRecordsToFetch int
249 ShowRecentCollectionsOnDashboard bool
250 ShowUserAgreementInline bool
251 ShowUserNotifications bool
254 UserProfileFormFields map[string]struct {
256 FormFieldTitle string
257 FormFieldDescription string
260 Options map[string]struct{}
262 UserProfileFormMessage string
264 WelcomePageHTML string
265 InactivePageHTML string
266 SSHHelpPageHTML string
267 SSHHelpHostSuffix string
273 AccessViaHosts map[URL]VolumeAccess
276 StorageClasses map[string]bool
278 DriverParameters json.RawMessage
281 type S3VolumeDriverParameters struct {
284 SecretAccessKey string
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
441 SbatchArgumentsList []string
442 SbatchEnvironmentVariables map[string]string
444 DNSServerConfDir string
445 DNSServerConfTemplate string
446 DNSServerReloadCommand string
447 DNSServerUpdateCommand string
448 ComputeNodeDomain string
449 ComputeNodeNameservers StringSet
450 AssignNodeHostname string
455 type CloudVMsConfig struct {
458 BootProbeCommand string
459 DeployRunnerBinary string
461 MaxCloudOpsPerSecond int
462 MaxProbesPerSecond int
463 MaxConcurrentInstanceCreateOps int
464 PollInterval Duration
465 ProbeInterval Duration
467 SyncInterval Duration
468 TimeoutBooting Duration
470 TimeoutProbe Duration
471 TimeoutShutdown Duration
472 TimeoutSignal Duration
473 TimeoutStaleRunLock Duration
475 ResourceTags map[string]string
479 DriverParameters json.RawMessage
482 type InstanceTypeMap map[string]InstanceType
484 var errDuplicateInstanceTypeName = errors.New("duplicate instance type name")
486 // UnmarshalJSON handles old config files that provide an array of
487 // instance types instead of a hash.
488 func (it *InstanceTypeMap) UnmarshalJSON(data []byte) error {
489 fixup := func(t InstanceType) (InstanceType, error) {
490 if t.ProviderType == "" {
491 t.ProviderType = t.Name
494 t.Scratch = t.IncludedScratch + t.AddedScratch
495 } else if t.AddedScratch == 0 {
496 t.AddedScratch = t.Scratch - t.IncludedScratch
497 } else if t.IncludedScratch == 0 {
498 t.IncludedScratch = t.Scratch - t.AddedScratch
501 if t.Scratch != (t.IncludedScratch + t.AddedScratch) {
502 return t, fmt.Errorf("InstanceType %q: Scratch != (IncludedScratch + AddedScratch)", t.Name)
507 if len(data) > 0 && data[0] == '[' {
508 var arr []InstanceType
509 err := json.Unmarshal(data, &arr)
517 *it = make(map[string]InstanceType, len(arr))
518 for _, t := range arr {
519 if _, ok := (*it)[t.Name]; ok {
520 return errDuplicateInstanceTypeName
530 var hash map[string]InstanceType
531 err := json.Unmarshal(data, &hash)
535 // Fill in Name field (and ProviderType field, if not
536 // specified) using hash key.
537 *it = InstanceTypeMap(hash)
538 for name, t := range *it {
549 type StringSet map[string]struct{}
551 // UnmarshalJSON handles old config files that provide an array of
552 // instance types instead of a hash.
553 func (ss *StringSet) UnmarshalJSON(data []byte) error {
554 if len(data) > 0 && data[0] == '[' {
556 err := json.Unmarshal(data, &arr)
564 *ss = make(map[string]struct{}, len(arr))
565 for _, t := range arr {
566 (*ss)[t] = struct{}{}
570 var hash map[string]struct{}
571 err := json.Unmarshal(data, &hash)
575 *ss = make(map[string]struct{}, len(hash))
576 for t := range hash {
577 (*ss)[t] = struct{}{}
583 type ServiceName string
586 ServiceNameRailsAPI ServiceName = "arvados-api-server"
587 ServiceNameController ServiceName = "arvados-controller"
588 ServiceNameDispatchCloud ServiceName = "arvados-dispatch-cloud"
589 ServiceNameHealth ServiceName = "arvados-health"
590 ServiceNameWorkbench1 ServiceName = "arvados-workbench1"
591 ServiceNameWorkbench2 ServiceName = "arvados-workbench2"
592 ServiceNameWebsocket ServiceName = "arvados-ws"
593 ServiceNameKeepbalance ServiceName = "keep-balance"
594 ServiceNameKeepweb ServiceName = "keep-web"
595 ServiceNameKeepproxy ServiceName = "keepproxy"
596 ServiceNameKeepstore ServiceName = "keepstore"
599 // Map returns all services as a map, suitable for iterating over all
600 // services or looking up a service by name.
601 func (svcs Services) Map() map[ServiceName]Service {
602 return map[ServiceName]Service{
603 ServiceNameRailsAPI: svcs.RailsAPI,
604 ServiceNameController: svcs.Controller,
605 ServiceNameDispatchCloud: svcs.DispatchCloud,
606 ServiceNameHealth: svcs.Health,
607 ServiceNameWorkbench1: svcs.Workbench1,
608 ServiceNameWorkbench2: svcs.Workbench2,
609 ServiceNameWebsocket: svcs.Websocket,
610 ServiceNameKeepbalance: svcs.Keepbalance,
611 ServiceNameKeepweb: svcs.WebDAV,
612 ServiceNameKeepproxy: svcs.Keepproxy,
613 ServiceNameKeepstore: svcs.Keepstore,