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 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
186 TrustedClients map[string]struct{}
189 MailchimpAPIKey string
190 MailchimpListID string
191 SendUserSetupNotificationEmail bool
192 IssueReporterEmailFrom string
193 IssueReporterEmailTo string
194 SupportEmailAddress string
200 MaxRequestLogParamsSize int
208 AnonymousUserToken string
209 AdminNotifierEmailFrom string
210 AutoAdminFirstUser bool
211 AutoAdminUserWithEmail string
212 AutoSetupNewUsers bool
213 AutoSetupNewUsersWithRepository bool
214 AutoSetupNewUsersWithVmUUID string
215 AutoSetupUsernameBlacklist StringSet
216 EmailSubjectPrefix string
217 NewInactiveUserNotificationRecipients StringSet
218 NewUserNotificationRecipients StringSet
219 NewUsersAreActive bool
220 UserNotifierEmailFrom string
221 UserProfileNotificationAddress string
222 PreferDomainForUsername string
223 UserSetupMailText string
225 Volumes map[string]Volume
227 ActivationContactLink string
228 APIClientConnectTimeout Duration
229 APIClientReceiveTimeout Duration
230 APIResponseCompression bool
231 ApplicationMimetypesWithViewIcon StringSet
232 ArvadosDocsite string
233 ArvadosPublicDataDocURL string
234 DefaultOpenIdPrefix string
235 EnableGettingStartedPopup bool
236 EnablePublicProjectsPage bool
237 FileViewersConfigURL string
238 LogViewerMaxBytes ByteSize
239 MultiSiteSearch string
240 ProfilingEnabled bool
242 RepositoryCache string
243 RunningJobLogRecordsToFetch int
245 ShowRecentCollectionsOnDashboard bool
246 ShowUserAgreementInline bool
247 ShowUserNotifications bool
250 UserProfileFormFields map[string]struct {
252 FormFieldTitle string
253 FormFieldDescription string
256 Options map[string]struct{}
258 UserProfileFormMessage string
260 WelcomePageHTML string
261 InactivePageHTML string
262 SSHHelpPageHTML string
263 SSHHelpHostSuffix string
267 ForceLegacyAPI14 bool
271 AccessViaHosts map[URL]VolumeAccess
274 StorageClasses map[string]bool
276 DriverParameters json.RawMessage
279 type S3VolumeDriverParameters struct {
286 LocationConstraint bool
288 UseAWSS3v2Driver bool
290 ConnectTimeout Duration
296 type AzureVolumeDriverParameters struct {
297 StorageAccountName string
298 StorageAccountKey string
299 StorageBaseURL string
301 RequestTimeout Duration
302 ListBlobsRetryDelay Duration
303 ListBlobsMaxAttempts int
306 type DirectoryVolumeDriverParameters struct {
311 type VolumeAccess struct {
315 type Services struct {
318 DispatchCloud Service
327 WebDAVDownload Service
335 type Service struct {
336 InternalURLs map[URL]ServiceInstance
340 type TestUser struct {
345 // URL is a url.URL that is also usable as a JSON key/value.
348 // UnmarshalText implements encoding.TextUnmarshaler so URL can be
349 // used as a JSON key/value.
350 func (su *URL) UnmarshalText(text []byte) error {
351 u, err := url.Parse(string(text))
354 if su.Path == "" && su.Host != "" {
355 // http://example really means http://example/
362 func (su URL) MarshalText() ([]byte, error) {
363 return []byte(fmt.Sprintf("%s", (*url.URL)(&su).String())), nil
366 func (su URL) String() string {
367 return (*url.URL)(&su).String()
370 type ServiceInstance struct {
371 Rendezvous string `json:",omitempty"`
374 type PostgreSQL struct {
375 Connection PostgreSQLConnection
379 type PostgreSQLConnection map[string]string
381 type RemoteCluster struct {
389 type InstanceType struct {
395 IncludedScratch ByteSize
396 AddedScratch ByteSize
401 type ContainersConfig struct {
402 CloudVMs CloudVMsConfig
403 CrunchRunCommand string
404 CrunchRunArgumentsList []string
405 DefaultKeepCacheRAM ByteSize
406 DispatchPrivateKey string
407 LogReuseDecisions bool
409 MaxDispatchAttempts int
411 MinRetryPeriod Duration
412 ReserveExtraRAM ByteSize
413 StaleLockTimeout Duration
414 SupportedDockerImageFormats StringSet
415 UsePreemptibleInstances bool
419 GitInternalDir string
424 LogSecondsBetweenEvents Duration
425 LogThrottlePeriod Duration
428 LimitLogBytesPerJob int
429 LogPartialLineThrottlePeriod Duration
430 LogUpdatePeriod Duration
431 LogUpdateSize ByteSize
435 SbatchArgumentsList []string
436 SbatchEnvironmentVariables map[string]string
438 DNSServerConfDir string
439 DNSServerConfTemplate string
440 DNSServerReloadCommand string
441 DNSServerUpdateCommand string
442 ComputeNodeDomain string
443 ComputeNodeNameservers StringSet
444 AssignNodeHostname string
449 type CloudVMsConfig struct {
452 BootProbeCommand string
453 DeployRunnerBinary string
455 MaxCloudOpsPerSecond int
456 MaxProbesPerSecond int
457 MaxConcurrentInstanceCreateOps int
458 PollInterval Duration
459 ProbeInterval Duration
461 SyncInterval Duration
462 TimeoutBooting Duration
464 TimeoutProbe Duration
465 TimeoutShutdown Duration
466 TimeoutSignal Duration
467 TimeoutStaleRunLock Duration
469 ResourceTags map[string]string
473 DriverParameters json.RawMessage
476 type InstanceTypeMap map[string]InstanceType
478 var errDuplicateInstanceTypeName = errors.New("duplicate instance type name")
480 // UnmarshalJSON handles old config files that provide an array of
481 // instance types instead of a hash.
482 func (it *InstanceTypeMap) UnmarshalJSON(data []byte) error {
483 fixup := func(t InstanceType) (InstanceType, error) {
484 if t.ProviderType == "" {
485 t.ProviderType = t.Name
488 t.Scratch = t.IncludedScratch + t.AddedScratch
489 } else if t.AddedScratch == 0 {
490 t.AddedScratch = t.Scratch - t.IncludedScratch
491 } else if t.IncludedScratch == 0 {
492 t.IncludedScratch = t.Scratch - t.AddedScratch
495 if t.Scratch != (t.IncludedScratch + t.AddedScratch) {
496 return t, fmt.Errorf("InstanceType %q: Scratch != (IncludedScratch + AddedScratch)", t.Name)
501 if len(data) > 0 && data[0] == '[' {
502 var arr []InstanceType
503 err := json.Unmarshal(data, &arr)
511 *it = make(map[string]InstanceType, len(arr))
512 for _, t := range arr {
513 if _, ok := (*it)[t.Name]; ok {
514 return errDuplicateInstanceTypeName
524 var hash map[string]InstanceType
525 err := json.Unmarshal(data, &hash)
529 // Fill in Name field (and ProviderType field, if not
530 // specified) using hash key.
531 *it = InstanceTypeMap(hash)
532 for name, t := range *it {
543 type StringSet map[string]struct{}
545 // UnmarshalJSON handles old config files that provide an array of
546 // instance types instead of a hash.
547 func (ss *StringSet) UnmarshalJSON(data []byte) error {
548 if len(data) > 0 && data[0] == '[' {
550 err := json.Unmarshal(data, &arr)
558 *ss = make(map[string]struct{}, len(arr))
559 for _, t := range arr {
560 (*ss)[t] = struct{}{}
564 var hash map[string]struct{}
565 err := json.Unmarshal(data, &hash)
569 *ss = make(map[string]struct{}, len(hash))
570 for t := range hash {
571 (*ss)[t] = struct{}{}
577 type ServiceName string
580 ServiceNameRailsAPI ServiceName = "arvados-api-server"
581 ServiceNameController ServiceName = "arvados-controller"
582 ServiceNameDispatchCloud ServiceName = "arvados-dispatch-cloud"
583 ServiceNameHealth ServiceName = "arvados-health"
584 ServiceNameWorkbench1 ServiceName = "arvados-workbench1"
585 ServiceNameWorkbench2 ServiceName = "arvados-workbench2"
586 ServiceNameWebsocket ServiceName = "arvados-ws"
587 ServiceNameKeepbalance ServiceName = "keep-balance"
588 ServiceNameKeepweb ServiceName = "keep-web"
589 ServiceNameKeepproxy ServiceName = "keepproxy"
590 ServiceNameKeepstore ServiceName = "keepstore"
593 // Map returns all services as a map, suitable for iterating over all
594 // services or looking up a service by name.
595 func (svcs Services) Map() map[ServiceName]Service {
596 return map[ServiceName]Service{
597 ServiceNameRailsAPI: svcs.RailsAPI,
598 ServiceNameController: svcs.Controller,
599 ServiceNameDispatchCloud: svcs.DispatchCloud,
600 ServiceNameHealth: svcs.Health,
601 ServiceNameWorkbench1: svcs.Workbench1,
602 ServiceNameWorkbench2: svcs.Workbench2,
603 ServiceNameWebsocket: svcs.Websocket,
604 ServiceNameKeepbalance: svcs.Keepbalance,
605 ServiceNameKeepweb: svcs.WebDAV,
606 ServiceNameKeepproxy: svcs.Keepproxy,
607 ServiceNameKeepstore: svcs.Keepstore,