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 {
66 DiskCacheSize ByteSizeOrPercent
67 MaxCollectionBytes ByteSize
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 MaxGatewayTunnels int
106 MaxQueueTimeForLockRequests Duration
107 LogCreateRequestFraction float64
108 MaxKeepBlobBuffers int
109 MaxRequestAmplification int
111 MaxTokenLifetime Duration
112 RequestTimeout Duration
114 WebsocketClientEventQueue int
115 WebsocketServerEventQueue int
116 KeepServiceRequestTimeout Duration
117 VocabularyPath string
118 FreezeProjectRequiresDescription bool
119 FreezeProjectRequiresProperties StringSet
120 UnfreezeProjectRequiresAdmin bool
121 LockBeforeUpdate bool
126 UnloggedAttributes StringSet
130 BlobSigningKey string
131 BlobSigningTTL Duration
133 BlobTrashLifetime Duration
134 BlobTrashCheckInterval Duration
135 BlobTrashConcurrency int
136 BlobDeleteConcurrency int
137 BlobReplicateConcurrency int
138 CollectionVersioning bool
139 DefaultTrashLifetime Duration
140 DefaultReplication int
141 ManagedProperties ManagedProperties
142 PreserveVersionIfIdle Duration
143 TrashSweepInterval Duration
145 ForwardSlashNameSubstitution string
148 BlobMissingReport string
149 BalancePeriod Duration
150 BalanceCollectionBatch int
151 BalanceCollectionBuffers int
152 BalanceTimeout Duration
153 BalanceUpdateLimit int
155 BalanceTrashLimit int
157 WebDAVCache WebDAVCacheConfig
159 KeepproxyPermission UploadDownloadRolePermissions
160 WebDAVPermission UploadDownloadRolePermissions
162 WebDAVOutputBuffer ByteSize
175 MinTLSVersion TLSVersion
178 SearchAttribute string
179 SearchBindUser string
180 SearchBindPassword string
183 EmailAttribute string
184 UsernameAttribute string
190 AlternateEmailAddresses bool
191 AuthenticationRequestParameters map[string]string
193 OpenIDConnect struct {
199 EmailVerifiedClaim string
201 AcceptAccessToken bool
202 AcceptAccessTokenScope string
203 AuthenticationRequestParameters map[string]string
208 DefaultEmailDomain string
212 Users map[string]TestUser
215 RemoteTokenRefresh Duration
216 TokenLifetime Duration
217 TrustedClients map[URL]struct{}
218 TrustPrivateNetworks bool
219 IssueTrustedTokens bool
222 MailchimpAPIKey string
223 MailchimpListID string
224 SendUserSetupNotificationEmail bool
225 IssueReporterEmailFrom string
226 IssueReporterEmailTo string
227 SupportEmailAddress string
233 MaxRequestLogParamsSize int
234 RequestQueueDumpDirectory string
245 ActivatedUsersAreVisibleToOthers bool
246 AnonymousUserToken string
247 AdminNotifierEmailFrom string
248 AutoAdminFirstUser bool
249 AutoAdminUserWithEmail string
250 AutoSetupNewUsers bool
251 AutoSetupNewUsersWithRepository bool
252 AutoSetupNewUsersWithVmUUID string
253 AutoSetupUsernameBlacklist StringSet
254 EmailSubjectPrefix string
255 NewInactiveUserNotificationRecipients StringSet
256 NewUserNotificationRecipients StringSet
257 NewUsersAreActive bool
258 UserNotifierEmailFrom string
259 UserNotifierEmailBcc StringSet
260 UserProfileNotificationAddress string
261 PreferDomainForUsername string
262 UserSetupMailText string
263 RoleGroupsVisibleToAll bool
264 CanCreateRoleGroups bool
265 ActivityLoggingPeriod Duration
266 SyncIgnoredGroups []string
267 SyncRequiredGroups []string
268 SyncUserAccounts bool
269 SyncUserAPITokens bool
273 StorageClasses map[string]StorageClassConfig
274 Volumes map[string]Volume
276 ActivationContactLink string
277 ArvadosDocsite string
278 ArvadosPublicDataDocURL string
279 DisableSharingURLsUI bool
280 FileViewersConfigURL string
281 ShowUserAgreementInline bool
284 UserProfileFormFields map[string]struct {
286 FormFieldTitle string
287 FormFieldDescription string
290 Options map[string]struct{}
292 UserProfileFormMessage string
293 WelcomePageHTML string
294 InactivePageHTML string
295 SSHHelpPageHTML string
296 SSHHelpHostSuffix string
302 type StorageClassConfig struct {
308 AccessViaHosts map[URL]VolumeAccess
310 AllowTrashWhenReadOnly bool
312 StorageClasses map[string]bool
314 DriverParameters json.RawMessage
317 type S3VolumeDriverParameters struct {
320 SecretAccessKey string
324 LocationConstraint bool
327 ConnectTimeout Duration
334 type AzureVolumeDriverParameters struct {
335 StorageAccountName string
336 StorageAccountKey string
337 StorageBaseURL string
339 RequestTimeout Duration
340 ListBlobsRetryDelay Duration
341 ListBlobsMaxAttempts int
344 type DirectoryVolumeDriverParameters struct {
349 type VolumeAccess struct {
353 type Services struct {
356 DispatchCloud Service
358 DispatchSLURM Service
366 WebDAVDownload Service
374 type Service struct {
375 InternalURLs map[URL]ServiceInstance
379 type TestUser struct {
384 // URL is a url.URL that is also usable as a JSON key/value.
387 // UnmarshalText implements encoding.TextUnmarshaler so URL can be
388 // used as a JSON key/value.
389 func (su *URL) UnmarshalText(text []byte) error {
390 u, err := url.Parse(string(text))
393 if su.Path == "" && su.Host != "" {
394 // http://example really means http://example/
401 func (su URL) MarshalText() ([]byte, error) {
402 return []byte(su.String()), nil
405 func (su URL) String() string {
406 return (*url.URL)(&su).String()
409 type TLSVersion uint16
411 func (v TLSVersion) MarshalText() ([]byte, error) {
415 case tls.VersionTLS10:
416 return []byte("1.0"), nil
417 case tls.VersionTLS11:
418 return []byte("1.1"), nil
419 case tls.VersionTLS12:
420 return []byte("1.2"), nil
421 case tls.VersionTLS13:
422 return []byte("1.3"), nil
424 return nil, fmt.Errorf("unsupported TLSVersion %x", v)
428 func (v *TLSVersion) UnmarshalJSON(text []byte) error {
429 if len(text) > 0 && text[0] == '"' {
431 err := json.Unmarshal(text, &s)
437 switch string(text) {
441 *v = tls.VersionTLS10
443 *v = tls.VersionTLS11
445 *v = tls.VersionTLS12
447 *v = tls.VersionTLS13
449 return fmt.Errorf("unsupported TLSVersion %q", text)
454 type ServiceInstance struct {
456 Rendezvous string `json:",omitempty"`
459 type PostgreSQL struct {
460 Connection PostgreSQLConnection
464 type PostgreSQLConnection map[string]string
466 type RemoteCluster struct {
474 type CUDAFeatures struct {
476 HardwareCapability string
480 type InstanceType struct {
481 Name string `json:"-"`
485 Scratch ByteSize `json:"-"`
486 IncludedScratch ByteSize
487 AddedScratch ByteSize
493 type ContainersConfig struct {
494 CloudVMs CloudVMsConfig
495 CrunchRunCommand string
496 CrunchRunArgumentsList []string
497 DefaultKeepCacheRAM ByteSize
498 DispatchPrivateKey string
499 LogReuseDecisions bool
500 MaxDispatchAttempts int
502 MinRetryPeriod Duration
503 ReserveExtraRAM ByteSize
504 StaleLockTimeout Duration
505 SupportedDockerImageFormats StringSet
506 AlwaysUsePreemptibleInstances bool
507 PreemptiblePriceFactor float64
508 MaximumPriceFactor float64
510 LocalKeepBlobBuffersPerVCPU int
511 LocalKeepLogsToContainerLog string
515 GitInternalDir string
519 SweepInterval Duration
521 LogSecondsBetweenEvents Duration
522 LogThrottlePeriod Duration
525 LimitLogBytesPerJob int
526 LogPartialLineThrottlePeriod Duration
527 LogUpdatePeriod Duration
528 LogUpdateSize ByteSize
536 SbatchArgumentsList []string
537 SbatchEnvironmentVariables map[string]string
539 DNSServerConfDir string
540 DNSServerConfTemplate string
541 DNSServerReloadCommand string
542 DNSServerUpdateCommand string
543 ComputeNodeDomain string
544 ComputeNodeNameservers StringSet
545 AssignNodeHostname string
550 BsubArgumentsList []string
551 BsubCUDAArguments []string
552 MaxRunTimeOverhead Duration
553 MaxRunTimeDefault Duration
557 type CloudVMsConfig struct {
560 BootProbeCommand string
561 InstanceInitCommand string
562 DeployRunnerBinary string
565 MaxCloudOpsPerSecond int
566 MaxProbesPerSecond int
567 MaxConcurrentInstanceCreateOps int
569 InitialQuotaEstimate int
570 SupervisorFraction float64
571 PollInterval Duration
572 ProbeInterval Duration
574 SyncInterval Duration
575 TimeoutBooting Duration
577 TimeoutProbe Duration
578 TimeoutShutdown Duration
579 TimeoutSignal Duration
580 TimeoutStaleRunLock Duration
582 ResourceTags map[string]string
586 DriverParameters json.RawMessage
589 type InstanceTypeMap map[string]InstanceType
591 var errDuplicateInstanceTypeName = errors.New("duplicate instance type name")
593 // UnmarshalJSON does special handling of InstanceTypes:
595 // - populate computed fields (Name and Scratch)
597 // - error out if InstancesTypes are populated as an array, which was
598 // deprecated in Arvados 1.2.0
599 func (it *InstanceTypeMap) UnmarshalJSON(data []byte) error {
600 fixup := func(t InstanceType) (InstanceType, error) {
601 if t.ProviderType == "" {
602 t.ProviderType = t.Name
604 // If t.Scratch is set in the configuration file, it will be ignored and overwritten.
605 // It will also generate a "deprecated or unknown config entry" warning.
606 t.Scratch = t.IncludedScratch + t.AddedScratch
610 if len(data) > 0 && data[0] == '[' {
611 return fmt.Errorf("InstanceTypes must be specified as a map, not an array, see https://doc.arvados.org/admin/config.html")
613 var hash map[string]InstanceType
614 err := json.Unmarshal(data, &hash)
618 // Fill in Name field (and ProviderType field, if not
619 // specified) using hash key.
620 *it = InstanceTypeMap(hash)
621 for name, t := range *it {
632 type StringSet map[string]struct{}
634 // UnmarshalJSON handles old config files that provide an array of
635 // instance types instead of a hash.
636 func (ss *StringSet) UnmarshalJSON(data []byte) error {
637 if len(data) > 0 && data[0] == '[' {
639 err := json.Unmarshal(data, &arr)
647 *ss = make(map[string]struct{}, len(arr))
648 for _, t := range arr {
649 (*ss)[t] = struct{}{}
653 var hash map[string]struct{}
654 err := json.Unmarshal(data, &hash)
658 *ss = make(map[string]struct{}, len(hash))
659 for t := range hash {
660 (*ss)[t] = struct{}{}
666 type ServiceName string
669 ServiceNameController ServiceName = "arvados-controller"
670 ServiceNameDispatchCloud ServiceName = "arvados-dispatch-cloud"
671 ServiceNameDispatchLSF ServiceName = "arvados-dispatch-lsf"
672 ServiceNameDispatchSLURM ServiceName = "crunch-dispatch-slurm"
673 ServiceNameGitHTTP ServiceName = "arvados-git-httpd"
674 ServiceNameHealth ServiceName = "arvados-health"
675 ServiceNameKeepbalance ServiceName = "keep-balance"
676 ServiceNameKeepproxy ServiceName = "keepproxy"
677 ServiceNameKeepstore ServiceName = "keepstore"
678 ServiceNameKeepweb ServiceName = "keep-web"
679 ServiceNameRailsAPI ServiceName = "arvados-api-server"
680 ServiceNameWebsocket ServiceName = "arvados-ws"
681 ServiceNameWorkbench1 ServiceName = "arvados-workbench1"
682 ServiceNameWorkbench2 ServiceName = "arvados-workbench2"
685 // Map returns all services as a map, suitable for iterating over all
686 // services or looking up a service by name.
687 func (svcs Services) Map() map[ServiceName]Service {
688 return map[ServiceName]Service{
689 ServiceNameController: svcs.Controller,
690 ServiceNameDispatchCloud: svcs.DispatchCloud,
691 ServiceNameDispatchLSF: svcs.DispatchLSF,
692 ServiceNameDispatchSLURM: svcs.DispatchSLURM,
693 ServiceNameGitHTTP: svcs.GitHTTP,
694 ServiceNameHealth: svcs.Health,
695 ServiceNameKeepbalance: svcs.Keepbalance,
696 ServiceNameKeepproxy: svcs.Keepproxy,
697 ServiceNameKeepstore: svcs.Keepstore,
698 ServiceNameKeepweb: svcs.WebDAV,
699 ServiceNameRailsAPI: svcs.RailsAPI,
700 ServiceNameWebsocket: svcs.Websocket,
701 ServiceNameWorkbench1: svcs.Workbench1,
702 ServiceNameWorkbench2: svcs.Workbench2,