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 AnonymousUserToken string
227 AdminNotifierEmailFrom string
228 AutoAdminFirstUser bool
229 AutoAdminUserWithEmail string
230 AutoSetupNewUsers bool
231 AutoSetupNewUsersWithRepository bool
232 AutoSetupNewUsersWithVmUUID string
233 AutoSetupUsernameBlacklist StringSet
234 EmailSubjectPrefix string
235 NewInactiveUserNotificationRecipients StringSet
236 NewUserNotificationRecipients StringSet
237 NewUsersAreActive bool
238 UserNotifierEmailFrom string
239 UserNotifierEmailBcc StringSet
240 UserProfileNotificationAddress string
241 PreferDomainForUsername string
242 UserSetupMailText string
244 StorageClasses map[string]StorageClassConfig
245 Volumes map[string]Volume
247 ActivationContactLink string
248 APIClientConnectTimeout Duration
249 APIClientReceiveTimeout Duration
250 APIResponseCompression bool
251 ApplicationMimetypesWithViewIcon StringSet
252 ArvadosDocsite string
253 ArvadosPublicDataDocURL string
254 DefaultOpenIdPrefix string
255 EnableGettingStartedPopup bool
256 EnablePublicProjectsPage bool
257 FileViewersConfigURL string
258 LogViewerMaxBytes ByteSize
259 MultiSiteSearch string
260 ProfilingEnabled bool
262 RepositoryCache string
263 RunningJobLogRecordsToFetch int
265 ShowRecentCollectionsOnDashboard bool
266 ShowUserAgreementInline bool
267 ShowUserNotifications bool
270 UserProfileFormFields map[string]struct {
272 FormFieldTitle string
273 FormFieldDescription string
276 Options map[string]struct{}
278 UserProfileFormMessage string
279 WelcomePageHTML string
280 InactivePageHTML string
281 SSHHelpPageHTML string
282 SSHHelpHostSuffix string
287 type StorageClassConfig struct {
293 AccessViaHosts map[URL]VolumeAccess
296 StorageClasses map[string]bool
298 DriverParameters json.RawMessage
301 type S3VolumeDriverParameters struct {
304 SecretAccessKey string
308 LocationConstraint bool
310 UseAWSS3v2Driver bool
312 ConnectTimeout Duration
319 type AzureVolumeDriverParameters struct {
320 StorageAccountName string
321 StorageAccountKey string
322 StorageBaseURL string
324 RequestTimeout Duration
325 ListBlobsRetryDelay Duration
326 ListBlobsMaxAttempts int
329 type DirectoryVolumeDriverParameters struct {
334 type VolumeAccess struct {
338 type Services struct {
341 DispatchCloud Service
350 WebDAVDownload Service
358 type Service struct {
359 InternalURLs map[URL]ServiceInstance
363 type TestUser struct {
368 // URL is a url.URL that is also usable as a JSON key/value.
371 // UnmarshalText implements encoding.TextUnmarshaler so URL can be
372 // used as a JSON key/value.
373 func (su *URL) UnmarshalText(text []byte) error {
374 u, err := url.Parse(string(text))
377 if su.Path == "" && su.Host != "" {
378 // http://example really means http://example/
385 func (su URL) MarshalText() ([]byte, error) {
386 return []byte(fmt.Sprintf("%s", (*url.URL)(&su).String())), nil
389 func (su URL) String() string {
390 return (*url.URL)(&su).String()
393 type ServiceInstance struct {
394 Rendezvous string `json:",omitempty"`
397 type PostgreSQL struct {
398 Connection PostgreSQLConnection
402 type PostgreSQLConnection map[string]string
404 type RemoteCluster struct {
412 type InstanceType struct {
418 IncludedScratch ByteSize
419 AddedScratch ByteSize
424 type ContainersConfig struct {
425 CloudVMs CloudVMsConfig
426 CrunchRunCommand string
427 CrunchRunArgumentsList []string
428 DefaultKeepCacheRAM ByteSize
429 DispatchPrivateKey string
430 LogReuseDecisions bool
432 MaxDispatchAttempts int
434 MinRetryPeriod Duration
435 ReserveExtraRAM ByteSize
436 StaleLockTimeout Duration
437 SupportedDockerImageFormats StringSet
438 UsePreemptibleInstances bool
440 LocalKeepBlobBuffersPerVCPU int
441 LocalKeepLogsToContainerLog string
445 GitInternalDir string
450 LogSecondsBetweenEvents Duration
451 LogThrottlePeriod Duration
454 LimitLogBytesPerJob int
455 LogPartialLineThrottlePeriod Duration
456 LogUpdatePeriod Duration
457 LogUpdateSize ByteSize
465 SbatchArgumentsList []string
466 SbatchEnvironmentVariables map[string]string
468 DNSServerConfDir string
469 DNSServerConfTemplate string
470 DNSServerReloadCommand string
471 DNSServerUpdateCommand string
472 ComputeNodeDomain string
473 ComputeNodeNameservers StringSet
474 AssignNodeHostname string
479 BsubArgumentsList []string
483 type CloudVMsConfig struct {
486 BootProbeCommand string
487 DeployRunnerBinary string
489 MaxCloudOpsPerSecond int
490 MaxProbesPerSecond int
491 MaxConcurrentInstanceCreateOps int
492 PollInterval Duration
493 ProbeInterval Duration
495 SyncInterval Duration
496 TimeoutBooting Duration
498 TimeoutProbe Duration
499 TimeoutShutdown Duration
500 TimeoutSignal Duration
501 TimeoutStaleRunLock Duration
503 ResourceTags map[string]string
507 DriverParameters json.RawMessage
510 type InstanceTypeMap map[string]InstanceType
512 var errDuplicateInstanceTypeName = errors.New("duplicate instance type name")
514 // UnmarshalJSON handles old config files that provide an array of
515 // instance types instead of a hash.
516 func (it *InstanceTypeMap) UnmarshalJSON(data []byte) error {
517 fixup := func(t InstanceType) (InstanceType, error) {
518 if t.ProviderType == "" {
519 t.ProviderType = t.Name
522 t.Scratch = t.IncludedScratch + t.AddedScratch
523 } else if t.AddedScratch == 0 {
524 t.AddedScratch = t.Scratch - t.IncludedScratch
525 } else if t.IncludedScratch == 0 {
526 t.IncludedScratch = t.Scratch - t.AddedScratch
529 if t.Scratch != (t.IncludedScratch + t.AddedScratch) {
530 return t, fmt.Errorf("InstanceType %q: Scratch != (IncludedScratch + AddedScratch)", t.Name)
535 if len(data) > 0 && data[0] == '[' {
536 var arr []InstanceType
537 err := json.Unmarshal(data, &arr)
545 *it = make(map[string]InstanceType, len(arr))
546 for _, t := range arr {
547 if _, ok := (*it)[t.Name]; ok {
548 return errDuplicateInstanceTypeName
558 var hash map[string]InstanceType
559 err := json.Unmarshal(data, &hash)
563 // Fill in Name field (and ProviderType field, if not
564 // specified) using hash key.
565 *it = InstanceTypeMap(hash)
566 for name, t := range *it {
577 type StringSet map[string]struct{}
579 // UnmarshalJSON handles old config files that provide an array of
580 // instance types instead of a hash.
581 func (ss *StringSet) UnmarshalJSON(data []byte) error {
582 if len(data) > 0 && data[0] == '[' {
584 err := json.Unmarshal(data, &arr)
592 *ss = make(map[string]struct{}, len(arr))
593 for _, t := range arr {
594 (*ss)[t] = struct{}{}
598 var hash map[string]struct{}
599 err := json.Unmarshal(data, &hash)
603 *ss = make(map[string]struct{}, len(hash))
604 for t := range hash {
605 (*ss)[t] = struct{}{}
611 type ServiceName string
614 ServiceNameRailsAPI ServiceName = "arvados-api-server"
615 ServiceNameController ServiceName = "arvados-controller"
616 ServiceNameDispatchCloud ServiceName = "arvados-dispatch-cloud"
617 ServiceNameDispatchLSF ServiceName = "arvados-dispatch-lsf"
618 ServiceNameHealth ServiceName = "arvados-health"
619 ServiceNameWorkbench1 ServiceName = "arvados-workbench1"
620 ServiceNameWorkbench2 ServiceName = "arvados-workbench2"
621 ServiceNameWebsocket ServiceName = "arvados-ws"
622 ServiceNameKeepbalance ServiceName = "keep-balance"
623 ServiceNameKeepweb ServiceName = "keep-web"
624 ServiceNameKeepproxy ServiceName = "keepproxy"
625 ServiceNameKeepstore ServiceName = "keepstore"
628 // Map returns all services as a map, suitable for iterating over all
629 // services or looking up a service by name.
630 func (svcs Services) Map() map[ServiceName]Service {
631 return map[ServiceName]Service{
632 ServiceNameRailsAPI: svcs.RailsAPI,
633 ServiceNameController: svcs.Controller,
634 ServiceNameDispatchCloud: svcs.DispatchCloud,
635 ServiceNameDispatchLSF: svcs.DispatchLSF,
636 ServiceNameHealth: svcs.Health,
637 ServiceNameWorkbench1: svcs.Workbench1,
638 ServiceNameWorkbench2: svcs.Workbench2,
639 ServiceNameWebsocket: svcs.Websocket,
640 ServiceNameKeepbalance: svcs.Keepbalance,
641 ServiceNameKeepweb: svcs.WebDAV,
642 ServiceNameKeepproxy: svcs.Keepproxy,
643 ServiceNameKeepstore: svcs.Keepstore,