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 UserProfileNotificationAddress string
238 PreferDomainForUsername string
239 UserSetupMailText string
241 Volumes map[string]Volume
243 ActivationContactLink string
244 APIClientConnectTimeout Duration
245 APIClientReceiveTimeout Duration
246 APIResponseCompression bool
247 ApplicationMimetypesWithViewIcon StringSet
248 ArvadosDocsite string
249 ArvadosPublicDataDocURL string
250 DefaultOpenIdPrefix string
251 EnableGettingStartedPopup bool
252 EnablePublicProjectsPage bool
253 FileViewersConfigURL string
254 LogViewerMaxBytes ByteSize
255 MultiSiteSearch string
256 ProfilingEnabled bool
258 RepositoryCache string
259 RunningJobLogRecordsToFetch int
261 ShowRecentCollectionsOnDashboard bool
262 ShowUserAgreementInline bool
263 ShowUserNotifications bool
266 UserProfileFormFields map[string]struct {
268 FormFieldTitle string
269 FormFieldDescription string
272 Options map[string]struct{}
274 UserProfileFormMessage string
276 WelcomePageHTML string
277 InactivePageHTML string
278 SSHHelpPageHTML string
279 SSHHelpHostSuffix string
285 AccessViaHosts map[URL]VolumeAccess
288 StorageClasses map[string]bool
290 DriverParameters json.RawMessage
293 type S3VolumeDriverParameters struct {
296 SecretAccessKey string
300 LocationConstraint bool
302 UseAWSS3v2Driver bool
304 ConnectTimeout Duration
310 type AzureVolumeDriverParameters struct {
311 StorageAccountName string
312 StorageAccountKey string
313 StorageBaseURL string
315 RequestTimeout Duration
316 ListBlobsRetryDelay Duration
317 ListBlobsMaxAttempts int
320 type DirectoryVolumeDriverParameters struct {
325 type VolumeAccess struct {
329 type Services struct {
332 DispatchCloud Service
341 WebDAVDownload Service
349 type Service struct {
350 InternalURLs map[URL]ServiceInstance
354 type TestUser struct {
359 // URL is a url.URL that is also usable as a JSON key/value.
362 // UnmarshalText implements encoding.TextUnmarshaler so URL can be
363 // used as a JSON key/value.
364 func (su *URL) UnmarshalText(text []byte) error {
365 u, err := url.Parse(string(text))
368 if su.Path == "" && su.Host != "" {
369 // http://example really means http://example/
376 func (su URL) MarshalText() ([]byte, error) {
377 return []byte(fmt.Sprintf("%s", (*url.URL)(&su).String())), nil
380 func (su URL) String() string {
381 return (*url.URL)(&su).String()
384 type ServiceInstance struct {
385 Rendezvous string `json:",omitempty"`
388 type PostgreSQL struct {
389 Connection PostgreSQLConnection
393 type PostgreSQLConnection map[string]string
395 type RemoteCluster struct {
403 type InstanceType struct {
409 IncludedScratch ByteSize
410 AddedScratch ByteSize
415 type ContainersConfig struct {
416 CloudVMs CloudVMsConfig
417 CrunchRunCommand string
418 CrunchRunArgumentsList []string
419 DefaultKeepCacheRAM ByteSize
420 DispatchPrivateKey string
421 LogReuseDecisions bool
423 MaxDispatchAttempts int
425 MinRetryPeriod Duration
426 ReserveExtraRAM ByteSize
427 StaleLockTimeout Duration
428 SupportedDockerImageFormats StringSet
429 UsePreemptibleInstances bool
434 GitInternalDir string
439 LogSecondsBetweenEvents Duration
440 LogThrottlePeriod Duration
443 LimitLogBytesPerJob int
444 LogPartialLineThrottlePeriod Duration
445 LogUpdatePeriod Duration
446 LogUpdateSize ByteSize
454 SbatchArgumentsList []string
455 SbatchEnvironmentVariables map[string]string
457 DNSServerConfDir string
458 DNSServerConfTemplate string
459 DNSServerReloadCommand string
460 DNSServerUpdateCommand string
461 ComputeNodeDomain string
462 ComputeNodeNameservers StringSet
463 AssignNodeHostname string
468 BsubArgumentsList []string
472 type CloudVMsConfig struct {
475 BootProbeCommand string
476 DeployRunnerBinary string
478 MaxCloudOpsPerSecond int
479 MaxProbesPerSecond int
480 MaxConcurrentInstanceCreateOps int
481 PollInterval Duration
482 ProbeInterval Duration
484 SyncInterval Duration
485 TimeoutBooting Duration
487 TimeoutProbe Duration
488 TimeoutShutdown Duration
489 TimeoutSignal Duration
490 TimeoutStaleRunLock Duration
492 ResourceTags map[string]string
496 DriverParameters json.RawMessage
499 type InstanceTypeMap map[string]InstanceType
501 var errDuplicateInstanceTypeName = errors.New("duplicate instance type name")
503 // UnmarshalJSON handles old config files that provide an array of
504 // instance types instead of a hash.
505 func (it *InstanceTypeMap) UnmarshalJSON(data []byte) error {
506 fixup := func(t InstanceType) (InstanceType, error) {
507 if t.ProviderType == "" {
508 t.ProviderType = t.Name
511 t.Scratch = t.IncludedScratch + t.AddedScratch
512 } else if t.AddedScratch == 0 {
513 t.AddedScratch = t.Scratch - t.IncludedScratch
514 } else if t.IncludedScratch == 0 {
515 t.IncludedScratch = t.Scratch - t.AddedScratch
518 if t.Scratch != (t.IncludedScratch + t.AddedScratch) {
519 return t, fmt.Errorf("InstanceType %q: Scratch != (IncludedScratch + AddedScratch)", t.Name)
524 if len(data) > 0 && data[0] == '[' {
525 var arr []InstanceType
526 err := json.Unmarshal(data, &arr)
534 *it = make(map[string]InstanceType, len(arr))
535 for _, t := range arr {
536 if _, ok := (*it)[t.Name]; ok {
537 return errDuplicateInstanceTypeName
547 var hash map[string]InstanceType
548 err := json.Unmarshal(data, &hash)
552 // Fill in Name field (and ProviderType field, if not
553 // specified) using hash key.
554 *it = InstanceTypeMap(hash)
555 for name, t := range *it {
566 type StringSet map[string]struct{}
568 // UnmarshalJSON handles old config files that provide an array of
569 // instance types instead of a hash.
570 func (ss *StringSet) UnmarshalJSON(data []byte) error {
571 if len(data) > 0 && data[0] == '[' {
573 err := json.Unmarshal(data, &arr)
581 *ss = make(map[string]struct{}, len(arr))
582 for _, t := range arr {
583 (*ss)[t] = struct{}{}
587 var hash map[string]struct{}
588 err := json.Unmarshal(data, &hash)
592 *ss = make(map[string]struct{}, len(hash))
593 for t := range hash {
594 (*ss)[t] = struct{}{}
600 type ServiceName string
603 ServiceNameRailsAPI ServiceName = "arvados-api-server"
604 ServiceNameController ServiceName = "arvados-controller"
605 ServiceNameDispatchCloud ServiceName = "arvados-dispatch-cloud"
606 ServiceNameDispatchLSF ServiceName = "arvados-dispatch-lsf"
607 ServiceNameHealth ServiceName = "arvados-health"
608 ServiceNameWorkbench1 ServiceName = "arvados-workbench1"
609 ServiceNameWorkbench2 ServiceName = "arvados-workbench2"
610 ServiceNameWebsocket ServiceName = "arvados-ws"
611 ServiceNameKeepbalance ServiceName = "keep-balance"
612 ServiceNameKeepweb ServiceName = "keep-web"
613 ServiceNameKeepproxy ServiceName = "keepproxy"
614 ServiceNameKeepstore ServiceName = "keepstore"
617 // Map returns all services as a map, suitable for iterating over all
618 // services or looking up a service by name.
619 func (svcs Services) Map() map[ServiceName]Service {
620 return map[ServiceName]Service{
621 ServiceNameRailsAPI: svcs.RailsAPI,
622 ServiceNameController: svcs.Controller,
623 ServiceNameDispatchCloud: svcs.DispatchCloud,
624 ServiceNameDispatchLSF: svcs.DispatchLSF,
625 ServiceNameHealth: svcs.Health,
626 ServiceNameWorkbench1: svcs.Workbench1,
627 ServiceNameWorkbench2: svcs.Workbench2,
628 ServiceNameWebsocket: svcs.Websocket,
629 ServiceNameKeepbalance: svcs.Keepbalance,
630 ServiceNameKeepweb: svcs.WebDAV,
631 ServiceNameKeepproxy: svcs.Keepproxy,
632 ServiceNameKeepstore: svcs.Keepstore,