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
70 type UploadDownloadPermission struct {
75 type UploadDownloadRolePermissions struct {
76 User UploadDownloadPermission
77 Admin UploadDownloadPermission
81 ClusterID string `json:"-"`
82 ManagementToken string
83 SystemRootToken string
85 InstanceTypes InstanceTypeMap
86 Containers ContainersConfig
87 RemoteClusters map[string]RemoteCluster
91 AsyncPermissionsUpdateInterval Duration
92 DisabledAPIs StringSet
93 MaxIndexDatabaseRead int
94 MaxItemsPerResponse int
95 MaxConcurrentRequests int
96 MaxKeepBlobBuffers int
97 MaxRequestAmplification int
99 MaxTokenLifetime Duration
100 RequestTimeout Duration
102 WebsocketClientEventQueue int
103 WebsocketServerEventQueue int
104 KeepServiceRequestTimeout Duration
109 UnloggedAttributes StringSet
113 BlobSigningKey string
114 BlobSigningTTL Duration
116 BlobTrashLifetime Duration
117 BlobTrashCheckInterval Duration
118 BlobTrashConcurrency int
119 BlobDeleteConcurrency int
120 BlobReplicateConcurrency int
121 CollectionVersioning bool
122 DefaultTrashLifetime Duration
123 DefaultReplication int
124 ManagedProperties map[string]struct {
129 PreserveVersionIfIdle Duration
130 TrashSweepInterval Duration
132 ForwardSlashNameSubstitution string
135 BlobMissingReport string
136 BalancePeriod Duration
137 BalanceCollectionBatch int
138 BalanceCollectionBuffers int
139 BalanceTimeout Duration
140 BalanceUpdateLimit int
142 WebDAVCache WebDAVCacheConfig
144 KeepproxyPermission UploadDownloadRolePermissions
145 WebDAVPermission UploadDownloadRolePermissions
161 SearchAttribute string
162 SearchBindUser string
163 SearchBindPassword string
166 EmailAttribute string
167 UsernameAttribute string
173 AlternateEmailAddresses bool
174 AuthenticationRequestParameters map[string]string
176 OpenIDConnect struct {
182 EmailVerifiedClaim string
184 AcceptAccessToken bool
185 AcceptAccessTokenScope string
186 AuthenticationRequestParameters map[string]string
191 DefaultEmailDomain string
195 Users map[string]TestUser
198 RemoteTokenRefresh Duration
199 TokenLifetime Duration
200 TrustedClients map[string]struct{}
201 IssueTrustedTokens bool
204 MailchimpAPIKey string
205 MailchimpListID string
206 SendUserSetupNotificationEmail bool
207 IssueReporterEmailFrom string
208 IssueReporterEmailTo string
209 SupportEmailAddress string
215 MaxRequestLogParamsSize int
223 AnonymousUserToken string
224 AdminNotifierEmailFrom string
225 AutoAdminFirstUser bool
226 AutoAdminUserWithEmail string
227 AutoSetupNewUsers bool
228 AutoSetupNewUsersWithRepository bool
229 AutoSetupNewUsersWithVmUUID string
230 AutoSetupUsernameBlacklist StringSet
231 EmailSubjectPrefix string
232 NewInactiveUserNotificationRecipients StringSet
233 NewUserNotificationRecipients StringSet
234 NewUsersAreActive bool
235 UserNotifierEmailFrom string
236 UserNotifierEmailBcc StringSet
237 UserProfileNotificationAddress string
238 PreferDomainForUsername string
239 UserSetupMailText string
241 StorageClasses map[string]StorageClassConfig
242 Volumes map[string]Volume
244 ActivationContactLink string
245 APIClientConnectTimeout Duration
246 APIClientReceiveTimeout Duration
247 APIResponseCompression bool
248 ApplicationMimetypesWithViewIcon StringSet
249 ArvadosDocsite string
250 ArvadosPublicDataDocURL string
251 DefaultOpenIdPrefix string
252 EnableGettingStartedPopup bool
253 EnablePublicProjectsPage bool
254 FileViewersConfigURL string
255 LogViewerMaxBytes ByteSize
256 MultiSiteSearch string
257 ProfilingEnabled bool
259 RepositoryCache string
260 RunningJobLogRecordsToFetch int
262 ShowRecentCollectionsOnDashboard bool
263 ShowUserAgreementInline bool
264 ShowUserNotifications bool
267 UserProfileFormFields map[string]struct {
269 FormFieldTitle string
270 FormFieldDescription string
273 Options map[string]struct{}
275 UserProfileFormMessage string
277 WelcomePageHTML string
278 InactivePageHTML string
279 SSHHelpPageHTML string
280 SSHHelpHostSuffix string
285 type StorageClassConfig struct {
291 AccessViaHosts map[URL]VolumeAccess
294 StorageClasses map[string]bool
296 DriverParameters json.RawMessage
299 type S3VolumeDriverParameters struct {
302 SecretAccessKey string
306 LocationConstraint bool
308 UseAWSS3v2Driver bool
310 ConnectTimeout Duration
317 type AzureVolumeDriverParameters struct {
318 StorageAccountName string
319 StorageAccountKey string
320 StorageBaseURL string
322 RequestTimeout Duration
323 ListBlobsRetryDelay Duration
324 ListBlobsMaxAttempts int
327 type DirectoryVolumeDriverParameters struct {
332 type VolumeAccess struct {
336 type Services struct {
339 DispatchCloud Service
348 WebDAVDownload Service
356 type Service struct {
357 InternalURLs map[URL]ServiceInstance
361 type TestUser struct {
366 // URL is a url.URL that is also usable as a JSON key/value.
369 // UnmarshalText implements encoding.TextUnmarshaler so URL can be
370 // used as a JSON key/value.
371 func (su *URL) UnmarshalText(text []byte) error {
372 u, err := url.Parse(string(text))
375 if su.Path == "" && su.Host != "" {
376 // http://example really means http://example/
383 func (su URL) MarshalText() ([]byte, error) {
384 return []byte(fmt.Sprintf("%s", (*url.URL)(&su).String())), nil
387 func (su URL) String() string {
388 return (*url.URL)(&su).String()
391 type ServiceInstance struct {
392 Rendezvous string `json:",omitempty"`
395 type PostgreSQL struct {
396 Connection PostgreSQLConnection
400 type PostgreSQLConnection map[string]string
402 type RemoteCluster struct {
410 type InstanceType struct {
416 IncludedScratch ByteSize
417 AddedScratch ByteSize
422 type ContainersConfig struct {
423 CloudVMs CloudVMsConfig
424 CrunchRunCommand string
425 CrunchRunArgumentsList []string
426 DefaultKeepCacheRAM ByteSize
427 DispatchPrivateKey string
428 LogReuseDecisions bool
430 MaxDispatchAttempts int
432 MinRetryPeriod Duration
433 ReserveExtraRAM ByteSize
434 StaleLockTimeout Duration
435 SupportedDockerImageFormats StringSet
436 UsePreemptibleInstances bool
438 LocalKeepBlobBuffersPerVCPU int
439 LocalKeepLogsToContainerLog string
443 GitInternalDir string
448 LogSecondsBetweenEvents Duration
449 LogThrottlePeriod Duration
452 LimitLogBytesPerJob int
453 LogPartialLineThrottlePeriod Duration
454 LogUpdatePeriod Duration
455 LogUpdateSize ByteSize
463 SbatchArgumentsList []string
464 SbatchEnvironmentVariables map[string]string
466 DNSServerConfDir string
467 DNSServerConfTemplate string
468 DNSServerReloadCommand string
469 DNSServerUpdateCommand string
470 ComputeNodeDomain string
471 ComputeNodeNameservers StringSet
472 AssignNodeHostname string
477 BsubArgumentsList []string
481 type CloudVMsConfig struct {
484 BootProbeCommand string
485 DeployRunnerBinary string
487 MaxCloudOpsPerSecond int
488 MaxProbesPerSecond int
489 MaxConcurrentInstanceCreateOps int
490 PollInterval Duration
491 ProbeInterval Duration
493 SyncInterval Duration
494 TimeoutBooting Duration
496 TimeoutProbe Duration
497 TimeoutShutdown Duration
498 TimeoutSignal Duration
499 TimeoutStaleRunLock Duration
501 ResourceTags map[string]string
505 DriverParameters json.RawMessage
508 type InstanceTypeMap map[string]InstanceType
510 var errDuplicateInstanceTypeName = errors.New("duplicate instance type name")
512 // UnmarshalJSON handles old config files that provide an array of
513 // instance types instead of a hash.
514 func (it *InstanceTypeMap) UnmarshalJSON(data []byte) error {
515 fixup := func(t InstanceType) (InstanceType, error) {
516 if t.ProviderType == "" {
517 t.ProviderType = t.Name
520 t.Scratch = t.IncludedScratch + t.AddedScratch
521 } else if t.AddedScratch == 0 {
522 t.AddedScratch = t.Scratch - t.IncludedScratch
523 } else if t.IncludedScratch == 0 {
524 t.IncludedScratch = t.Scratch - t.AddedScratch
527 if t.Scratch != (t.IncludedScratch + t.AddedScratch) {
528 return t, fmt.Errorf("InstanceType %q: Scratch != (IncludedScratch + AddedScratch)", t.Name)
533 if len(data) > 0 && data[0] == '[' {
534 var arr []InstanceType
535 err := json.Unmarshal(data, &arr)
543 *it = make(map[string]InstanceType, len(arr))
544 for _, t := range arr {
545 if _, ok := (*it)[t.Name]; ok {
546 return errDuplicateInstanceTypeName
556 var hash map[string]InstanceType
557 err := json.Unmarshal(data, &hash)
561 // Fill in Name field (and ProviderType field, if not
562 // specified) using hash key.
563 *it = InstanceTypeMap(hash)
564 for name, t := range *it {
575 type StringSet map[string]struct{}
577 // UnmarshalJSON handles old config files that provide an array of
578 // instance types instead of a hash.
579 func (ss *StringSet) UnmarshalJSON(data []byte) error {
580 if len(data) > 0 && data[0] == '[' {
582 err := json.Unmarshal(data, &arr)
590 *ss = make(map[string]struct{}, len(arr))
591 for _, t := range arr {
592 (*ss)[t] = struct{}{}
596 var hash map[string]struct{}
597 err := json.Unmarshal(data, &hash)
601 *ss = make(map[string]struct{}, len(hash))
602 for t := range hash {
603 (*ss)[t] = struct{}{}
609 type ServiceName string
612 ServiceNameRailsAPI ServiceName = "arvados-api-server"
613 ServiceNameController ServiceName = "arvados-controller"
614 ServiceNameDispatchCloud ServiceName = "arvados-dispatch-cloud"
615 ServiceNameDispatchLSF ServiceName = "arvados-dispatch-lsf"
616 ServiceNameHealth ServiceName = "arvados-health"
617 ServiceNameWorkbench1 ServiceName = "arvados-workbench1"
618 ServiceNameWorkbench2 ServiceName = "arvados-workbench2"
619 ServiceNameWebsocket ServiceName = "arvados-ws"
620 ServiceNameKeepbalance ServiceName = "keep-balance"
621 ServiceNameKeepweb ServiceName = "keep-web"
622 ServiceNameKeepproxy ServiceName = "keepproxy"
623 ServiceNameKeepstore ServiceName = "keepstore"
626 // Map returns all services as a map, suitable for iterating over all
627 // services or looking up a service by name.
628 func (svcs Services) Map() map[ServiceName]Service {
629 return map[ServiceName]Service{
630 ServiceNameRailsAPI: svcs.RailsAPI,
631 ServiceNameController: svcs.Controller,
632 ServiceNameDispatchCloud: svcs.DispatchCloud,
633 ServiceNameDispatchLSF: svcs.DispatchLSF,
634 ServiceNameHealth: svcs.Health,
635 ServiceNameWorkbench1: svcs.Workbench1,
636 ServiceNameWorkbench2: svcs.Workbench2,
637 ServiceNameWebsocket: svcs.Websocket,
638 ServiceNameKeepbalance: svcs.Keepbalance,
639 ServiceNameKeepweb: svcs.WebDAV,
640 ServiceNameKeepproxy: svcs.Keepproxy,
641 ServiceNameKeepstore: svcs.Keepstore,