1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
14 "git.curoverse.com/arvados.git/sdk/go/config"
17 var DefaultConfigFile = func() string {
18 if path := os.Getenv("ARVADOS_CONFIG"); path != "" {
21 return "/etc/arvados/config.yml"
26 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 if cc, ok := sc.Clusters[clusterID]; !ok {
53 return nil, fmt.Errorf("cluster %q is not configured", clusterID)
55 cc.ClusterID = clusterID
61 ClusterID string `json:"-"`
62 ManagementToken string
63 SystemRootToken string
65 InstanceTypes InstanceTypeMap
66 Containers ContainersConfig
67 RemoteClusters map[string]RemoteCluster
71 AsyncPermissionsUpdateInterval Duration
73 MaxIndexDatabaseRead int
74 MaxItemsPerResponse int
75 MaxRequestAmplification int
77 RailsSessionSecretToken string
78 RequestTimeout Duration
83 UnloggedAttributes []string
88 BlobSigningTTL Duration
89 CollectionVersioning bool
90 DefaultTrashLifetime Duration
91 DefaultReplication int
92 ManagedProperties map[string]struct {
97 PreserveVersionIfIdle Duration
98 TrashSweepInterval Duration
105 ProviderAppSecret string
109 MailchimpAPIKey string
110 MailchimpListID string
111 SendUserSetupNotificationEmail bool
112 IssueReporterEmailFrom string
113 IssueReporterEmailTo string
114 SupportEmailAddress string
120 MaxRequestLogParamsSize int
128 AnonymousUserToken string
129 AdminNotifierEmailFrom string
130 AutoAdminFirstUser bool
131 AutoAdminUserWithEmail string
132 AutoSetupNewUsers bool
133 AutoSetupNewUsersWithRepository bool
134 AutoSetupNewUsersWithVmUUID string
135 AutoSetupUsernameBlacklist []string
136 EmailSubjectPrefix string
137 NewInactiveUserNotificationRecipients []string
138 NewUserNotificationRecipients []string
139 NewUsersAreActive bool
140 UserNotifierEmailFrom string
141 UserProfileNotificationAddress string
144 ActivationContactLink string
145 APIClientConnectTimeout Duration
146 APIClientReceiveTimeout Duration
147 APIResponseCompression bool
148 ApplicationMimetypesWithViewIcon map[string]struct{}
149 ArvadosDocsite string
150 ArvadosPublicDataDocURL string
151 DefaultOpenIdPrefix string
152 EnableGettingStartedPopup bool
153 EnablePublicProjectsPage bool
154 FileViewersConfigURL string
155 LogViewerMaxBytes ByteSize
156 MultiSiteSearch string
157 ProfilingEnabled bool
159 RepositoryCache string
160 RunningJobLogRecordsToFetch int
162 ShowRecentCollectionsOnDashboard bool
163 ShowUserAgreementInline bool
164 ShowUserNotifications bool
167 UserProfileFormFields map[string]struct {
169 FormFieldTitle string
170 FormFieldDescription string
173 Options map[string]struct{}
175 UserProfileFormMessage string
179 EnableBetaController14287 bool
182 type Services struct {
185 DispatchCloud Service
195 WebDAVDownload Service
203 type Service struct {
204 InternalURLs map[URL]ServiceInstance
208 // URL is a url.URL that is also usable as a JSON key/value.
211 // UnmarshalText implements encoding.TextUnmarshaler so URL can be
212 // used as a JSON key/value.
213 func (su *URL) UnmarshalText(text []byte) error {
214 u, err := url.Parse(string(text))
221 func (su URL) MarshalText() ([]byte, error) {
222 return []byte(fmt.Sprintf("%s", (*url.URL)(&su).String())), nil
225 type ServiceInstance struct{}
227 type PostgreSQL struct {
228 Connection PostgreSQLConnection
232 type PostgreSQLConnection map[string]string
234 type RemoteCluster struct {
242 type InstanceType struct {
248 IncludedScratch ByteSize
249 AddedScratch ByteSize
254 type ContainersConfig struct {
255 CloudVMs CloudVMsConfig
256 CrunchRunCommand string
257 CrunchRunArgumentsList []string
258 DefaultKeepCacheRAM ByteSize
259 DispatchPrivateKey string
260 LogReuseDecisions bool
262 MaxDispatchAttempts int
264 MinRetryPeriod Duration
265 ReserveExtraRAM ByteSize
266 StaleLockTimeout Duration
267 SupportedDockerImageFormats []string
268 UsePreemptibleInstances bool
272 GitInternalDir string
273 DefaultDockerImage string
274 CrunchJobWrapper string
276 CrunchRefreshTrigger string
277 ReuseJobIfOutputsDiffer bool
282 LogSecondsBetweenEvents int
283 LogThrottlePeriod Duration
286 LimitLogBytesPerJob int
287 LogPartialLineThrottlePeriod Duration
288 LogUpdatePeriod Duration
289 LogUpdateSize ByteSize
293 SbatchArgumentsList []string
295 DNSServerConfDir string
296 DNSServerConfTemplate string
297 DNSServerReloadCommand string
298 DNSServerUpdateCommand string
299 ComputeNodeDomain string
300 ComputeNodeNameservers []string
301 AssignNodeHostname string
306 type CloudVMsConfig struct {
309 BootProbeCommand string
311 MaxCloudOpsPerSecond int
312 MaxProbesPerSecond int
313 PollInterval Duration
314 ProbeInterval Duration
316 SyncInterval Duration
317 TimeoutBooting Duration
319 TimeoutProbe Duration
320 TimeoutShutdown Duration
321 TimeoutSignal Duration
323 ResourceTags map[string]string
327 DriverParameters json.RawMessage
330 type InstanceTypeMap map[string]InstanceType
332 var errDuplicateInstanceTypeName = errors.New("duplicate instance type name")
334 // UnmarshalJSON handles old config files that provide an array of
335 // instance types instead of a hash.
336 func (it *InstanceTypeMap) UnmarshalJSON(data []byte) error {
337 if len(data) > 0 && data[0] == '[' {
338 var arr []InstanceType
339 err := json.Unmarshal(data, &arr)
347 *it = make(map[string]InstanceType, len(arr))
348 for _, t := range arr {
349 if _, ok := (*it)[t.Name]; ok {
350 return errDuplicateInstanceTypeName
352 if t.ProviderType == "" {
353 t.ProviderType = t.Name
356 t.Scratch = t.IncludedScratch + t.AddedScratch
357 } else if t.AddedScratch == 0 {
358 t.AddedScratch = t.Scratch - t.IncludedScratch
359 } else if t.IncludedScratch == 0 {
360 t.IncludedScratch = t.Scratch - t.AddedScratch
363 if t.Scratch != (t.IncludedScratch + t.AddedScratch) {
364 return fmt.Errorf("%v: Scratch != (IncludedScratch + AddedScratch)", t.Name)
370 var hash map[string]InstanceType
371 err := json.Unmarshal(data, &hash)
375 // Fill in Name field (and ProviderType field, if not
376 // specified) using hash key.
377 *it = InstanceTypeMap(hash)
378 for name, t := range *it {
380 if t.ProviderType == "" {
381 t.ProviderType = name
388 type ServiceName string
391 ServiceNameRailsAPI ServiceName = "arvados-api-server"
392 ServiceNameController ServiceName = "arvados-controller"
393 ServiceNameDispatchCloud ServiceName = "arvados-dispatch-cloud"
394 ServiceNameHealth ServiceName = "arvados-health"
395 ServiceNameNodemanager ServiceName = "arvados-node-manager"
396 ServiceNameWorkbench1 ServiceName = "arvados-workbench1"
397 ServiceNameWorkbench2 ServiceName = "arvados-workbench2"
398 ServiceNameWebsocket ServiceName = "arvados-ws"
399 ServiceNameKeepbalance ServiceName = "keep-balance"
400 ServiceNameKeepweb ServiceName = "keep-web"
401 ServiceNameKeepproxy ServiceName = "keepproxy"
402 ServiceNameKeepstore ServiceName = "keepstore"
405 // Map returns all services as a map, suitable for iterating over all
406 // services or looking up a service by name.
407 func (svcs Services) Map() map[ServiceName]Service {
408 return map[ServiceName]Service{
409 ServiceNameRailsAPI: svcs.RailsAPI,
410 ServiceNameController: svcs.Controller,
411 ServiceNameDispatchCloud: svcs.DispatchCloud,
412 ServiceNameHealth: svcs.Health,
413 ServiceNameNodemanager: svcs.Nodemanager,
414 ServiceNameWorkbench1: svcs.Workbench1,
415 ServiceNameWorkbench2: svcs.Workbench2,
416 ServiceNameWebsocket: svcs.Websocket,
417 ServiceNameKeepbalance: svcs.Keepbalance,
418 ServiceNameKeepweb: svcs.WebDAV,
419 ServiceNameKeepproxy: svcs.Keepproxy,
420 ServiceNameKeepstore: svcs.Keepstore,