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 MaxConcurrentRailsRequests int
103 MaxConcurrentRequests int
104 MaxQueuedRequests int
105 MaxQueueTimeForLockRequests Duration
106 LogCreateRequestFraction float64
107 MaxKeepBlobBuffers int
108 MaxRequestAmplification int
110 MaxTokenLifetime Duration
111 RequestTimeout Duration
113 WebsocketClientEventQueue int
114 WebsocketServerEventQueue int
115 KeepServiceRequestTimeout Duration
116 VocabularyPath string
117 FreezeProjectRequiresDescription bool
118 FreezeProjectRequiresProperties StringSet
119 UnfreezeProjectRequiresAdmin bool
120 LockBeforeUpdate bool
125 UnloggedAttributes StringSet
129 BlobSigningKey string
130 BlobSigningTTL Duration
132 BlobTrashLifetime Duration
133 BlobTrashCheckInterval Duration
134 BlobTrashConcurrency int
135 BlobDeleteConcurrency int
136 BlobReplicateConcurrency int
137 CollectionVersioning bool
138 DefaultTrashLifetime Duration
139 DefaultReplication int
140 ManagedProperties ManagedProperties
141 PreserveVersionIfIdle Duration
142 TrashSweepInterval Duration
144 ForwardSlashNameSubstitution string
147 BlobMissingReport string
148 BalancePeriod Duration
149 BalanceCollectionBatch int
150 BalanceCollectionBuffers int
151 BalanceTimeout Duration
152 BalanceUpdateLimit int
154 WebDAVCache WebDAVCacheConfig
156 KeepproxyPermission UploadDownloadRolePermissions
157 WebDAVPermission UploadDownloadRolePermissions
171 MinTLSVersion TLSVersion
174 SearchAttribute string
175 SearchBindUser string
176 SearchBindPassword string
179 EmailAttribute string
180 UsernameAttribute string
186 AlternateEmailAddresses bool
187 AuthenticationRequestParameters map[string]string
189 OpenIDConnect struct {
195 EmailVerifiedClaim string
197 AcceptAccessToken bool
198 AcceptAccessTokenScope string
199 AuthenticationRequestParameters map[string]string
204 DefaultEmailDomain string
208 Users map[string]TestUser
211 RemoteTokenRefresh Duration
212 TokenLifetime Duration
213 TrustedClients map[URL]struct{}
214 TrustPrivateNetworks bool
215 IssueTrustedTokens bool
218 MailchimpAPIKey string
219 MailchimpListID string
220 SendUserSetupNotificationEmail bool
221 IssueReporterEmailFrom string
222 IssueReporterEmailTo string
223 SupportEmailAddress string
229 MaxRequestLogParamsSize int
230 RequestQueueDumpDirectory string
241 ActivatedUsersAreVisibleToOthers bool
242 AnonymousUserToken string
243 AdminNotifierEmailFrom string
244 AutoAdminFirstUser bool
245 AutoAdminUserWithEmail string
246 AutoSetupNewUsers bool
247 AutoSetupNewUsersWithRepository bool
248 AutoSetupNewUsersWithVmUUID string
249 AutoSetupUsernameBlacklist StringSet
250 EmailSubjectPrefix string
251 NewInactiveUserNotificationRecipients StringSet
252 NewUserNotificationRecipients StringSet
253 NewUsersAreActive bool
254 UserNotifierEmailFrom string
255 UserNotifierEmailBcc StringSet
256 UserProfileNotificationAddress string
257 PreferDomainForUsername string
258 UserSetupMailText string
259 RoleGroupsVisibleToAll bool
260 CanCreateRoleGroups bool
261 ActivityLoggingPeriod Duration
262 SyncIgnoredGroups []string
263 SyncRequiredGroups []string
264 SyncUserAccounts bool
265 SyncUserAPITokens bool
269 StorageClasses map[string]StorageClassConfig
270 Volumes map[string]Volume
272 ActivationContactLink string
273 APIClientConnectTimeout Duration
274 APIClientReceiveTimeout Duration
275 APIResponseCompression bool
276 ApplicationMimetypesWithViewIcon StringSet
277 ArvadosDocsite string
278 ArvadosPublicDataDocURL string
279 DefaultOpenIdPrefix string
280 DisableSharingURLsUI bool
281 EnableGettingStartedPopup bool
282 EnablePublicProjectsPage bool
283 FileViewersConfigURL string
284 LogViewerMaxBytes ByteSize
285 MultiSiteSearch string
286 ProfilingEnabled bool
288 RepositoryCache string
289 RunningJobLogRecordsToFetch int
291 ShowRecentCollectionsOnDashboard bool
292 ShowUserAgreementInline bool
293 ShowUserNotifications bool
296 UserProfileFormFields map[string]struct {
298 FormFieldTitle string
299 FormFieldDescription string
302 Options map[string]struct{}
304 UserProfileFormMessage string
305 WelcomePageHTML string
306 InactivePageHTML string
307 SSHHelpPageHTML string
308 SSHHelpHostSuffix string
314 type StorageClassConfig struct {
320 AccessViaHosts map[URL]VolumeAccess
322 AllowTrashWhenReadOnly bool
324 StorageClasses map[string]bool
326 DriverParameters json.RawMessage
329 type S3VolumeDriverParameters struct {
332 SecretAccessKey string
336 LocationConstraint bool
339 ConnectTimeout Duration
346 type AzureVolumeDriverParameters struct {
347 StorageAccountName string
348 StorageAccountKey string
349 StorageBaseURL string
351 RequestTimeout Duration
352 ListBlobsRetryDelay Duration
353 ListBlobsMaxAttempts int
356 type DirectoryVolumeDriverParameters struct {
361 type VolumeAccess struct {
365 type Services struct {
368 DispatchCloud Service
370 DispatchSLURM Service
378 WebDAVDownload Service
386 type Service struct {
387 InternalURLs map[URL]ServiceInstance
391 type TestUser struct {
396 // URL is a url.URL that is also usable as a JSON key/value.
399 // UnmarshalText implements encoding.TextUnmarshaler so URL can be
400 // used as a JSON key/value.
401 func (su *URL) UnmarshalText(text []byte) error {
402 u, err := url.Parse(string(text))
405 if su.Path == "" && su.Host != "" {
406 // http://example really means http://example/
413 func (su URL) MarshalText() ([]byte, error) {
414 return []byte(su.String()), nil
417 func (su URL) String() string {
418 return (*url.URL)(&su).String()
421 type TLSVersion uint16
423 func (v TLSVersion) MarshalText() ([]byte, error) {
427 case tls.VersionTLS10:
428 return []byte("1.0"), nil
429 case tls.VersionTLS11:
430 return []byte("1.1"), nil
431 case tls.VersionTLS12:
432 return []byte("1.2"), nil
433 case tls.VersionTLS13:
434 return []byte("1.3"), nil
436 return nil, fmt.Errorf("unsupported TLSVersion %x", v)
440 func (v *TLSVersion) UnmarshalJSON(text []byte) error {
441 if len(text) > 0 && text[0] == '"' {
443 err := json.Unmarshal(text, &s)
449 switch string(text) {
453 *v = tls.VersionTLS10
455 *v = tls.VersionTLS11
457 *v = tls.VersionTLS12
459 *v = tls.VersionTLS13
461 return fmt.Errorf("unsupported TLSVersion %q", text)
466 type ServiceInstance struct {
468 Rendezvous string `json:",omitempty"`
471 type PostgreSQL struct {
472 Connection PostgreSQLConnection
476 type PostgreSQLConnection map[string]string
478 type RemoteCluster struct {
486 type CUDAFeatures struct {
488 HardwareCapability string
492 type InstanceType struct {
493 Name string `json:"-"`
497 Scratch ByteSize `json:"-"`
498 IncludedScratch ByteSize
499 AddedScratch ByteSize
505 type ContainersConfig struct {
506 CloudVMs CloudVMsConfig
507 CrunchRunCommand string
508 CrunchRunArgumentsList []string
509 DefaultKeepCacheRAM ByteSize
510 DispatchPrivateKey string
511 LogReuseDecisions bool
512 MaxDispatchAttempts int
514 MinRetryPeriod Duration
515 ReserveExtraRAM ByteSize
516 StaleLockTimeout Duration
517 SupportedDockerImageFormats StringSet
518 AlwaysUsePreemptibleInstances bool
519 PreemptiblePriceFactor float64
520 MaximumPriceFactor float64
522 LocalKeepBlobBuffersPerVCPU int
523 LocalKeepLogsToContainerLog string
527 GitInternalDir string
531 SweepInterval Duration
533 LogSecondsBetweenEvents Duration
534 LogThrottlePeriod Duration
537 LimitLogBytesPerJob int
538 LogPartialLineThrottlePeriod Duration
539 LogUpdatePeriod Duration
540 LogUpdateSize ByteSize
548 SbatchArgumentsList []string
549 SbatchEnvironmentVariables map[string]string
551 DNSServerConfDir string
552 DNSServerConfTemplate string
553 DNSServerReloadCommand string
554 DNSServerUpdateCommand string
555 ComputeNodeDomain string
556 ComputeNodeNameservers StringSet
557 AssignNodeHostname string
562 BsubArgumentsList []string
563 BsubCUDAArguments []string
567 type CloudVMsConfig struct {
570 BootProbeCommand string
571 InstanceInitCommand string
572 DeployRunnerBinary string
575 MaxCloudOpsPerSecond int
576 MaxProbesPerSecond int
577 MaxConcurrentInstanceCreateOps int
579 InitialQuotaEstimate int
580 SupervisorFraction float64
581 PollInterval Duration
582 ProbeInterval Duration
584 SyncInterval Duration
585 TimeoutBooting Duration
587 TimeoutProbe Duration
588 TimeoutShutdown Duration
589 TimeoutSignal Duration
590 TimeoutStaleRunLock Duration
592 ResourceTags map[string]string
596 DriverParameters json.RawMessage
599 type InstanceTypeMap map[string]InstanceType
601 var errDuplicateInstanceTypeName = errors.New("duplicate instance type name")
603 // UnmarshalJSON does special handling of InstanceTypes:
605 // - populate computed fields (Name and Scratch)
607 // - error out if InstancesTypes are populated as an array, which was
608 // deprecated in Arvados 1.2.0
609 func (it *InstanceTypeMap) UnmarshalJSON(data []byte) error {
610 fixup := func(t InstanceType) (InstanceType, error) {
611 if t.ProviderType == "" {
612 t.ProviderType = t.Name
614 // If t.Scratch is set in the configuration file, it will be ignored and overwritten.
615 // It will also generate a "deprecated or unknown config entry" warning.
616 t.Scratch = t.IncludedScratch + t.AddedScratch
620 if len(data) > 0 && data[0] == '[' {
621 return fmt.Errorf("InstanceTypes must be specified as a map, not an array, see https://doc.arvados.org/admin/config.html")
623 var hash map[string]InstanceType
624 err := json.Unmarshal(data, &hash)
628 // Fill in Name field (and ProviderType field, if not
629 // specified) using hash key.
630 *it = InstanceTypeMap(hash)
631 for name, t := range *it {
642 type StringSet map[string]struct{}
644 // UnmarshalJSON handles old config files that provide an array of
645 // instance types instead of a hash.
646 func (ss *StringSet) UnmarshalJSON(data []byte) error {
647 if len(data) > 0 && data[0] == '[' {
649 err := json.Unmarshal(data, &arr)
657 *ss = make(map[string]struct{}, len(arr))
658 for _, t := range arr {
659 (*ss)[t] = struct{}{}
663 var hash map[string]struct{}
664 err := json.Unmarshal(data, &hash)
668 *ss = make(map[string]struct{}, len(hash))
669 for t := range hash {
670 (*ss)[t] = struct{}{}
676 type ServiceName string
679 ServiceNameController ServiceName = "arvados-controller"
680 ServiceNameDispatchCloud ServiceName = "arvados-dispatch-cloud"
681 ServiceNameDispatchLSF ServiceName = "arvados-dispatch-lsf"
682 ServiceNameDispatchSLURM ServiceName = "crunch-dispatch-slurm"
683 ServiceNameGitHTTP ServiceName = "arvados-git-httpd"
684 ServiceNameHealth ServiceName = "arvados-health"
685 ServiceNameKeepbalance ServiceName = "keep-balance"
686 ServiceNameKeepproxy ServiceName = "keepproxy"
687 ServiceNameKeepstore ServiceName = "keepstore"
688 ServiceNameKeepweb ServiceName = "keep-web"
689 ServiceNameRailsAPI ServiceName = "arvados-api-server"
690 ServiceNameWebsocket ServiceName = "arvados-ws"
691 ServiceNameWorkbench1 ServiceName = "arvados-workbench1"
692 ServiceNameWorkbench2 ServiceName = "arvados-workbench2"
695 // Map returns all services as a map, suitable for iterating over all
696 // services or looking up a service by name.
697 func (svcs Services) Map() map[ServiceName]Service {
698 return map[ServiceName]Service{
699 ServiceNameController: svcs.Controller,
700 ServiceNameDispatchCloud: svcs.DispatchCloud,
701 ServiceNameDispatchLSF: svcs.DispatchLSF,
702 ServiceNameDispatchSLURM: svcs.DispatchSLURM,
703 ServiceNameGitHTTP: svcs.GitHTTP,
704 ServiceNameHealth: svcs.Health,
705 ServiceNameKeepbalance: svcs.Keepbalance,
706 ServiceNameKeepproxy: svcs.Keepproxy,
707 ServiceNameKeepstore: svcs.Keepstore,
708 ServiceNameKeepweb: svcs.WebDAV,
709 ServiceNameRailsAPI: svcs.RailsAPI,
710 ServiceNameWebsocket: svcs.Websocket,
711 ServiceNameWorkbench1: svcs.Workbench1,
712 ServiceNameWorkbench2: svcs.Workbench2,