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
112 FreezeProjectRequiresDescription bool
113 FreezeProjectRequiresProperties StringSet
114 UnfreezeProjectRequiresAdmin bool
119 UnloggedAttributes StringSet
123 BlobSigningKey string
124 BlobSigningTTL Duration
126 BlobTrashLifetime Duration
127 BlobTrashCheckInterval Duration
128 BlobTrashConcurrency int
129 BlobDeleteConcurrency int
130 BlobReplicateConcurrency int
131 CollectionVersioning bool
132 DefaultTrashLifetime Duration
133 DefaultReplication int
134 ManagedProperties ManagedProperties
135 PreserveVersionIfIdle Duration
136 TrashSweepInterval Duration
138 ForwardSlashNameSubstitution string
141 BlobMissingReport string
142 BalancePeriod Duration
143 BalanceCollectionBatch int
144 BalanceCollectionBuffers int
145 BalanceTimeout Duration
146 BalanceUpdateLimit int
148 WebDAVCache WebDAVCacheConfig
150 KeepproxyPermission UploadDownloadRolePermissions
151 WebDAVPermission UploadDownloadRolePermissions
167 SearchAttribute string
168 SearchBindUser string
169 SearchBindPassword string
172 EmailAttribute string
173 UsernameAttribute string
179 AlternateEmailAddresses bool
180 AuthenticationRequestParameters map[string]string
182 OpenIDConnect struct {
188 EmailVerifiedClaim string
190 AcceptAccessToken bool
191 AcceptAccessTokenScope string
192 AuthenticationRequestParameters map[string]string
197 DefaultEmailDomain string
201 Users map[string]TestUser
204 RemoteTokenRefresh Duration
205 TokenLifetime Duration
206 TrustedClients map[string]struct{}
207 IssueTrustedTokens bool
210 MailchimpAPIKey string
211 MailchimpListID string
212 SendUserSetupNotificationEmail bool
213 IssueReporterEmailFrom string
214 IssueReporterEmailTo string
215 SupportEmailAddress string
221 MaxRequestLogParamsSize int
229 ActivatedUsersAreVisibleToOthers bool
230 AnonymousUserToken string
231 AdminNotifierEmailFrom string
232 AutoAdminFirstUser bool
233 AutoAdminUserWithEmail string
234 AutoSetupNewUsers bool
235 AutoSetupNewUsersWithRepository bool
236 AutoSetupNewUsersWithVmUUID string
237 AutoSetupUsernameBlacklist StringSet
238 EmailSubjectPrefix string
239 NewInactiveUserNotificationRecipients StringSet
240 NewUserNotificationRecipients StringSet
241 NewUsersAreActive bool
242 UserNotifierEmailFrom string
243 UserNotifierEmailBcc StringSet
244 UserProfileNotificationAddress string
245 PreferDomainForUsername string
246 UserSetupMailText string
247 RoleGroupsVisibleToAll bool
249 StorageClasses map[string]StorageClassConfig
250 Volumes map[string]Volume
252 ActivationContactLink string
253 APIClientConnectTimeout Duration
254 APIClientReceiveTimeout Duration
255 APIResponseCompression bool
256 ApplicationMimetypesWithViewIcon StringSet
257 ArvadosDocsite string
258 ArvadosPublicDataDocURL string
259 DefaultOpenIdPrefix string
260 EnableGettingStartedPopup bool
261 EnablePublicProjectsPage bool
262 FileViewersConfigURL string
263 LogViewerMaxBytes ByteSize
264 MultiSiteSearch string
265 ProfilingEnabled bool
267 RepositoryCache string
268 RunningJobLogRecordsToFetch int
270 ShowRecentCollectionsOnDashboard bool
271 ShowUserAgreementInline bool
272 ShowUserNotifications bool
275 UserProfileFormFields map[string]struct {
277 FormFieldTitle string
278 FormFieldDescription string
281 Options map[string]struct{}
283 UserProfileFormMessage string
284 WelcomePageHTML string
285 InactivePageHTML string
286 SSHHelpPageHTML string
287 SSHHelpHostSuffix string
292 type StorageClassConfig struct {
298 AccessViaHosts map[URL]VolumeAccess
301 StorageClasses map[string]bool
303 DriverParameters json.RawMessage
306 type S3VolumeDriverParameters struct {
309 SecretAccessKey string
313 LocationConstraint bool
315 UseAWSS3v2Driver bool
317 ConnectTimeout Duration
324 type AzureVolumeDriverParameters struct {
325 StorageAccountName string
326 StorageAccountKey string
327 StorageBaseURL string
329 RequestTimeout Duration
330 ListBlobsRetryDelay Duration
331 ListBlobsMaxAttempts int
334 type DirectoryVolumeDriverParameters struct {
339 type VolumeAccess struct {
343 type Services struct {
346 DispatchCloud Service
355 WebDAVDownload Service
363 type Service struct {
364 InternalURLs map[URL]ServiceInstance
368 type TestUser struct {
373 // URL is a url.URL that is also usable as a JSON key/value.
376 // UnmarshalText implements encoding.TextUnmarshaler so URL can be
377 // used as a JSON key/value.
378 func (su *URL) UnmarshalText(text []byte) error {
379 u, err := url.Parse(string(text))
382 if su.Path == "" && su.Host != "" {
383 // http://example really means http://example/
390 func (su URL) MarshalText() ([]byte, error) {
391 return []byte(fmt.Sprintf("%s", (*url.URL)(&su).String())), nil
394 func (su URL) String() string {
395 return (*url.URL)(&su).String()
398 type ServiceInstance struct {
399 Rendezvous string `json:",omitempty"`
402 type PostgreSQL struct {
403 Connection PostgreSQLConnection
407 type PostgreSQLConnection map[string]string
409 type RemoteCluster struct {
417 type CUDAFeatures struct {
419 HardwareCapability string
423 type InstanceType struct {
429 IncludedScratch ByteSize
430 AddedScratch ByteSize
436 type ContainersConfig struct {
437 CloudVMs CloudVMsConfig
438 CrunchRunCommand string
439 CrunchRunArgumentsList []string
440 DefaultKeepCacheRAM ByteSize
441 DispatchPrivateKey string
442 LogReuseDecisions bool
444 MaxDispatchAttempts int
446 MinRetryPeriod Duration
447 ReserveExtraRAM ByteSize
448 StaleLockTimeout Duration
449 SupportedDockerImageFormats StringSet
450 AlwaysUsePreemptibleInstances bool
452 LocalKeepBlobBuffersPerVCPU int
453 LocalKeepLogsToContainerLog string
457 GitInternalDir string
462 LogSecondsBetweenEvents Duration
463 LogThrottlePeriod Duration
466 LimitLogBytesPerJob int
467 LogPartialLineThrottlePeriod Duration
468 LogUpdatePeriod Duration
469 LogUpdateSize ByteSize
477 SbatchArgumentsList []string
478 SbatchEnvironmentVariables map[string]string
480 DNSServerConfDir string
481 DNSServerConfTemplate string
482 DNSServerReloadCommand string
483 DNSServerUpdateCommand string
484 ComputeNodeDomain string
485 ComputeNodeNameservers StringSet
486 AssignNodeHostname string
491 BsubArgumentsList []string
492 BsubCUDAArguments []string
496 type CloudVMsConfig struct {
499 BootProbeCommand string
500 DeployRunnerBinary string
502 MaxCloudOpsPerSecond int
503 MaxProbesPerSecond int
504 MaxConcurrentInstanceCreateOps int
505 PollInterval Duration
506 ProbeInterval Duration
508 SyncInterval Duration
509 TimeoutBooting Duration
511 TimeoutProbe Duration
512 TimeoutShutdown Duration
513 TimeoutSignal Duration
514 TimeoutStaleRunLock Duration
516 ResourceTags map[string]string
520 DriverParameters json.RawMessage
523 type InstanceTypeMap map[string]InstanceType
525 var errDuplicateInstanceTypeName = errors.New("duplicate instance type name")
527 // UnmarshalJSON handles old config files that provide an array of
528 // instance types instead of a hash.
529 func (it *InstanceTypeMap) UnmarshalJSON(data []byte) error {
530 fixup := func(t InstanceType) (InstanceType, error) {
531 if t.ProviderType == "" {
532 t.ProviderType = t.Name
535 t.Scratch = t.IncludedScratch + t.AddedScratch
536 } else if t.AddedScratch == 0 {
537 t.AddedScratch = t.Scratch - t.IncludedScratch
538 } else if t.IncludedScratch == 0 {
539 t.IncludedScratch = t.Scratch - t.AddedScratch
542 if t.Scratch != (t.IncludedScratch + t.AddedScratch) {
543 return t, fmt.Errorf("InstanceType %q: Scratch != (IncludedScratch + AddedScratch)", t.Name)
548 if len(data) > 0 && data[0] == '[' {
549 var arr []InstanceType
550 err := json.Unmarshal(data, &arr)
558 *it = make(map[string]InstanceType, len(arr))
559 for _, t := range arr {
560 if _, ok := (*it)[t.Name]; ok {
561 return errDuplicateInstanceTypeName
571 var hash map[string]InstanceType
572 err := json.Unmarshal(data, &hash)
576 // Fill in Name field (and ProviderType field, if not
577 // specified) using hash key.
578 *it = InstanceTypeMap(hash)
579 for name, t := range *it {
590 type StringSet map[string]struct{}
592 // UnmarshalJSON handles old config files that provide an array of
593 // instance types instead of a hash.
594 func (ss *StringSet) UnmarshalJSON(data []byte) error {
595 if len(data) > 0 && data[0] == '[' {
597 err := json.Unmarshal(data, &arr)
605 *ss = make(map[string]struct{}, len(arr))
606 for _, t := range arr {
607 (*ss)[t] = struct{}{}
611 var hash map[string]struct{}
612 err := json.Unmarshal(data, &hash)
616 *ss = make(map[string]struct{}, len(hash))
617 for t := range hash {
618 (*ss)[t] = struct{}{}
624 type ServiceName string
627 ServiceNameRailsAPI ServiceName = "arvados-api-server"
628 ServiceNameController ServiceName = "arvados-controller"
629 ServiceNameDispatchCloud ServiceName = "arvados-dispatch-cloud"
630 ServiceNameDispatchLSF ServiceName = "arvados-dispatch-lsf"
631 ServiceNameHealth ServiceName = "arvados-health"
632 ServiceNameWorkbench1 ServiceName = "arvados-workbench1"
633 ServiceNameWorkbench2 ServiceName = "arvados-workbench2"
634 ServiceNameWebsocket ServiceName = "arvados-ws"
635 ServiceNameKeepbalance ServiceName = "keep-balance"
636 ServiceNameKeepweb ServiceName = "keep-web"
637 ServiceNameKeepproxy ServiceName = "keepproxy"
638 ServiceNameKeepstore ServiceName = "keepstore"
641 // Map returns all services as a map, suitable for iterating over all
642 // services or looking up a service by name.
643 func (svcs Services) Map() map[ServiceName]Service {
644 return map[ServiceName]Service{
645 ServiceNameRailsAPI: svcs.RailsAPI,
646 ServiceNameController: svcs.Controller,
647 ServiceNameDispatchCloud: svcs.DispatchCloud,
648 ServiceNameDispatchLSF: svcs.DispatchLSF,
649 ServiceNameHealth: svcs.Health,
650 ServiceNameWorkbench1: svcs.Workbench1,
651 ServiceNameWorkbench2: svcs.Workbench2,
652 ServiceNameWebsocket: svcs.Websocket,
653 ServiceNameKeepbalance: svcs.Keepbalance,
654 ServiceNameKeepweb: svcs.WebDAV,
655 ServiceNameKeepproxy: svcs.Keepproxy,
656 ServiceNameKeepstore: svcs.Keepstore,