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
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 SendUserSetupNotificationEmail bool
218 SupportEmailAddress string
223 MaxRequestLogParamsSize int
224 RequestQueueDumpDirectory string
235 ActivatedUsersAreVisibleToOthers bool
236 AnonymousUserToken string
237 AdminNotifierEmailFrom string
238 AutoAdminFirstUser bool
239 AutoAdminUserWithEmail string
240 AutoSetupNewUsers bool
241 AutoSetupNewUsersWithVmUUID string
242 AutoSetupUsernameBlacklist StringSet
243 EmailSubjectPrefix string
244 NewInactiveUserNotificationRecipients StringSet
245 NewUserNotificationRecipients StringSet
246 NewUsersAreActive bool
247 UserNotifierEmailFrom string
248 UserNotifierEmailBcc StringSet
249 UserProfileNotificationAddress string
250 PreferDomainForUsername string
251 UserSetupMailText string
252 RoleGroupsVisibleToAll bool
253 CanCreateRoleGroups bool
254 ActivityLoggingPeriod Duration
255 SyncIgnoredGroups []string
256 SyncRequiredGroups []string
257 SyncUserAccounts bool
258 SyncUserAPITokens bool
262 StorageClasses map[string]StorageClassConfig
263 Volumes map[string]Volume
265 ActivationContactLink string
266 ArvadosDocsite string
267 ArvadosPublicDataDocURL string
268 DisableSharingURLsUI bool
269 FileViewersConfigURL string
270 ShowUserAgreementInline bool
273 UserProfileFormFields map[string]struct {
275 FormFieldTitle string
276 FormFieldDescription string
279 Options map[string]struct{}
281 UserProfileFormMessage string
282 WelcomePageHTML string
283 InactivePageHTML string
284 SSHHelpPageHTML string
285 SSHHelpHostSuffix string
291 type StorageClassConfig struct {
297 AccessViaHosts map[URL]VolumeAccess
299 AllowTrashWhenReadOnly bool
301 StorageClasses map[string]bool
303 DriverParameters json.RawMessage
306 type S3VolumeDriverParameters struct {
309 SecretAccessKey string
313 LocationConstraint bool
316 ConnectTimeout Duration
323 type AzureVolumeDriverParameters struct {
324 StorageAccountName string
325 StorageAccountKey string
326 StorageBaseURL string
328 RequestTimeout Duration
329 ListBlobsRetryDelay Duration
330 ListBlobsMaxAttempts int
333 type DirectoryVolumeDriverParameters struct {
338 type VolumeAccess struct {
342 type Services struct {
345 DispatchCloud Service
347 DispatchSLURM Service
353 WebDAVDownload Service
361 type Service struct {
362 InternalURLs map[URL]ServiceInstance
366 type TestUser struct {
371 // URL is a url.URL that is also usable as a JSON key/value.
374 // UnmarshalText implements encoding.TextUnmarshaler so URL can be
375 // used as a JSON key/value.
376 func (su *URL) UnmarshalText(text []byte) error {
377 u, err := url.Parse(string(text))
380 if su.Path == "" && su.Host != "" {
381 // http://example really means http://example/
388 func (su URL) MarshalText() ([]byte, error) {
389 return []byte(su.String()), nil
392 func (su URL) String() string {
393 return (*url.URL)(&su).String()
396 type TLSVersion uint16
398 func (v TLSVersion) MarshalText() ([]byte, error) {
402 case tls.VersionTLS10:
403 return []byte("1.0"), nil
404 case tls.VersionTLS11:
405 return []byte("1.1"), nil
406 case tls.VersionTLS12:
407 return []byte("1.2"), nil
408 case tls.VersionTLS13:
409 return []byte("1.3"), nil
411 return nil, fmt.Errorf("unsupported TLSVersion %x", v)
415 func (v *TLSVersion) UnmarshalJSON(text []byte) error {
416 if len(text) > 0 && text[0] == '"' {
418 err := json.Unmarshal(text, &s)
424 switch string(text) {
428 *v = tls.VersionTLS10
430 *v = tls.VersionTLS11
432 *v = tls.VersionTLS12
434 *v = tls.VersionTLS13
436 return fmt.Errorf("unsupported TLSVersion %q", text)
441 type ServiceInstance struct {
443 Rendezvous string `json:",omitempty"`
446 type PostgreSQL struct {
447 Connection PostgreSQLConnection
451 type PostgreSQLConnection map[string]string
453 type RemoteCluster struct {
461 type CUDAFeatures struct {
463 HardwareCapability string
467 type InstanceType struct {
468 Name string `json:"-"`
472 Scratch ByteSize `json:"-"`
473 IncludedScratch ByteSize
474 AddedScratch ByteSize
480 type ContainersConfig struct {
481 CloudVMs CloudVMsConfig
482 CrunchRunCommand string
483 CrunchRunArgumentsList []string
484 DefaultKeepCacheRAM ByteSize
485 DispatchPrivateKey string
486 LogReuseDecisions bool
487 MaxDispatchAttempts int
489 MinRetryPeriod Duration
490 ReserveExtraRAM ByteSize
491 StaleLockTimeout Duration
492 SupportedDockerImageFormats StringSet
493 AlwaysUsePreemptibleInstances bool
494 PreemptiblePriceFactor float64
495 MaximumPriceFactor float64
497 LocalKeepBlobBuffersPerVCPU int
498 LocalKeepLogsToContainerLog string
501 LogUpdatePeriod Duration
502 LogUpdateSize ByteSize
510 SbatchArgumentsList []string
511 SbatchEnvironmentVariables map[string]string
515 BsubArgumentsList []string
516 BsubCUDAArguments []string
517 MaxRunTimeOverhead Duration
518 MaxRunTimeDefault Duration
522 type CloudVMsConfig struct {
525 BootProbeCommand string
526 InstanceInitCommand string
527 DeployRunnerBinary string
530 MaxCloudOpsPerSecond int
531 MaxProbesPerSecond int
532 MaxConcurrentInstanceCreateOps int
534 InitialQuotaEstimate int
535 SupervisorFraction float64
536 PollInterval Duration
537 ProbeInterval Duration
539 SyncInterval Duration
540 TimeoutBooting Duration
542 TimeoutProbe Duration
543 TimeoutShutdown Duration
544 TimeoutSignal Duration
545 TimeoutStaleRunLock Duration
547 ResourceTags map[string]string
551 DriverParameters json.RawMessage
554 type InstanceTypeMap map[string]InstanceType
556 var errDuplicateInstanceTypeName = errors.New("duplicate instance type name")
558 // UnmarshalJSON does special handling of InstanceTypes:
560 // - populate computed fields (Name and Scratch)
562 // - error out if InstancesTypes are populated as an array, which was
563 // deprecated in Arvados 1.2.0
564 func (it *InstanceTypeMap) UnmarshalJSON(data []byte) error {
565 fixup := func(t InstanceType) (InstanceType, error) {
566 if t.ProviderType == "" {
567 t.ProviderType = t.Name
569 // If t.Scratch is set in the configuration file, it will be ignored and overwritten.
570 // It will also generate a "deprecated or unknown config entry" warning.
571 t.Scratch = t.IncludedScratch + t.AddedScratch
575 if len(data) > 0 && data[0] == '[' {
576 return fmt.Errorf("InstanceTypes must be specified as a map, not an array, see https://doc.arvados.org/admin/config.html")
578 var hash map[string]InstanceType
579 err := json.Unmarshal(data, &hash)
583 // Fill in Name field (and ProviderType field, if not
584 // specified) using hash key.
585 *it = InstanceTypeMap(hash)
586 for name, t := range *it {
597 type StringSet map[string]struct{}
599 // UnmarshalJSON handles old config files that provide an array of
600 // instance types instead of a hash.
601 func (ss *StringSet) UnmarshalJSON(data []byte) error {
602 if len(data) > 0 && data[0] == '[' {
604 err := json.Unmarshal(data, &arr)
612 *ss = make(map[string]struct{}, len(arr))
613 for _, t := range arr {
614 (*ss)[t] = struct{}{}
618 var hash map[string]struct{}
619 err := json.Unmarshal(data, &hash)
623 *ss = make(map[string]struct{}, len(hash))
624 for t := range hash {
625 (*ss)[t] = struct{}{}
631 type ServiceName string
634 ServiceNameController ServiceName = "arvados-controller"
635 ServiceNameDispatchCloud ServiceName = "arvados-dispatch-cloud"
636 ServiceNameDispatchLSF ServiceName = "arvados-dispatch-lsf"
637 ServiceNameDispatchSLURM ServiceName = "crunch-dispatch-slurm"
638 ServiceNameHealth ServiceName = "arvados-health"
639 ServiceNameKeepbalance ServiceName = "keep-balance"
640 ServiceNameKeepproxy ServiceName = "keepproxy"
641 ServiceNameKeepstore ServiceName = "keepstore"
642 ServiceNameKeepweb ServiceName = "keep-web"
643 ServiceNameRailsAPI ServiceName = "arvados-api-server"
644 ServiceNameWebsocket ServiceName = "arvados-ws"
645 ServiceNameWorkbench1 ServiceName = "arvados-workbench1"
646 ServiceNameWorkbench2 ServiceName = "arvados-workbench2"
649 // Map returns all services as a map, suitable for iterating over all
650 // services or looking up a service by name.
651 func (svcs Services) Map() map[ServiceName]Service {
652 return map[ServiceName]Service{
653 ServiceNameController: svcs.Controller,
654 ServiceNameDispatchCloud: svcs.DispatchCloud,
655 ServiceNameDispatchLSF: svcs.DispatchLSF,
656 ServiceNameDispatchSLURM: svcs.DispatchSLURM,
657 ServiceNameHealth: svcs.Health,
658 ServiceNameKeepbalance: svcs.Keepbalance,
659 ServiceNameKeepproxy: svcs.Keepproxy,
660 ServiceNameKeepstore: svcs.Keepstore,
661 ServiceNameKeepweb: svcs.WebDAV,
662 ServiceNameRailsAPI: svcs.RailsAPI,
663 ServiceNameWebsocket: svcs.Websocket,
664 ServiceNameWorkbench1: svcs.Workbench1,
665 ServiceNameWorkbench2: svcs.Workbench2,