1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
16 "git.arvados.org/arvados.git/sdk/go/config"
19 var DefaultConfigFile = func() string {
20 if path := os.Getenv("ARVADOS_CONFIG"); path != "" {
23 return "/etc/arvados/config.yml"
27 Clusters map[string]Cluster
29 SourceTimestamp time.Time
33 // GetConfig returns the current system config, loading it from
34 // configFile if needed.
35 func GetConfig(configFile string) (*Config, error) {
37 err := config.LoadFile(&cfg, configFile)
41 // GetCluster returns the cluster ID and config for the given
42 // cluster, or the default/only configured cluster if clusterID is "".
43 func (sc *Config) GetCluster(clusterID string) (*Cluster, error) {
45 if len(sc.Clusters) == 0 {
46 return nil, fmt.Errorf("no clusters configured")
47 } else if len(sc.Clusters) > 1 {
48 return nil, fmt.Errorf("multiple clusters configured, cannot choose")
50 for id, cc := range sc.Clusters {
56 cc, ok := sc.Clusters[clusterID]
58 return nil, fmt.Errorf("cluster %q is not configured", clusterID)
60 cc.ClusterID = clusterID
64 type WebDAVCacheConfig struct {
67 MaxCollectionBytes int64
71 type UploadDownloadPermission struct {
76 type UploadDownloadRolePermissions struct {
77 User UploadDownloadPermission
78 Admin UploadDownloadPermission
81 type ManagedProperties map[string]struct {
88 ClusterID string `json:"-"`
89 ManagementToken string
90 SystemRootToken string
92 InstanceTypes InstanceTypeMap
93 Containers ContainersConfig
94 RemoteClusters map[string]RemoteCluster
98 AsyncPermissionsUpdateInterval Duration
99 DisabledAPIs StringSet
100 MaxIndexDatabaseRead int
101 MaxItemsPerResponse int
102 MaxConcurrentRequests int
103 MaxQueuedRequests int
104 MaxQueueTimeForLockRequests Duration
105 LogCreateRequestFraction float64
106 MaxKeepBlobBuffers int
107 MaxRequestAmplification int
109 MaxTokenLifetime Duration
110 RequestTimeout Duration
112 WebsocketClientEventQueue int
113 WebsocketServerEventQueue int
114 KeepServiceRequestTimeout Duration
115 VocabularyPath string
116 FreezeProjectRequiresDescription bool
117 FreezeProjectRequiresProperties StringSet
118 UnfreezeProjectRequiresAdmin bool
119 LockBeforeUpdate bool
124 UnloggedAttributes StringSet
128 BlobSigningKey string
129 BlobSigningTTL Duration
131 BlobTrashLifetime Duration
132 BlobTrashCheckInterval Duration
133 BlobTrashConcurrency int
134 BlobDeleteConcurrency int
135 BlobReplicateConcurrency int
136 CollectionVersioning bool
137 DefaultTrashLifetime Duration
138 DefaultReplication int
139 ManagedProperties ManagedProperties
140 PreserveVersionIfIdle Duration
141 TrashSweepInterval Duration
143 ForwardSlashNameSubstitution string
146 BlobMissingReport string
147 BalancePeriod Duration
148 BalanceCollectionBatch int
149 BalanceCollectionBuffers int
150 BalanceTimeout Duration
151 BalanceUpdateLimit int
153 WebDAVCache WebDAVCacheConfig
155 KeepproxyPermission UploadDownloadRolePermissions
156 WebDAVPermission UploadDownloadRolePermissions
170 MinTLSVersion TLSVersion
173 SearchAttribute string
174 SearchBindUser string
175 SearchBindPassword string
178 EmailAttribute string
179 UsernameAttribute string
185 AlternateEmailAddresses bool
186 AuthenticationRequestParameters map[string]string
188 OpenIDConnect struct {
194 EmailVerifiedClaim string
196 AcceptAccessToken bool
197 AcceptAccessTokenScope string
198 AuthenticationRequestParameters map[string]string
203 DefaultEmailDomain string
207 Users map[string]TestUser
210 RemoteTokenRefresh Duration
211 TokenLifetime Duration
212 TrustedClients map[URL]struct{}
213 TrustPrivateNetworks bool
214 IssueTrustedTokens bool
217 MailchimpAPIKey string
218 MailchimpListID string
219 SendUserSetupNotificationEmail bool
220 IssueReporterEmailFrom string
221 IssueReporterEmailTo string
222 SupportEmailAddress string
228 MaxRequestLogParamsSize int
229 RequestQueueDumpDirectory string
240 ActivatedUsersAreVisibleToOthers bool
241 AnonymousUserToken string
242 AdminNotifierEmailFrom string
243 AutoAdminFirstUser bool
244 AutoAdminUserWithEmail string
245 AutoSetupNewUsers bool
246 AutoSetupNewUsersWithRepository bool
247 AutoSetupNewUsersWithVmUUID string
248 AutoSetupUsernameBlacklist StringSet
249 EmailSubjectPrefix string
250 NewInactiveUserNotificationRecipients StringSet
251 NewUserNotificationRecipients StringSet
252 NewUsersAreActive bool
253 UserNotifierEmailFrom string
254 UserNotifierEmailBcc StringSet
255 UserProfileNotificationAddress string
256 PreferDomainForUsername string
257 UserSetupMailText string
258 RoleGroupsVisibleToAll bool
259 CanCreateRoleGroups bool
260 ActivityLoggingPeriod Duration
261 SyncIgnoredGroups []string
262 SyncRequiredGroups []string
263 SyncUserAccounts bool
264 SyncUserAPITokens bool
268 StorageClasses map[string]StorageClassConfig
269 Volumes map[string]Volume
271 ActivationContactLink string
272 APIClientConnectTimeout Duration
273 APIClientReceiveTimeout Duration
274 APIResponseCompression bool
275 ApplicationMimetypesWithViewIcon StringSet
276 ArvadosDocsite string
277 ArvadosPublicDataDocURL string
278 DefaultOpenIdPrefix string
279 DisableSharingURLsUI bool
280 EnableGettingStartedPopup bool
281 EnablePublicProjectsPage bool
282 FileViewersConfigURL string
283 LogViewerMaxBytes ByteSize
284 MultiSiteSearch string
285 ProfilingEnabled bool
287 RepositoryCache string
288 RunningJobLogRecordsToFetch int
290 ShowRecentCollectionsOnDashboard bool
291 ShowUserAgreementInline bool
292 ShowUserNotifications bool
295 UserProfileFormFields map[string]struct {
297 FormFieldTitle string
298 FormFieldDescription string
301 Options map[string]struct{}
303 UserProfileFormMessage string
304 WelcomePageHTML string
305 InactivePageHTML string
306 SSHHelpPageHTML string
307 SSHHelpHostSuffix string
313 type StorageClassConfig struct {
319 AccessViaHosts map[URL]VolumeAccess
321 AllowTrashWhenReadOnly bool
323 StorageClasses map[string]bool
325 DriverParameters json.RawMessage
328 type S3VolumeDriverParameters struct {
331 SecretAccessKey string
335 LocationConstraint bool
338 ConnectTimeout Duration
345 type AzureVolumeDriverParameters struct {
346 StorageAccountName string
347 StorageAccountKey string
348 StorageBaseURL string
350 RequestTimeout Duration
351 ListBlobsRetryDelay Duration
352 ListBlobsMaxAttempts int
355 type DirectoryVolumeDriverParameters struct {
360 type VolumeAccess struct {
364 type Services struct {
367 DispatchCloud Service
369 DispatchSLURM Service
377 WebDAVDownload Service
385 type Service struct {
386 InternalURLs map[URL]ServiceInstance
390 type TestUser struct {
395 // URL is a url.URL that is also usable as a JSON key/value.
398 // UnmarshalText implements encoding.TextUnmarshaler so URL can be
399 // used as a JSON key/value.
400 func (su *URL) UnmarshalText(text []byte) error {
401 u, err := url.Parse(string(text))
404 if su.Path == "" && su.Host != "" {
405 // http://example really means http://example/
412 func (su URL) MarshalText() ([]byte, error) {
413 return []byte(su.String()), nil
416 func (su URL) String() string {
417 return (*url.URL)(&su).String()
420 type TLSVersion uint16
422 func (v TLSVersion) MarshalText() ([]byte, error) {
426 case tls.VersionTLS10:
427 return []byte("1.0"), nil
428 case tls.VersionTLS11:
429 return []byte("1.1"), nil
430 case tls.VersionTLS12:
431 return []byte("1.2"), nil
432 case tls.VersionTLS13:
433 return []byte("1.3"), nil
435 return nil, fmt.Errorf("unsupported TLSVersion %x", v)
439 func (v *TLSVersion) UnmarshalJSON(text []byte) error {
440 if len(text) > 0 && text[0] == '"' {
442 err := json.Unmarshal(text, &s)
448 switch string(text) {
452 *v = tls.VersionTLS10
454 *v = tls.VersionTLS11
456 *v = tls.VersionTLS12
458 *v = tls.VersionTLS13
460 return fmt.Errorf("unsupported TLSVersion %q", text)
465 type ServiceInstance struct {
467 Rendezvous string `json:",omitempty"`
470 type PostgreSQL struct {
471 Connection PostgreSQLConnection
475 type PostgreSQLConnection map[string]string
477 type RemoteCluster struct {
485 type CUDAFeatures struct {
487 HardwareCapability string
491 type InstanceType struct {
492 Name string `json:"-"`
496 Scratch ByteSize `json:"-"`
497 IncludedScratch ByteSize
498 AddedScratch ByteSize
504 type ContainersConfig struct {
505 CloudVMs CloudVMsConfig
506 CrunchRunCommand string
507 CrunchRunArgumentsList []string
508 DefaultKeepCacheRAM ByteSize
509 DispatchPrivateKey string
510 LogReuseDecisions bool
511 MaxDispatchAttempts int
513 MinRetryPeriod Duration
514 ReserveExtraRAM ByteSize
515 StaleLockTimeout Duration
516 SupportedDockerImageFormats StringSet
517 AlwaysUsePreemptibleInstances bool
518 PreemptiblePriceFactor float64
520 LocalKeepBlobBuffersPerVCPU int
521 LocalKeepLogsToContainerLog string
525 GitInternalDir string
529 SweepInterval Duration
531 LogSecondsBetweenEvents Duration
532 LogThrottlePeriod Duration
535 LimitLogBytesPerJob int
536 LogPartialLineThrottlePeriod Duration
537 LogUpdatePeriod Duration
538 LogUpdateSize ByteSize
546 SbatchArgumentsList []string
547 SbatchEnvironmentVariables map[string]string
549 DNSServerConfDir string
550 DNSServerConfTemplate string
551 DNSServerReloadCommand string
552 DNSServerUpdateCommand string
553 ComputeNodeDomain string
554 ComputeNodeNameservers StringSet
555 AssignNodeHostname string
560 BsubArgumentsList []string
561 BsubCUDAArguments []string
565 type CloudVMsConfig struct {
568 BootProbeCommand string
569 InstanceInitCommand string
570 DeployRunnerBinary string
573 MaxCloudOpsPerSecond int
574 MaxProbesPerSecond int
575 MaxConcurrentInstanceCreateOps int
577 InitialQuotaEstimate int
578 SupervisorFraction float64
579 PollInterval Duration
580 ProbeInterval Duration
582 SyncInterval Duration
583 TimeoutBooting Duration
585 TimeoutProbe Duration
586 TimeoutShutdown Duration
587 TimeoutSignal Duration
588 TimeoutStaleRunLock Duration
590 ResourceTags map[string]string
594 DriverParameters json.RawMessage
597 type InstanceTypeMap map[string]InstanceType
599 var errDuplicateInstanceTypeName = errors.New("duplicate instance type name")
601 // UnmarshalJSON does special handling of InstanceTypes:
603 // - populate computed fields (Name and Scratch)
605 // - error out if InstancesTypes are populated as an array, which was
606 // deprecated in Arvados 1.2.0
607 func (it *InstanceTypeMap) UnmarshalJSON(data []byte) error {
608 fixup := func(t InstanceType) (InstanceType, error) {
609 if t.ProviderType == "" {
610 t.ProviderType = t.Name
612 // If t.Scratch is set in the configuration file, it will be ignored and overwritten.
613 // It will also generate a "deprecated or unknown config entry" warning.
614 t.Scratch = t.IncludedScratch + t.AddedScratch
618 if len(data) > 0 && data[0] == '[' {
619 return fmt.Errorf("InstanceTypes must be specified as a map, not an array, see https://doc.arvados.org/admin/config.html")
621 var hash map[string]InstanceType
622 err := json.Unmarshal(data, &hash)
626 // Fill in Name field (and ProviderType field, if not
627 // specified) using hash key.
628 *it = InstanceTypeMap(hash)
629 for name, t := range *it {
640 type StringSet map[string]struct{}
642 // UnmarshalJSON handles old config files that provide an array of
643 // instance types instead of a hash.
644 func (ss *StringSet) UnmarshalJSON(data []byte) error {
645 if len(data) > 0 && data[0] == '[' {
647 err := json.Unmarshal(data, &arr)
655 *ss = make(map[string]struct{}, len(arr))
656 for _, t := range arr {
657 (*ss)[t] = struct{}{}
661 var hash map[string]struct{}
662 err := json.Unmarshal(data, &hash)
666 *ss = make(map[string]struct{}, len(hash))
667 for t := range hash {
668 (*ss)[t] = struct{}{}
674 type ServiceName string
677 ServiceNameController ServiceName = "arvados-controller"
678 ServiceNameDispatchCloud ServiceName = "arvados-dispatch-cloud"
679 ServiceNameDispatchLSF ServiceName = "arvados-dispatch-lsf"
680 ServiceNameDispatchSLURM ServiceName = "crunch-dispatch-slurm"
681 ServiceNameGitHTTP ServiceName = "arvados-git-httpd"
682 ServiceNameHealth ServiceName = "arvados-health"
683 ServiceNameKeepbalance ServiceName = "keep-balance"
684 ServiceNameKeepproxy ServiceName = "keepproxy"
685 ServiceNameKeepstore ServiceName = "keepstore"
686 ServiceNameKeepweb ServiceName = "keep-web"
687 ServiceNameRailsAPI ServiceName = "arvados-api-server"
688 ServiceNameWebsocket ServiceName = "arvados-ws"
689 ServiceNameWorkbench1 ServiceName = "arvados-workbench1"
690 ServiceNameWorkbench2 ServiceName = "arvados-workbench2"
693 // Map returns all services as a map, suitable for iterating over all
694 // services or looking up a service by name.
695 func (svcs Services) Map() map[ServiceName]Service {
696 return map[ServiceName]Service{
697 ServiceNameController: svcs.Controller,
698 ServiceNameDispatchCloud: svcs.DispatchCloud,
699 ServiceNameDispatchLSF: svcs.DispatchLSF,
700 ServiceNameDispatchSLURM: svcs.DispatchSLURM,
701 ServiceNameGitHTTP: svcs.GitHTTP,
702 ServiceNameHealth: svcs.Health,
703 ServiceNameKeepbalance: svcs.Keepbalance,
704 ServiceNameKeepproxy: svcs.Keepproxy,
705 ServiceNameKeepstore: svcs.Keepstore,
706 ServiceNameKeepweb: svcs.WebDAV,
707 ServiceNameRailsAPI: svcs.RailsAPI,
708 ServiceNameWebsocket: svcs.Websocket,
709 ServiceNameWorkbench1: svcs.Workbench1,
710 ServiceNameWorkbench2: svcs.Workbench2,