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
80 type ManagedProperties map[string]struct {
87 ClusterID string `json:"-"`
88 ManagementToken string
89 SystemRootToken string
91 InstanceTypes InstanceTypeMap
92 Containers ContainersConfig
93 RemoteClusters map[string]RemoteCluster
97 AsyncPermissionsUpdateInterval Duration
98 DisabledAPIs StringSet
99 MaxIndexDatabaseRead int
100 MaxItemsPerResponse int
101 MaxConcurrentRequests int
102 MaxKeepBlobBuffers int
103 MaxRequestAmplification int
105 MaxTokenLifetime Duration
106 RequestTimeout Duration
108 WebsocketClientEventQueue int
109 WebsocketServerEventQueue int
110 KeepServiceRequestTimeout Duration
111 VocabularyPath string
116 UnloggedAttributes StringSet
120 BlobSigningKey string
121 BlobSigningTTL Duration
123 BlobTrashLifetime Duration
124 BlobTrashCheckInterval Duration
125 BlobTrashConcurrency int
126 BlobDeleteConcurrency int
127 BlobReplicateConcurrency int
128 CollectionVersioning bool
129 DefaultTrashLifetime Duration
130 DefaultReplication int
131 ManagedProperties ManagedProperties
132 PreserveVersionIfIdle Duration
133 TrashSweepInterval Duration
135 ForwardSlashNameSubstitution string
138 BlobMissingReport string
139 BalancePeriod Duration
140 BalanceCollectionBatch int
141 BalanceCollectionBuffers int
142 BalanceTimeout Duration
143 BalanceUpdateLimit int
145 WebDAVCache WebDAVCacheConfig
147 KeepproxyPermission UploadDownloadRolePermissions
148 WebDAVPermission UploadDownloadRolePermissions
164 SearchAttribute string
165 SearchBindUser string
166 SearchBindPassword string
169 EmailAttribute string
170 UsernameAttribute string
176 AlternateEmailAddresses bool
177 AuthenticationRequestParameters map[string]string
179 OpenIDConnect struct {
185 EmailVerifiedClaim string
187 AcceptAccessToken bool
188 AcceptAccessTokenScope string
189 AuthenticationRequestParameters map[string]string
194 DefaultEmailDomain string
198 Users map[string]TestUser
201 RemoteTokenRefresh Duration
202 TokenLifetime Duration
203 TrustedClients map[string]struct{}
204 IssueTrustedTokens bool
207 MailchimpAPIKey string
208 MailchimpListID string
209 SendUserSetupNotificationEmail bool
210 IssueReporterEmailFrom string
211 IssueReporterEmailTo string
212 SupportEmailAddress string
218 MaxRequestLogParamsSize int
226 ActivatedUsersAreVisibleToOthers bool
227 AnonymousUserToken string
228 AdminNotifierEmailFrom string
229 AutoAdminFirstUser bool
230 AutoAdminUserWithEmail string
231 AutoSetupNewUsers bool
232 AutoSetupNewUsersWithRepository bool
233 AutoSetupNewUsersWithVmUUID string
234 AutoSetupUsernameBlacklist StringSet
235 EmailSubjectPrefix string
236 NewInactiveUserNotificationRecipients StringSet
237 NewUserNotificationRecipients StringSet
238 NewUsersAreActive bool
239 UserNotifierEmailFrom string
240 UserNotifierEmailBcc StringSet
241 UserProfileNotificationAddress string
242 PreferDomainForUsername string
243 UserSetupMailText string
245 StorageClasses map[string]StorageClassConfig
246 Volumes map[string]Volume
248 ActivationContactLink string
249 APIClientConnectTimeout Duration
250 APIClientReceiveTimeout Duration
251 APIResponseCompression bool
252 ApplicationMimetypesWithViewIcon StringSet
253 ArvadosDocsite string
254 ArvadosPublicDataDocURL string
255 DefaultOpenIdPrefix string
256 EnableGettingStartedPopup bool
257 EnablePublicProjectsPage bool
258 FileViewersConfigURL string
259 LogViewerMaxBytes ByteSize
260 MultiSiteSearch string
261 ProfilingEnabled bool
263 RepositoryCache string
264 RunningJobLogRecordsToFetch int
266 ShowRecentCollectionsOnDashboard bool
267 ShowUserAgreementInline bool
268 ShowUserNotifications bool
271 UserProfileFormFields map[string]struct {
273 FormFieldTitle string
274 FormFieldDescription string
277 Options map[string]struct{}
279 UserProfileFormMessage string
280 WelcomePageHTML string
281 InactivePageHTML string
282 SSHHelpPageHTML string
283 SSHHelpHostSuffix string
288 type StorageClassConfig struct {
294 AccessViaHosts map[URL]VolumeAccess
297 StorageClasses map[string]bool
299 DriverParameters json.RawMessage
302 type S3VolumeDriverParameters struct {
305 SecretAccessKey string
309 LocationConstraint bool
311 UseAWSS3v2Driver bool
313 ConnectTimeout Duration
320 type AzureVolumeDriverParameters struct {
321 StorageAccountName string
322 StorageAccountKey string
323 StorageBaseURL string
325 RequestTimeout Duration
326 ListBlobsRetryDelay Duration
327 ListBlobsMaxAttempts int
330 type DirectoryVolumeDriverParameters struct {
335 type VolumeAccess struct {
339 type Services struct {
342 DispatchCloud Service
351 WebDAVDownload Service
359 type Service struct {
360 InternalURLs map[URL]ServiceInstance
364 type TestUser struct {
369 // URL is a url.URL that is also usable as a JSON key/value.
372 // UnmarshalText implements encoding.TextUnmarshaler so URL can be
373 // used as a JSON key/value.
374 func (su *URL) UnmarshalText(text []byte) error {
375 u, err := url.Parse(string(text))
378 if su.Path == "" && su.Host != "" {
379 // http://example really means http://example/
386 func (su URL) MarshalText() ([]byte, error) {
387 return []byte(fmt.Sprintf("%s", (*url.URL)(&su).String())), nil
390 func (su URL) String() string {
391 return (*url.URL)(&su).String()
394 type ServiceInstance struct {
395 Rendezvous string `json:",omitempty"`
398 type PostgreSQL struct {
399 Connection PostgreSQLConnection
403 type PostgreSQLConnection map[string]string
405 type RemoteCluster struct {
413 type InstanceType struct {
419 IncludedScratch ByteSize
420 AddedScratch ByteSize
425 type ContainersConfig struct {
426 CloudVMs CloudVMsConfig
427 CrunchRunCommand string
428 CrunchRunArgumentsList []string
429 DefaultKeepCacheRAM ByteSize
430 DispatchPrivateKey string
431 LogReuseDecisions bool
433 MaxDispatchAttempts int
435 MinRetryPeriod Duration
436 ReserveExtraRAM ByteSize
437 StaleLockTimeout Duration
438 SupportedDockerImageFormats StringSet
439 UsePreemptibleInstances bool
441 LocalKeepBlobBuffersPerVCPU int
442 LocalKeepLogsToContainerLog string
446 GitInternalDir string
451 LogSecondsBetweenEvents Duration
452 LogThrottlePeriod Duration
455 LimitLogBytesPerJob int
456 LogPartialLineThrottlePeriod Duration
457 LogUpdatePeriod Duration
458 LogUpdateSize ByteSize
466 SbatchArgumentsList []string
467 SbatchEnvironmentVariables map[string]string
469 DNSServerConfDir string
470 DNSServerConfTemplate string
471 DNSServerReloadCommand string
472 DNSServerUpdateCommand string
473 ComputeNodeDomain string
474 ComputeNodeNameservers StringSet
475 AssignNodeHostname string
480 BsubArgumentsList []string
484 type CloudVMsConfig struct {
487 BootProbeCommand string
488 DeployRunnerBinary string
490 MaxCloudOpsPerSecond int
491 MaxProbesPerSecond int
492 MaxConcurrentInstanceCreateOps int
493 PollInterval Duration
494 ProbeInterval Duration
496 SyncInterval Duration
497 TimeoutBooting Duration
499 TimeoutProbe Duration
500 TimeoutShutdown Duration
501 TimeoutSignal Duration
502 TimeoutStaleRunLock Duration
504 ResourceTags map[string]string
508 DriverParameters json.RawMessage
511 type InstanceTypeMap map[string]InstanceType
513 var errDuplicateInstanceTypeName = errors.New("duplicate instance type name")
515 // UnmarshalJSON handles old config files that provide an array of
516 // instance types instead of a hash.
517 func (it *InstanceTypeMap) UnmarshalJSON(data []byte) error {
518 fixup := func(t InstanceType) (InstanceType, error) {
519 if t.ProviderType == "" {
520 t.ProviderType = t.Name
523 t.Scratch = t.IncludedScratch + t.AddedScratch
524 } else if t.AddedScratch == 0 {
525 t.AddedScratch = t.Scratch - t.IncludedScratch
526 } else if t.IncludedScratch == 0 {
527 t.IncludedScratch = t.Scratch - t.AddedScratch
530 if t.Scratch != (t.IncludedScratch + t.AddedScratch) {
531 return t, fmt.Errorf("InstanceType %q: Scratch != (IncludedScratch + AddedScratch)", t.Name)
536 if len(data) > 0 && data[0] == '[' {
537 var arr []InstanceType
538 err := json.Unmarshal(data, &arr)
546 *it = make(map[string]InstanceType, len(arr))
547 for _, t := range arr {
548 if _, ok := (*it)[t.Name]; ok {
549 return errDuplicateInstanceTypeName
559 var hash map[string]InstanceType
560 err := json.Unmarshal(data, &hash)
564 // Fill in Name field (and ProviderType field, if not
565 // specified) using hash key.
566 *it = InstanceTypeMap(hash)
567 for name, t := range *it {
578 type StringSet map[string]struct{}
580 // UnmarshalJSON handles old config files that provide an array of
581 // instance types instead of a hash.
582 func (ss *StringSet) UnmarshalJSON(data []byte) error {
583 if len(data) > 0 && data[0] == '[' {
585 err := json.Unmarshal(data, &arr)
593 *ss = make(map[string]struct{}, len(arr))
594 for _, t := range arr {
595 (*ss)[t] = struct{}{}
599 var hash map[string]struct{}
600 err := json.Unmarshal(data, &hash)
604 *ss = make(map[string]struct{}, len(hash))
605 for t := range hash {
606 (*ss)[t] = struct{}{}
612 type ServiceName string
615 ServiceNameRailsAPI ServiceName = "arvados-api-server"
616 ServiceNameController ServiceName = "arvados-controller"
617 ServiceNameDispatchCloud ServiceName = "arvados-dispatch-cloud"
618 ServiceNameDispatchLSF ServiceName = "arvados-dispatch-lsf"
619 ServiceNameHealth ServiceName = "arvados-health"
620 ServiceNameWorkbench1 ServiceName = "arvados-workbench1"
621 ServiceNameWorkbench2 ServiceName = "arvados-workbench2"
622 ServiceNameWebsocket ServiceName = "arvados-ws"
623 ServiceNameKeepbalance ServiceName = "keep-balance"
624 ServiceNameKeepweb ServiceName = "keep-web"
625 ServiceNameKeepproxy ServiceName = "keepproxy"
626 ServiceNameKeepstore ServiceName = "keepstore"
629 // Map returns all services as a map, suitable for iterating over all
630 // services or looking up a service by name.
631 func (svcs Services) Map() map[ServiceName]Service {
632 return map[ServiceName]Service{
633 ServiceNameRailsAPI: svcs.RailsAPI,
634 ServiceNameController: svcs.Controller,
635 ServiceNameDispatchCloud: svcs.DispatchCloud,
636 ServiceNameDispatchLSF: svcs.DispatchLSF,
637 ServiceNameHealth: svcs.Health,
638 ServiceNameWorkbench1: svcs.Workbench1,
639 ServiceNameWorkbench2: svcs.Workbench2,
640 ServiceNameWebsocket: svcs.Websocket,
641 ServiceNameKeepbalance: svcs.Keepbalance,
642 ServiceNameKeepweb: svcs.WebDAV,
643 ServiceNameKeepproxy: svcs.Keepproxy,
644 ServiceNameKeepstore: svcs.Keepstore,