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
72 ClusterID string `json:"-"`
73 ManagementToken string
74 SystemRootToken string
76 InstanceTypes InstanceTypeMap
77 Containers ContainersConfig
78 RemoteClusters map[string]RemoteCluster
82 AsyncPermissionsUpdateInterval Duration
83 DisabledAPIs StringSet
84 MaxIndexDatabaseRead int
85 MaxItemsPerResponse int
86 MaxConcurrentRequests int
87 MaxKeepBlobBuffers int
88 MaxRequestAmplification int
90 MaxTokenLifetime Duration
91 RequestTimeout Duration
93 WebsocketClientEventQueue int
94 WebsocketServerEventQueue int
95 KeepServiceRequestTimeout Duration
100 UnloggedAttributes StringSet
104 BlobSigningKey string
105 BlobSigningTTL Duration
107 BlobTrashLifetime Duration
108 BlobTrashCheckInterval Duration
109 BlobTrashConcurrency int
110 BlobDeleteConcurrency int
111 BlobReplicateConcurrency int
112 CollectionVersioning bool
113 DefaultTrashLifetime Duration
114 DefaultReplication int
115 ManagedProperties map[string]struct {
120 PreserveVersionIfIdle Duration
121 TrashSweepInterval Duration
123 ForwardSlashNameSubstitution string
126 BlobMissingReport string
127 BalancePeriod Duration
128 BalanceCollectionBatch int
129 BalanceCollectionBuffers int
130 BalanceTimeout Duration
132 WebDAVCache WebDAVCacheConfig
147 SearchAttribute string
148 SearchBindUser string
149 SearchBindPassword string
152 EmailAttribute string
153 UsernameAttribute string
159 AlternateEmailAddresses bool
160 AuthenticationRequestParameters map[string]string
162 OpenIDConnect struct {
168 EmailVerifiedClaim string
170 AcceptAccessToken bool
171 AcceptAccessTokenScope string
172 AuthenticationRequestParameters map[string]string
177 DefaultEmailDomain string
181 Users map[string]TestUser
184 RemoteTokenRefresh Duration
185 TokenLifetime Duration
186 TrustedClients map[string]struct{}
187 IssueTrustedTokens bool
190 MailchimpAPIKey string
191 MailchimpListID string
192 SendUserSetupNotificationEmail bool
193 IssueReporterEmailFrom string
194 IssueReporterEmailTo string
195 SupportEmailAddress string
201 MaxRequestLogParamsSize int
209 AnonymousUserToken string
210 AdminNotifierEmailFrom string
211 AutoAdminFirstUser bool
212 AutoAdminUserWithEmail string
213 AutoSetupNewUsers bool
214 AutoSetupNewUsersWithRepository bool
215 AutoSetupNewUsersWithVmUUID string
216 AutoSetupUsernameBlacklist StringSet
217 EmailSubjectPrefix string
218 NewInactiveUserNotificationRecipients StringSet
219 NewUserNotificationRecipients StringSet
220 NewUsersAreActive bool
221 UserNotifierEmailFrom string
222 UserProfileNotificationAddress string
223 PreferDomainForUsername string
224 UserSetupMailText string
226 Volumes map[string]Volume
228 ActivationContactLink string
229 APIClientConnectTimeout Duration
230 APIClientReceiveTimeout Duration
231 APIResponseCompression bool
232 ApplicationMimetypesWithViewIcon StringSet
233 ArvadosDocsite string
234 ArvadosPublicDataDocURL string
235 DefaultOpenIdPrefix string
236 EnableGettingStartedPopup bool
237 EnablePublicProjectsPage bool
238 FileViewersConfigURL string
239 LogViewerMaxBytes ByteSize
240 MultiSiteSearch string
241 ProfilingEnabled bool
243 RepositoryCache string
244 RunningJobLogRecordsToFetch int
246 ShowRecentCollectionsOnDashboard bool
247 ShowUserAgreementInline bool
248 ShowUserNotifications bool
251 UserProfileFormFields map[string]struct {
253 FormFieldTitle string
254 FormFieldDescription string
257 Options map[string]struct{}
259 UserProfileFormMessage string
261 WelcomePageHTML string
262 InactivePageHTML string
263 SSHHelpPageHTML string
264 SSHHelpHostSuffix string
270 AccessViaHosts map[URL]VolumeAccess
273 StorageClasses map[string]bool
275 DriverParameters json.RawMessage
278 type S3VolumeDriverParameters struct {
281 SecretAccessKey string
285 LocationConstraint bool
287 UseAWSS3v2Driver bool
289 ConnectTimeout Duration
295 type AzureVolumeDriverParameters struct {
296 StorageAccountName string
297 StorageAccountKey string
298 StorageBaseURL string
300 RequestTimeout Duration
301 ListBlobsRetryDelay Duration
302 ListBlobsMaxAttempts int
305 type DirectoryVolumeDriverParameters struct {
310 type VolumeAccess struct {
314 type Services struct {
317 DispatchCloud Service
325 WebDAVDownload Service
333 type Service struct {
334 InternalURLs map[URL]ServiceInstance
338 type TestUser struct {
343 // URL is a url.URL that is also usable as a JSON key/value.
346 // UnmarshalText implements encoding.TextUnmarshaler so URL can be
347 // used as a JSON key/value.
348 func (su *URL) UnmarshalText(text []byte) error {
349 u, err := url.Parse(string(text))
352 if su.Path == "" && su.Host != "" {
353 // http://example really means http://example/
360 func (su URL) MarshalText() ([]byte, error) {
361 return []byte(fmt.Sprintf("%s", (*url.URL)(&su).String())), nil
364 func (su URL) String() string {
365 return (*url.URL)(&su).String()
368 type ServiceInstance struct {
369 Rendezvous string `json:",omitempty"`
372 type PostgreSQL struct {
373 Connection PostgreSQLConnection
377 type PostgreSQLConnection map[string]string
379 type RemoteCluster struct {
387 type InstanceType struct {
393 IncludedScratch ByteSize
394 AddedScratch ByteSize
399 type ContainersConfig struct {
400 CloudVMs CloudVMsConfig
401 CrunchRunCommand string
402 CrunchRunArgumentsList []string
403 DefaultKeepCacheRAM ByteSize
404 DispatchPrivateKey string
405 LogReuseDecisions bool
407 MaxDispatchAttempts int
409 MinRetryPeriod Duration
410 ReserveExtraRAM ByteSize
411 StaleLockTimeout Duration
412 SupportedDockerImageFormats StringSet
413 UsePreemptibleInstances bool
418 GitInternalDir string
423 LogSecondsBetweenEvents Duration
424 LogThrottlePeriod Duration
427 LimitLogBytesPerJob int
428 LogPartialLineThrottlePeriod Duration
429 LogUpdatePeriod Duration
430 LogUpdateSize ByteSize
438 SbatchArgumentsList []string
439 SbatchEnvironmentVariables map[string]string
441 DNSServerConfDir string
442 DNSServerConfTemplate string
443 DNSServerReloadCommand string
444 DNSServerUpdateCommand string
445 ComputeNodeDomain string
446 ComputeNodeNameservers StringSet
447 AssignNodeHostname string
452 type CloudVMsConfig struct {
455 BootProbeCommand string
456 DeployRunnerBinary string
458 MaxCloudOpsPerSecond int
459 MaxProbesPerSecond int
460 MaxConcurrentInstanceCreateOps int
461 PollInterval Duration
462 ProbeInterval Duration
464 SyncInterval Duration
465 TimeoutBooting Duration
467 TimeoutProbe Duration
468 TimeoutShutdown Duration
469 TimeoutSignal Duration
470 TimeoutStaleRunLock Duration
472 ResourceTags map[string]string
476 DriverParameters json.RawMessage
479 type InstanceTypeMap map[string]InstanceType
481 var errDuplicateInstanceTypeName = errors.New("duplicate instance type name")
483 // UnmarshalJSON handles old config files that provide an array of
484 // instance types instead of a hash.
485 func (it *InstanceTypeMap) UnmarshalJSON(data []byte) error {
486 fixup := func(t InstanceType) (InstanceType, error) {
487 if t.ProviderType == "" {
488 t.ProviderType = t.Name
491 t.Scratch = t.IncludedScratch + t.AddedScratch
492 } else if t.AddedScratch == 0 {
493 t.AddedScratch = t.Scratch - t.IncludedScratch
494 } else if t.IncludedScratch == 0 {
495 t.IncludedScratch = t.Scratch - t.AddedScratch
498 if t.Scratch != (t.IncludedScratch + t.AddedScratch) {
499 return t, fmt.Errorf("InstanceType %q: Scratch != (IncludedScratch + AddedScratch)", t.Name)
504 if len(data) > 0 && data[0] == '[' {
505 var arr []InstanceType
506 err := json.Unmarshal(data, &arr)
514 *it = make(map[string]InstanceType, len(arr))
515 for _, t := range arr {
516 if _, ok := (*it)[t.Name]; ok {
517 return errDuplicateInstanceTypeName
527 var hash map[string]InstanceType
528 err := json.Unmarshal(data, &hash)
532 // Fill in Name field (and ProviderType field, if not
533 // specified) using hash key.
534 *it = InstanceTypeMap(hash)
535 for name, t := range *it {
546 type StringSet map[string]struct{}
548 // UnmarshalJSON handles old config files that provide an array of
549 // instance types instead of a hash.
550 func (ss *StringSet) UnmarshalJSON(data []byte) error {
551 if len(data) > 0 && data[0] == '[' {
553 err := json.Unmarshal(data, &arr)
561 *ss = make(map[string]struct{}, len(arr))
562 for _, t := range arr {
563 (*ss)[t] = struct{}{}
567 var hash map[string]struct{}
568 err := json.Unmarshal(data, &hash)
572 *ss = make(map[string]struct{}, len(hash))
573 for t := range hash {
574 (*ss)[t] = struct{}{}
580 type ServiceName string
583 ServiceNameRailsAPI ServiceName = "arvados-api-server"
584 ServiceNameController ServiceName = "arvados-controller"
585 ServiceNameDispatchCloud ServiceName = "arvados-dispatch-cloud"
586 ServiceNameHealth ServiceName = "arvados-health"
587 ServiceNameWorkbench1 ServiceName = "arvados-workbench1"
588 ServiceNameWorkbench2 ServiceName = "arvados-workbench2"
589 ServiceNameWebsocket ServiceName = "arvados-ws"
590 ServiceNameKeepbalance ServiceName = "keep-balance"
591 ServiceNameKeepweb ServiceName = "keep-web"
592 ServiceNameKeepproxy ServiceName = "keepproxy"
593 ServiceNameKeepstore ServiceName = "keepstore"
596 // Map returns all services as a map, suitable for iterating over all
597 // services or looking up a service by name.
598 func (svcs Services) Map() map[ServiceName]Service {
599 return map[ServiceName]Service{
600 ServiceNameRailsAPI: svcs.RailsAPI,
601 ServiceNameController: svcs.Controller,
602 ServiceNameDispatchCloud: svcs.DispatchCloud,
603 ServiceNameHealth: svcs.Health,
604 ServiceNameWorkbench1: svcs.Workbench1,
605 ServiceNameWorkbench2: svcs.Workbench2,
606 ServiceNameWebsocket: svcs.Websocket,
607 ServiceNameKeepbalance: svcs.Keepbalance,
608 ServiceNameKeepweb: svcs.WebDAV,
609 ServiceNameKeepproxy: svcs.Keepproxy,
610 ServiceNameKeepstore: svcs.Keepstore,