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 if cc, ok := sc.Clusters[clusterID]; !ok {
53 return nil, fmt.Errorf("cluster %q is not configured", clusterID)
55 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 RailsSessionSecretToken string
90 RequestTimeout Duration
92 WebsocketClientEventQueue int
93 WebsocketServerEventQueue int
94 KeepServiceRequestTimeout Duration
99 UnloggedAttributes StringSet
103 BlobSigningKey string
104 BlobSigningTTL Duration
106 BlobTrashLifetime Duration
107 BlobTrashCheckInterval Duration
108 BlobTrashConcurrency int
109 BlobDeleteConcurrency int
110 BlobReplicateConcurrency int
111 CollectionVersioning bool
112 DefaultTrashLifetime Duration
113 DefaultReplication int
114 ManagedProperties map[string]struct {
119 PreserveVersionIfIdle Duration
120 TrashSweepInterval Duration
122 ForwardSlashNameSubstitution string
125 BlobMissingReport string
126 BalancePeriod Duration
127 BalanceCollectionBatch int
128 BalanceCollectionBuffers int
129 BalanceTimeout Duration
131 WebDAVCache WebDAVCacheConfig
146 SearchAttribute string
147 SearchBindUser string
148 SearchBindPassword string
151 EmailAttribute string
152 UsernameAttribute string
158 AlternateEmailAddresses bool
160 OpenIDConnect struct {
166 EmailVerifiedClaim string
172 DefaultEmailDomain string
177 ProviderAppSecret string
181 Users map[string]TestUser
184 RemoteTokenRefresh Duration
185 TokenLifetime Duration
188 MailchimpAPIKey string
189 MailchimpListID string
190 SendUserSetupNotificationEmail bool
191 IssueReporterEmailFrom string
192 IssueReporterEmailTo string
193 SupportEmailAddress string
199 MaxRequestLogParamsSize int
207 AnonymousUserToken string
208 AdminNotifierEmailFrom string
209 AutoAdminFirstUser bool
210 AutoAdminUserWithEmail string
211 AutoSetupNewUsers bool
212 AutoSetupNewUsersWithRepository bool
213 AutoSetupNewUsersWithVmUUID string
214 AutoSetupUsernameBlacklist StringSet
215 EmailSubjectPrefix string
216 NewInactiveUserNotificationRecipients StringSet
217 NewUserNotificationRecipients StringSet
218 NewUsersAreActive bool
219 UserNotifierEmailFrom string
220 UserProfileNotificationAddress string
221 PreferDomainForUsername string
223 Volumes map[string]Volume
225 ActivationContactLink string
226 APIClientConnectTimeout Duration
227 APIClientReceiveTimeout Duration
228 APIResponseCompression bool
229 ApplicationMimetypesWithViewIcon StringSet
230 ArvadosDocsite string
231 ArvadosPublicDataDocURL string
232 DefaultOpenIdPrefix string
233 EnableGettingStartedPopup bool
234 EnablePublicProjectsPage bool
235 FileViewersConfigURL string
236 LogViewerMaxBytes ByteSize
237 MultiSiteSearch string
238 ProfilingEnabled bool
240 RepositoryCache string
241 RunningJobLogRecordsToFetch int
243 ShowRecentCollectionsOnDashboard bool
244 ShowUserAgreementInline bool
245 ShowUserNotifications bool
248 UserProfileFormFields map[string]struct {
250 FormFieldTitle string
251 FormFieldDescription string
254 Options map[string]struct{}
256 UserProfileFormMessage string
258 WelcomePageHTML string
259 InactivePageHTML string
260 SSHHelpPageHTML string
261 SSHHelpHostSuffix string
265 ForceLegacyAPI14 bool
269 AccessViaHosts map[URL]VolumeAccess
272 StorageClasses map[string]bool
274 DriverParameters json.RawMessage
277 type S3VolumeDriverParameters struct {
284 LocationConstraint bool
286 UseAWSS3v2Driver bool
288 ConnectTimeout Duration
294 type AzureVolumeDriverParameters struct {
295 StorageAccountName string
296 StorageAccountKey string
297 StorageBaseURL string
299 RequestTimeout Duration
300 ListBlobsRetryDelay Duration
301 ListBlobsMaxAttempts int
304 type DirectoryVolumeDriverParameters struct {
309 type VolumeAccess struct {
313 type Services struct {
316 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
417 GitInternalDir string
422 LogSecondsBetweenEvents Duration
423 LogThrottlePeriod Duration
426 LimitLogBytesPerJob int
427 LogPartialLineThrottlePeriod Duration
428 LogUpdatePeriod Duration
429 LogUpdateSize ByteSize
433 SbatchArgumentsList []string
434 SbatchEnvironmentVariables map[string]string
436 DNSServerConfDir string
437 DNSServerConfTemplate string
438 DNSServerReloadCommand string
439 DNSServerUpdateCommand string
440 ComputeNodeDomain string
441 ComputeNodeNameservers StringSet
442 AssignNodeHostname string
447 type CloudVMsConfig struct {
450 BootProbeCommand string
451 DeployRunnerBinary string
453 MaxCloudOpsPerSecond int
454 MaxProbesPerSecond int
455 MaxConcurrentInstanceCreateOps int
456 PollInterval Duration
457 ProbeInterval Duration
459 SyncInterval Duration
460 TimeoutBooting Duration
462 TimeoutProbe Duration
463 TimeoutShutdown Duration
464 TimeoutSignal Duration
466 ResourceTags map[string]string
470 DriverParameters json.RawMessage
473 type InstanceTypeMap map[string]InstanceType
475 var errDuplicateInstanceTypeName = errors.New("duplicate instance type name")
477 // UnmarshalJSON handles old config files that provide an array of
478 // instance types instead of a hash.
479 func (it *InstanceTypeMap) UnmarshalJSON(data []byte) error {
480 fixup := func(t InstanceType) (InstanceType, error) {
481 if t.ProviderType == "" {
482 t.ProviderType = t.Name
485 t.Scratch = t.IncludedScratch + t.AddedScratch
486 } else if t.AddedScratch == 0 {
487 t.AddedScratch = t.Scratch - t.IncludedScratch
488 } else if t.IncludedScratch == 0 {
489 t.IncludedScratch = t.Scratch - t.AddedScratch
492 if t.Scratch != (t.IncludedScratch + t.AddedScratch) {
493 return t, fmt.Errorf("InstanceType %q: Scratch != (IncludedScratch + AddedScratch)", t.Name)
498 if len(data) > 0 && data[0] == '[' {
499 var arr []InstanceType
500 err := json.Unmarshal(data, &arr)
508 *it = make(map[string]InstanceType, len(arr))
509 for _, t := range arr {
510 if _, ok := (*it)[t.Name]; ok {
511 return errDuplicateInstanceTypeName
521 var hash map[string]InstanceType
522 err := json.Unmarshal(data, &hash)
526 // Fill in Name field (and ProviderType field, if not
527 // specified) using hash key.
528 *it = InstanceTypeMap(hash)
529 for name, t := range *it {
540 type StringSet map[string]struct{}
542 // UnmarshalJSON handles old config files that provide an array of
543 // instance types instead of a hash.
544 func (ss *StringSet) UnmarshalJSON(data []byte) error {
545 if len(data) > 0 && data[0] == '[' {
547 err := json.Unmarshal(data, &arr)
555 *ss = make(map[string]struct{}, len(arr))
556 for _, t := range arr {
557 (*ss)[t] = struct{}{}
561 var hash map[string]struct{}
562 err := json.Unmarshal(data, &hash)
566 *ss = make(map[string]struct{}, len(hash))
567 for t := range hash {
568 (*ss)[t] = struct{}{}
574 type ServiceName string
577 ServiceNameRailsAPI ServiceName = "arvados-api-server"
578 ServiceNameController ServiceName = "arvados-controller"
579 ServiceNameDispatchCloud ServiceName = "arvados-dispatch-cloud"
580 ServiceNameHealth ServiceName = "arvados-health"
581 ServiceNameWorkbench1 ServiceName = "arvados-workbench1"
582 ServiceNameWorkbench2 ServiceName = "arvados-workbench2"
583 ServiceNameWebsocket ServiceName = "arvados-ws"
584 ServiceNameKeepbalance ServiceName = "keep-balance"
585 ServiceNameKeepweb ServiceName = "keep-web"
586 ServiceNameKeepproxy ServiceName = "keepproxy"
587 ServiceNameKeepstore ServiceName = "keepstore"
590 // Map returns all services as a map, suitable for iterating over all
591 // services or looking up a service by name.
592 func (svcs Services) Map() map[ServiceName]Service {
593 return map[ServiceName]Service{
594 ServiceNameRailsAPI: svcs.RailsAPI,
595 ServiceNameController: svcs.Controller,
596 ServiceNameDispatchCloud: svcs.DispatchCloud,
597 ServiceNameHealth: svcs.Health,
598 ServiceNameWorkbench1: svcs.Workbench1,
599 ServiceNameWorkbench2: svcs.Workbench2,
600 ServiceNameWebsocket: svcs.Websocket,
601 ServiceNameKeepbalance: svcs.Keepbalance,
602 ServiceNameKeepweb: svcs.WebDAV,
603 ServiceNameKeepproxy: svcs.Keepproxy,
604 ServiceNameKeepstore: svcs.Keepstore,