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
71 type UploadDownloadPermission struct {
76 type UploadDownloadRolePermissions struct {
77 User UploadDownloadPermission
78 Admin UploadDownloadPermission
82 ClusterID string `json:"-"`
83 ManagementToken string
84 SystemRootToken string
86 InstanceTypes InstanceTypeMap
87 Containers ContainersConfig
88 RemoteClusters map[string]RemoteCluster
92 AsyncPermissionsUpdateInterval Duration
93 DisabledAPIs StringSet
94 MaxIndexDatabaseRead int
95 MaxItemsPerResponse int
96 MaxConcurrentRequests int
97 MaxKeepBlobBuffers int
98 MaxRequestAmplification int
100 MaxTokenLifetime Duration
101 RequestTimeout Duration
103 WebsocketClientEventQueue int
104 WebsocketServerEventQueue int
105 KeepServiceRequestTimeout Duration
110 UnloggedAttributes StringSet
114 BlobSigningKey string
115 BlobSigningTTL Duration
117 BlobTrashLifetime Duration
118 BlobTrashCheckInterval Duration
119 BlobTrashConcurrency int
120 BlobDeleteConcurrency int
121 BlobReplicateConcurrency int
122 CollectionVersioning bool
123 DefaultTrashLifetime Duration
124 DefaultReplication int
125 ManagedProperties map[string]struct {
130 PreserveVersionIfIdle Duration
131 TrashSweepInterval Duration
133 ForwardSlashNameSubstitution string
136 BlobMissingReport string
137 BalancePeriod Duration
138 BalanceCollectionBatch int
139 BalanceCollectionBuffers int
140 BalanceTimeout Duration
141 BalanceUpdateLimit int
143 WebDAVCache WebDAVCacheConfig
145 KeepproxyPermission UploadDownloadRolePermissions
146 WebDAVPermission UploadDownloadRolePermissions
162 SearchAttribute string
163 SearchBindUser string
164 SearchBindPassword string
167 EmailAttribute string
168 UsernameAttribute string
174 AlternateEmailAddresses bool
175 AuthenticationRequestParameters map[string]string
177 OpenIDConnect struct {
183 EmailVerifiedClaim string
185 AcceptAccessToken bool
186 AcceptAccessTokenScope string
187 AuthenticationRequestParameters map[string]string
192 DefaultEmailDomain string
196 Users map[string]TestUser
199 RemoteTokenRefresh Duration
200 TokenLifetime Duration
201 TrustedClients map[string]struct{}
202 IssueTrustedTokens bool
205 MailchimpAPIKey string
206 MailchimpListID string
207 SendUserSetupNotificationEmail bool
208 IssueReporterEmailFrom string
209 IssueReporterEmailTo string
210 SupportEmailAddress string
216 MaxRequestLogParamsSize int
224 AnonymousUserToken string
225 AdminNotifierEmailFrom string
226 AutoAdminFirstUser bool
227 AutoAdminUserWithEmail string
228 AutoSetupNewUsers bool
229 AutoSetupNewUsersWithRepository bool
230 AutoSetupNewUsersWithVmUUID string
231 AutoSetupUsernameBlacklist StringSet
232 EmailSubjectPrefix string
233 NewInactiveUserNotificationRecipients StringSet
234 NewUserNotificationRecipients StringSet
235 NewUsersAreActive bool
236 UserNotifierEmailFrom string
237 UserNotifierEmailBcc StringSet
238 UserProfileNotificationAddress string
239 PreferDomainForUsername string
240 UserSetupMailText string
242 StorageClasses map[string]StorageClassConfig
243 Volumes map[string]Volume
245 ActivationContactLink string
246 APIClientConnectTimeout Duration
247 APIClientReceiveTimeout Duration
248 APIResponseCompression bool
249 ApplicationMimetypesWithViewIcon StringSet
250 ArvadosDocsite string
251 ArvadosPublicDataDocURL string
252 DefaultOpenIdPrefix string
253 EnableGettingStartedPopup bool
254 EnablePublicProjectsPage bool
255 FileViewersConfigURL string
256 LogViewerMaxBytes ByteSize
257 MultiSiteSearch string
258 ProfilingEnabled bool
260 RepositoryCache string
261 RunningJobLogRecordsToFetch int
263 ShowRecentCollectionsOnDashboard bool
264 ShowUserAgreementInline bool
265 ShowUserNotifications bool
268 UserProfileFormFields map[string]struct {
270 FormFieldTitle string
271 FormFieldDescription string
274 Options map[string]struct{}
276 UserProfileFormMessage string
278 WelcomePageHTML string
279 InactivePageHTML string
280 SSHHelpPageHTML string
281 SSHHelpHostSuffix string
286 type StorageClassConfig struct {
292 AccessViaHosts map[URL]VolumeAccess
295 StorageClasses map[string]bool
297 DriverParameters json.RawMessage
300 type S3VolumeDriverParameters struct {
303 SecretAccessKey string
307 LocationConstraint bool
309 UseAWSS3v2Driver bool
311 ConnectTimeout Duration
317 type AzureVolumeDriverParameters struct {
318 StorageAccountName string
319 StorageAccountKey string
320 StorageBaseURL string
322 RequestTimeout Duration
323 ListBlobsRetryDelay Duration
324 ListBlobsMaxAttempts int
327 type DirectoryVolumeDriverParameters struct {
332 type VolumeAccess struct {
336 type Services struct {
339 DispatchCloud Service
348 WebDAVDownload Service
356 type Service struct {
357 InternalURLs map[URL]ServiceInstance
361 type TestUser struct {
366 // URL is a url.URL that is also usable as a JSON key/value.
369 // UnmarshalText implements encoding.TextUnmarshaler so URL can be
370 // used as a JSON key/value.
371 func (su *URL) UnmarshalText(text []byte) error {
372 u, err := url.Parse(string(text))
375 if su.Path == "" && su.Host != "" {
376 // http://example really means http://example/
383 func (su URL) MarshalText() ([]byte, error) {
384 return []byte(fmt.Sprintf("%s", (*url.URL)(&su).String())), nil
387 func (su URL) String() string {
388 return (*url.URL)(&su).String()
391 type ServiceInstance struct {
392 Rendezvous string `json:",omitempty"`
395 type PostgreSQL struct {
396 Connection PostgreSQLConnection
400 type PostgreSQLConnection map[string]string
402 type RemoteCluster struct {
410 type InstanceType struct {
416 IncludedScratch ByteSize
417 AddedScratch ByteSize
422 type ContainersConfig struct {
423 CloudVMs CloudVMsConfig
424 CrunchRunCommand string
425 CrunchRunArgumentsList []string
426 DefaultKeepCacheRAM ByteSize
427 DispatchPrivateKey string
428 LogReuseDecisions bool
430 MaxDispatchAttempts int
432 MinRetryPeriod Duration
433 ReserveExtraRAM ByteSize
434 StaleLockTimeout Duration
435 SupportedDockerImageFormats StringSet
436 UsePreemptibleInstances bool
441 GitInternalDir string
446 LogSecondsBetweenEvents Duration
447 LogThrottlePeriod Duration
450 LimitLogBytesPerJob int
451 LogPartialLineThrottlePeriod Duration
452 LogUpdatePeriod Duration
453 LogUpdateSize ByteSize
461 SbatchArgumentsList []string
462 SbatchEnvironmentVariables map[string]string
464 DNSServerConfDir string
465 DNSServerConfTemplate string
466 DNSServerReloadCommand string
467 DNSServerUpdateCommand string
468 ComputeNodeDomain string
469 ComputeNodeNameservers StringSet
470 AssignNodeHostname string
475 BsubArgumentsList []string
479 type CloudVMsConfig struct {
482 BootProbeCommand string
483 DeployRunnerBinary string
485 MaxCloudOpsPerSecond int
486 MaxProbesPerSecond int
487 MaxConcurrentInstanceCreateOps int
488 PollInterval Duration
489 ProbeInterval Duration
491 SyncInterval Duration
492 TimeoutBooting Duration
494 TimeoutProbe Duration
495 TimeoutShutdown Duration
496 TimeoutSignal Duration
497 TimeoutStaleRunLock Duration
499 ResourceTags map[string]string
503 DriverParameters json.RawMessage
506 type InstanceTypeMap map[string]InstanceType
508 var errDuplicateInstanceTypeName = errors.New("duplicate instance type name")
510 // UnmarshalJSON handles old config files that provide an array of
511 // instance types instead of a hash.
512 func (it *InstanceTypeMap) UnmarshalJSON(data []byte) error {
513 fixup := func(t InstanceType) (InstanceType, error) {
514 if t.ProviderType == "" {
515 t.ProviderType = t.Name
518 t.Scratch = t.IncludedScratch + t.AddedScratch
519 } else if t.AddedScratch == 0 {
520 t.AddedScratch = t.Scratch - t.IncludedScratch
521 } else if t.IncludedScratch == 0 {
522 t.IncludedScratch = t.Scratch - t.AddedScratch
525 if t.Scratch != (t.IncludedScratch + t.AddedScratch) {
526 return t, fmt.Errorf("InstanceType %q: Scratch != (IncludedScratch + AddedScratch)", t.Name)
531 if len(data) > 0 && data[0] == '[' {
532 var arr []InstanceType
533 err := json.Unmarshal(data, &arr)
541 *it = make(map[string]InstanceType, len(arr))
542 for _, t := range arr {
543 if _, ok := (*it)[t.Name]; ok {
544 return errDuplicateInstanceTypeName
554 var hash map[string]InstanceType
555 err := json.Unmarshal(data, &hash)
559 // Fill in Name field (and ProviderType field, if not
560 // specified) using hash key.
561 *it = InstanceTypeMap(hash)
562 for name, t := range *it {
573 type StringSet map[string]struct{}
575 // UnmarshalJSON handles old config files that provide an array of
576 // instance types instead of a hash.
577 func (ss *StringSet) UnmarshalJSON(data []byte) error {
578 if len(data) > 0 && data[0] == '[' {
580 err := json.Unmarshal(data, &arr)
588 *ss = make(map[string]struct{}, len(arr))
589 for _, t := range arr {
590 (*ss)[t] = struct{}{}
594 var hash map[string]struct{}
595 err := json.Unmarshal(data, &hash)
599 *ss = make(map[string]struct{}, len(hash))
600 for t := range hash {
601 (*ss)[t] = struct{}{}
607 type ServiceName string
610 ServiceNameRailsAPI ServiceName = "arvados-api-server"
611 ServiceNameController ServiceName = "arvados-controller"
612 ServiceNameDispatchCloud ServiceName = "arvados-dispatch-cloud"
613 ServiceNameDispatchLSF ServiceName = "arvados-dispatch-lsf"
614 ServiceNameHealth ServiceName = "arvados-health"
615 ServiceNameWorkbench1 ServiceName = "arvados-workbench1"
616 ServiceNameWorkbench2 ServiceName = "arvados-workbench2"
617 ServiceNameWebsocket ServiceName = "arvados-ws"
618 ServiceNameKeepbalance ServiceName = "keep-balance"
619 ServiceNameKeepweb ServiceName = "keep-web"
620 ServiceNameKeepproxy ServiceName = "keepproxy"
621 ServiceNameKeepstore ServiceName = "keepstore"
624 // Map returns all services as a map, suitable for iterating over all
625 // services or looking up a service by name.
626 func (svcs Services) Map() map[ServiceName]Service {
627 return map[ServiceName]Service{
628 ServiceNameRailsAPI: svcs.RailsAPI,
629 ServiceNameController: svcs.Controller,
630 ServiceNameDispatchCloud: svcs.DispatchCloud,
631 ServiceNameDispatchLSF: svcs.DispatchLSF,
632 ServiceNameHealth: svcs.Health,
633 ServiceNameWorkbench1: svcs.Workbench1,
634 ServiceNameWorkbench2: svcs.Workbench2,
635 ServiceNameWebsocket: svcs.Websocket,
636 ServiceNameKeepbalance: svcs.Keepbalance,
637 ServiceNameKeepweb: svcs.WebDAV,
638 ServiceNameKeepproxy: svcs.Keepproxy,
639 ServiceNameKeepstore: svcs.Keepstore,