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
244 RoleGroupsVisibleToAll bool
246 StorageClasses map[string]StorageClassConfig
247 Volumes map[string]Volume
249 ActivationContactLink string
250 APIClientConnectTimeout Duration
251 APIClientReceiveTimeout Duration
252 APIResponseCompression bool
253 ApplicationMimetypesWithViewIcon StringSet
254 ArvadosDocsite string
255 ArvadosPublicDataDocURL string
256 DefaultOpenIdPrefix string
257 EnableGettingStartedPopup bool
258 EnablePublicProjectsPage bool
259 FileViewersConfigURL string
260 LogViewerMaxBytes ByteSize
261 MultiSiteSearch string
262 ProfilingEnabled bool
264 RepositoryCache string
265 RunningJobLogRecordsToFetch int
267 ShowRecentCollectionsOnDashboard bool
268 ShowUserAgreementInline bool
269 ShowUserNotifications bool
272 UserProfileFormFields map[string]struct {
274 FormFieldTitle string
275 FormFieldDescription string
278 Options map[string]struct{}
280 UserProfileFormMessage string
281 WelcomePageHTML string
282 InactivePageHTML string
283 SSHHelpPageHTML string
284 SSHHelpHostSuffix string
289 type StorageClassConfig struct {
295 AccessViaHosts map[URL]VolumeAccess
298 StorageClasses map[string]bool
300 DriverParameters json.RawMessage
303 type S3VolumeDriverParameters struct {
306 SecretAccessKey string
310 LocationConstraint bool
312 UseAWSS3v2Driver bool
314 ConnectTimeout Duration
321 type AzureVolumeDriverParameters struct {
322 StorageAccountName string
323 StorageAccountKey string
324 StorageBaseURL string
326 RequestTimeout Duration
327 ListBlobsRetryDelay Duration
328 ListBlobsMaxAttempts int
331 type DirectoryVolumeDriverParameters struct {
336 type VolumeAccess struct {
340 type Services struct {
343 DispatchCloud Service
352 WebDAVDownload Service
360 type Service struct {
361 InternalURLs map[URL]ServiceInstance
365 type TestUser struct {
370 // URL is a url.URL that is also usable as a JSON key/value.
373 // UnmarshalText implements encoding.TextUnmarshaler so URL can be
374 // used as a JSON key/value.
375 func (su *URL) UnmarshalText(text []byte) error {
376 u, err := url.Parse(string(text))
379 if su.Path == "" && su.Host != "" {
380 // http://example really means http://example/
387 func (su URL) MarshalText() ([]byte, error) {
388 return []byte(fmt.Sprintf("%s", (*url.URL)(&su).String())), nil
391 func (su URL) String() string {
392 return (*url.URL)(&su).String()
395 type ServiceInstance struct {
396 Rendezvous string `json:",omitempty"`
399 type PostgreSQL struct {
400 Connection PostgreSQLConnection
404 type PostgreSQLConnection map[string]string
406 type RemoteCluster struct {
414 type InstanceType struct {
420 IncludedScratch ByteSize
421 AddedScratch ByteSize
426 type ContainersConfig struct {
427 CloudVMs CloudVMsConfig
428 CrunchRunCommand string
429 CrunchRunArgumentsList []string
430 DefaultKeepCacheRAM ByteSize
431 DispatchPrivateKey string
432 LogReuseDecisions bool
434 MaxDispatchAttempts int
436 MinRetryPeriod Duration
437 ReserveExtraRAM ByteSize
438 StaleLockTimeout Duration
439 SupportedDockerImageFormats StringSet
440 AlwaysUsePreemptibleInstances bool
442 LocalKeepBlobBuffersPerVCPU int
443 LocalKeepLogsToContainerLog string
447 GitInternalDir string
452 LogSecondsBetweenEvents Duration
453 LogThrottlePeriod Duration
456 LimitLogBytesPerJob int
457 LogPartialLineThrottlePeriod Duration
458 LogUpdatePeriod Duration
459 LogUpdateSize ByteSize
467 SbatchArgumentsList []string
468 SbatchEnvironmentVariables map[string]string
470 DNSServerConfDir string
471 DNSServerConfTemplate string
472 DNSServerReloadCommand string
473 DNSServerUpdateCommand string
474 ComputeNodeDomain string
475 ComputeNodeNameservers StringSet
476 AssignNodeHostname string
481 BsubArgumentsList []string
485 type CloudVMsConfig struct {
488 BootProbeCommand string
489 DeployRunnerBinary string
491 MaxCloudOpsPerSecond int
492 MaxProbesPerSecond int
493 MaxConcurrentInstanceCreateOps int
494 PollInterval Duration
495 ProbeInterval Duration
497 SyncInterval Duration
498 TimeoutBooting Duration
500 TimeoutProbe Duration
501 TimeoutShutdown Duration
502 TimeoutSignal Duration
503 TimeoutStaleRunLock Duration
505 ResourceTags map[string]string
509 DriverParameters json.RawMessage
512 type InstanceTypeMap map[string]InstanceType
514 var errDuplicateInstanceTypeName = errors.New("duplicate instance type name")
516 // UnmarshalJSON handles old config files that provide an array of
517 // instance types instead of a hash.
518 func (it *InstanceTypeMap) UnmarshalJSON(data []byte) error {
519 fixup := func(t InstanceType) (InstanceType, error) {
520 if t.ProviderType == "" {
521 t.ProviderType = t.Name
524 t.Scratch = t.IncludedScratch + t.AddedScratch
525 } else if t.AddedScratch == 0 {
526 t.AddedScratch = t.Scratch - t.IncludedScratch
527 } else if t.IncludedScratch == 0 {
528 t.IncludedScratch = t.Scratch - t.AddedScratch
531 if t.Scratch != (t.IncludedScratch + t.AddedScratch) {
532 return t, fmt.Errorf("InstanceType %q: Scratch != (IncludedScratch + AddedScratch)", t.Name)
537 if len(data) > 0 && data[0] == '[' {
538 var arr []InstanceType
539 err := json.Unmarshal(data, &arr)
547 *it = make(map[string]InstanceType, len(arr))
548 for _, t := range arr {
549 if _, ok := (*it)[t.Name]; ok {
550 return errDuplicateInstanceTypeName
560 var hash map[string]InstanceType
561 err := json.Unmarshal(data, &hash)
565 // Fill in Name field (and ProviderType field, if not
566 // specified) using hash key.
567 *it = InstanceTypeMap(hash)
568 for name, t := range *it {
579 type StringSet map[string]struct{}
581 // UnmarshalJSON handles old config files that provide an array of
582 // instance types instead of a hash.
583 func (ss *StringSet) UnmarshalJSON(data []byte) error {
584 if len(data) > 0 && data[0] == '[' {
586 err := json.Unmarshal(data, &arr)
594 *ss = make(map[string]struct{}, len(arr))
595 for _, t := range arr {
596 (*ss)[t] = struct{}{}
600 var hash map[string]struct{}
601 err := json.Unmarshal(data, &hash)
605 *ss = make(map[string]struct{}, len(hash))
606 for t := range hash {
607 (*ss)[t] = struct{}{}
613 type ServiceName string
616 ServiceNameRailsAPI ServiceName = "arvados-api-server"
617 ServiceNameController ServiceName = "arvados-controller"
618 ServiceNameDispatchCloud ServiceName = "arvados-dispatch-cloud"
619 ServiceNameDispatchLSF ServiceName = "arvados-dispatch-lsf"
620 ServiceNameHealth ServiceName = "arvados-health"
621 ServiceNameWorkbench1 ServiceName = "arvados-workbench1"
622 ServiceNameWorkbench2 ServiceName = "arvados-workbench2"
623 ServiceNameWebsocket ServiceName = "arvados-ws"
624 ServiceNameKeepbalance ServiceName = "keep-balance"
625 ServiceNameKeepweb ServiceName = "keep-web"
626 ServiceNameKeepproxy ServiceName = "keepproxy"
627 ServiceNameKeepstore ServiceName = "keepstore"
630 // Map returns all services as a map, suitable for iterating over all
631 // services or looking up a service by name.
632 func (svcs Services) Map() map[ServiceName]Service {
633 return map[ServiceName]Service{
634 ServiceNameRailsAPI: svcs.RailsAPI,
635 ServiceNameController: svcs.Controller,
636 ServiceNameDispatchCloud: svcs.DispatchCloud,
637 ServiceNameDispatchLSF: svcs.DispatchLSF,
638 ServiceNameHealth: svcs.Health,
639 ServiceNameWorkbench1: svcs.Workbench1,
640 ServiceNameWorkbench2: svcs.Workbench2,
641 ServiceNameWebsocket: svcs.Websocket,
642 ServiceNameKeepbalance: svcs.Keepbalance,
643 ServiceNameKeepweb: svcs.WebDAV,
644 ServiceNameKeepproxy: svcs.Keepproxy,
645 ServiceNameKeepstore: svcs.Keepstore,