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 ClusterID string `json:"-"`
72 ManagementToken string
73 SystemRootToken string
75 InstanceTypes InstanceTypeMap
76 Containers ContainersConfig
77 RemoteClusters map[string]RemoteCluster
81 AsyncPermissionsUpdateInterval Duration
82 DisabledAPIs StringSet
83 MaxIndexDatabaseRead int
84 MaxItemsPerResponse int
85 MaxConcurrentRequests int
86 MaxKeepBlobBuffers int
87 MaxRequestAmplification int
89 RequestTimeout Duration
91 WebsocketClientEventQueue int
92 WebsocketServerEventQueue int
93 KeepServiceRequestTimeout Duration
98 UnloggedAttributes StringSet
102 BlobSigningKey string
103 BlobSigningTTL Duration
105 BlobTrashLifetime Duration
106 BlobTrashCheckInterval Duration
107 BlobTrashConcurrency int
108 BlobDeleteConcurrency int
109 BlobReplicateConcurrency int
110 CollectionVersioning bool
111 DefaultTrashLifetime Duration
112 DefaultReplication int
113 ManagedProperties map[string]struct {
118 PreserveVersionIfIdle Duration
119 TrashSweepInterval Duration
121 ForwardSlashNameSubstitution string
124 BlobMissingReport string
125 BalancePeriod Duration
126 BalanceCollectionBatch int
127 BalanceCollectionBuffers int
128 BalanceTimeout Duration
130 WebDAVCache WebDAVCacheConfig
145 SearchAttribute string
146 SearchBindUser string
147 SearchBindPassword string
150 EmailAttribute string
151 UsernameAttribute string
157 AlternateEmailAddresses bool
158 AuthenticationRequestParameters map[string]string
160 OpenIDConnect struct {
166 EmailVerifiedClaim string
168 AuthenticationRequestParameters map[string]string
173 DefaultEmailDomain string
178 ProviderAppSecret string
182 Users map[string]TestUser
185 RemoteTokenRefresh Duration
186 TokenLifetime Duration
187 TrustedClients map[string]struct{}
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
268 ForceLegacyAPI14 bool
272 AccessViaHosts map[URL]VolumeAccess
275 StorageClasses map[string]bool
277 DriverParameters json.RawMessage
280 type S3VolumeDriverParameters struct {
287 LocationConstraint bool
289 UseAWSS3v2Driver bool
291 ConnectTimeout Duration
297 type AzureVolumeDriverParameters struct {
298 StorageAccountName string
299 StorageAccountKey string
300 StorageBaseURL string
302 RequestTimeout Duration
303 ListBlobsRetryDelay Duration
304 ListBlobsMaxAttempts int
307 type DirectoryVolumeDriverParameters struct {
312 type VolumeAccess struct {
316 type Services struct {
319 DispatchCloud Service
328 WebDAVDownload Service
336 type Service struct {
337 InternalURLs map[URL]ServiceInstance
341 type TestUser struct {
346 // URL is a url.URL that is also usable as a JSON key/value.
349 // UnmarshalText implements encoding.TextUnmarshaler so URL can be
350 // used as a JSON key/value.
351 func (su *URL) UnmarshalText(text []byte) error {
352 u, err := url.Parse(string(text))
355 if su.Path == "" && su.Host != "" {
356 // http://example really means http://example/
363 func (su URL) MarshalText() ([]byte, error) {
364 return []byte(fmt.Sprintf("%s", (*url.URL)(&su).String())), nil
367 func (su URL) String() string {
368 return (*url.URL)(&su).String()
371 type ServiceInstance struct {
372 Rendezvous string `json:",omitempty"`
375 type PostgreSQL struct {
376 Connection PostgreSQLConnection
380 type PostgreSQLConnection map[string]string
382 type RemoteCluster struct {
390 type InstanceType struct {
396 IncludedScratch ByteSize
397 AddedScratch ByteSize
402 type ContainersConfig struct {
403 CloudVMs CloudVMsConfig
404 CrunchRunCommand string
405 CrunchRunArgumentsList []string
406 DefaultKeepCacheRAM ByteSize
407 DispatchPrivateKey string
408 LogReuseDecisions bool
410 MaxDispatchAttempts int
412 MinRetryPeriod Duration
413 ReserveExtraRAM ByteSize
414 StaleLockTimeout Duration
415 SupportedDockerImageFormats StringSet
416 UsePreemptibleInstances bool
420 GitInternalDir string
425 LogSecondsBetweenEvents Duration
426 LogThrottlePeriod Duration
429 LimitLogBytesPerJob int
430 LogPartialLineThrottlePeriod Duration
431 LogUpdatePeriod Duration
432 LogUpdateSize ByteSize
440 SbatchArgumentsList []string
441 SbatchEnvironmentVariables map[string]string
443 DNSServerConfDir string
444 DNSServerConfTemplate string
445 DNSServerReloadCommand string
446 DNSServerUpdateCommand string
447 ComputeNodeDomain string
448 ComputeNodeNameservers StringSet
449 AssignNodeHostname string
454 type CloudVMsConfig struct {
457 BootProbeCommand string
458 DeployRunnerBinary string
460 MaxCloudOpsPerSecond int
461 MaxProbesPerSecond int
462 MaxConcurrentInstanceCreateOps int
463 PollInterval Duration
464 ProbeInterval Duration
466 SyncInterval Duration
467 TimeoutBooting Duration
469 TimeoutProbe Duration
470 TimeoutShutdown Duration
471 TimeoutSignal Duration
472 TimeoutStaleRunLock Duration
474 ResourceTags map[string]string
478 DriverParameters json.RawMessage
481 type InstanceTypeMap map[string]InstanceType
483 var errDuplicateInstanceTypeName = errors.New("duplicate instance type name")
485 // UnmarshalJSON handles old config files that provide an array of
486 // instance types instead of a hash.
487 func (it *InstanceTypeMap) UnmarshalJSON(data []byte) error {
488 fixup := func(t InstanceType) (InstanceType, error) {
489 if t.ProviderType == "" {
490 t.ProviderType = t.Name
493 t.Scratch = t.IncludedScratch + t.AddedScratch
494 } else if t.AddedScratch == 0 {
495 t.AddedScratch = t.Scratch - t.IncludedScratch
496 } else if t.IncludedScratch == 0 {
497 t.IncludedScratch = t.Scratch - t.AddedScratch
500 if t.Scratch != (t.IncludedScratch + t.AddedScratch) {
501 return t, fmt.Errorf("InstanceType %q: Scratch != (IncludedScratch + AddedScratch)", t.Name)
506 if len(data) > 0 && data[0] == '[' {
507 var arr []InstanceType
508 err := json.Unmarshal(data, &arr)
516 *it = make(map[string]InstanceType, len(arr))
517 for _, t := range arr {
518 if _, ok := (*it)[t.Name]; ok {
519 return errDuplicateInstanceTypeName
529 var hash map[string]InstanceType
530 err := json.Unmarshal(data, &hash)
534 // Fill in Name field (and ProviderType field, if not
535 // specified) using hash key.
536 *it = InstanceTypeMap(hash)
537 for name, t := range *it {
548 type StringSet map[string]struct{}
550 // UnmarshalJSON handles old config files that provide an array of
551 // instance types instead of a hash.
552 func (ss *StringSet) UnmarshalJSON(data []byte) error {
553 if len(data) > 0 && data[0] == '[' {
555 err := json.Unmarshal(data, &arr)
563 *ss = make(map[string]struct{}, len(arr))
564 for _, t := range arr {
565 (*ss)[t] = struct{}{}
569 var hash map[string]struct{}
570 err := json.Unmarshal(data, &hash)
574 *ss = make(map[string]struct{}, len(hash))
575 for t := range hash {
576 (*ss)[t] = struct{}{}
582 type ServiceName string
585 ServiceNameRailsAPI ServiceName = "arvados-api-server"
586 ServiceNameController ServiceName = "arvados-controller"
587 ServiceNameDispatchCloud ServiceName = "arvados-dispatch-cloud"
588 ServiceNameHealth ServiceName = "arvados-health"
589 ServiceNameWorkbench1 ServiceName = "arvados-workbench1"
590 ServiceNameWorkbench2 ServiceName = "arvados-workbench2"
591 ServiceNameWebsocket ServiceName = "arvados-ws"
592 ServiceNameKeepbalance ServiceName = "keep-balance"
593 ServiceNameKeepweb ServiceName = "keep-web"
594 ServiceNameKeepproxy ServiceName = "keepproxy"
595 ServiceNameKeepstore ServiceName = "keepstore"
598 // Map returns all services as a map, suitable for iterating over all
599 // services or looking up a service by name.
600 func (svcs Services) Map() map[ServiceName]Service {
601 return map[ServiceName]Service{
602 ServiceNameRailsAPI: svcs.RailsAPI,
603 ServiceNameController: svcs.Controller,
604 ServiceNameDispatchCloud: svcs.DispatchCloud,
605 ServiceNameHealth: svcs.Health,
606 ServiceNameWorkbench1: svcs.Workbench1,
607 ServiceNameWorkbench2: svcs.Workbench2,
608 ServiceNameWebsocket: svcs.Websocket,
609 ServiceNameKeepbalance: svcs.Keepbalance,
610 ServiceNameKeepweb: svcs.WebDAV,
611 ServiceNameKeepproxy: svcs.Keepproxy,
612 ServiceNameKeepstore: svcs.Keepstore,