}
// update config using values from an old-style keepstore config file.
-func (ldr *Loader) loadOldKeepstoreConfig(cfg *arvados.Config) error {
+func (ldr *Loader) loadOldKeepstoreConfig(cfg *arvados.Config, required bool) error {
var oc oldKeepstoreConfig
err := ldr.loadOldConfigHelper("keepstore", ldr.KeepstorePath, &oc)
- if os.IsNotExist(err) && ldr.KeepstorePath == defaultKeepstoreConfigPath {
+ if os.IsNotExist(err) && !required {
return nil
} else if err != nil {
return err
}
// update config using values from an crunch-dispatch-slurm config file.
-func (ldr *Loader) loadOldCrunchDispatchSlurmConfig(cfg *arvados.Config) error {
+func (ldr *Loader) loadOldCrunchDispatchSlurmConfig(cfg *arvados.Config, required bool) error {
var oc oldCrunchDispatchSlurmConfig
err := ldr.loadOldConfigHelper("crunch-dispatch-slurm", ldr.CrunchDispatchSlurmPath, &oc)
- if os.IsNotExist(err) && ldr.CrunchDispatchSlurmPath == defaultCrunchDispatchSlurmConfigPath {
+ if os.IsNotExist(err) && !required {
return nil
} else if err != nil {
return err
ManagementToken *string
}
-const defaultWebsocketsConfigPath = "/etc/arvados/ws/ws.yml"
+const defaultWebsocketConfigPath = "/etc/arvados/ws/ws.yml"
// update config using values from an crunch-dispatch-slurm config file.
-func (ldr *Loader) loadOldWebsocketsConfig(cfg *arvados.Config) error {
+func (ldr *Loader) loadOldWebsocketConfig(cfg *arvados.Config, required bool) error {
var oc oldWsConfig
- err := ldr.loadOldConfigHelper("arvados-ws", ldr.WebsocketsPath, &oc)
- if os.IsNotExist(err) && ldr.WebsocketsPath == defaultWebsocketsConfigPath {
+ err := ldr.loadOldConfigHelper("arvados-ws", ldr.WebsocketPath, &oc)
+ if os.IsNotExist(err) && !required {
return nil
} else if err != nil {
return err
}
loadOldClientConfig(cluster, oc.Client)
- fmt.Printf("Clllllllllllient %v %v", *oc.Client, cluster.Services.Controller.ExternalURL)
if oc.Postgres != nil {
cluster.PostgreSQL.Connection = *oc.Postgres
cluster.SystemLogs.Format = *oc.LogFormat
}
if oc.PingTimeout != nil {
- cluster.API.WebsocketKeepaliveTimeout = *oc.PingTimeout
+ cluster.API.SendTimeout = *oc.PingTimeout
}
if oc.ClientEventQueue != nil {
cluster.API.WebsocketClientEventQueue = *oc.ClientEventQueue
Path string
KeepstorePath string
CrunchDispatchSlurmPath string
- WebsocketsPath string
+ WebsocketPath string
+
+ // Legacy config file for the current component (will be the
+ // same as one of the above files). If set, not being able to
+ // load the 'main' config.yml will not be a fatal error, but
+ // the the legacy file will be required instead.
+ LegacyComponentConfig string
configdata []byte
}
flagset.StringVar(&ldr.Path, "config", arvados.DefaultConfigFile, "Site configuration `file` (default may be overridden by setting an ARVADOS_CONFIG environment variable)")
flagset.StringVar(&ldr.KeepstorePath, "legacy-keepstore-config", defaultKeepstoreConfigPath, "Legacy keepstore configuration `file`")
flagset.StringVar(&ldr.CrunchDispatchSlurmPath, "legacy-crunch-dispatch-slurm-config", defaultCrunchDispatchSlurmConfigPath, "Legacy crunch-dispatch-slurm configuration `file`")
- flagset.StringVar(&ldr.WebsocketsPath, "legacy-ws-config", defaultWebsocketsConfigPath, "Legacy arvados-ws configuration `file`")
+ flagset.StringVar(&ldr.WebsocketPath, "legacy-ws-config", defaultWebsocketConfigPath, "Legacy arvados-ws configuration `file`")
}
// MungeLegacyConfigArgs checks args for a -config flag whose argument
return ioutil.ReadAll(f)
}
-func (ldr *Loader) LoadDefaults() (*arvados.Config, error) {
- ldr.configdata = []byte(`Clusters: {zzzzz: {}}`)
- defer func() { ldr.configdata = nil }()
- return ldr.Load()
-}
-
func (ldr *Loader) Load() (*arvados.Config, error) {
if ldr.configdata == nil {
buf, err := ldr.loadBytes(ldr.Path)
if err != nil {
- return nil, err
+ if ldr.LegacyComponentConfig != "" && os.IsNotExist(err) && !ldr.SkipDeprecated {
+ buf = []byte(`Clusters: {zzzzz: {}}`)
+ } else {
+ return nil, err
+ }
}
ldr.configdata = buf
}
+ noConfigLoaded := bytes.Compare(ldr.configdata, []byte(`Clusters: {zzzzz: {}}`)) == 0
// Load the config into a dummy map to get the cluster ID
// keys, discarding the values; then set up defaults for each
if err != nil {
return nil, err
}
+ // legacy file is required when either:
+ // * a non-default location was specified
+ // * no primary config was loaded, and this is the
+ // legacy config file for the current component
for _, err := range []error{
- ldr.loadOldKeepstoreConfig(&cfg),
- ldr.loadOldCrunchDispatchSlurmConfig(&cfg),
- ldr.loadOldWebsocketsConfig(&cfg),
+ ldr.loadOldKeepstoreConfig(&cfg, (ldr.KeepstorePath != defaultKeepstoreConfigPath) ||
+ (noConfigLoaded && ldr.LegacyComponentConfig == ldr.KeepstorePath)),
+
+ ldr.loadOldCrunchDispatchSlurmConfig(&cfg, (ldr.CrunchDispatchSlurmPath != defaultCrunchDispatchSlurmConfigPath) ||
+ (noConfigLoaded && ldr.LegacyComponentConfig == ldr.CrunchDispatchSlurmPath)),
+
+ ldr.loadOldWebsocketConfig(&cfg, (ldr.WebsocketPath != defaultWebsocketConfigPath) ||
+ (noConfigLoaded && ldr.LegacyComponentConfig == ldr.WebsocketPath)),
} {
if err != nil {
return nil, err
MaxRequestSize int
RailsSessionSecretToken string
RequestTimeout Duration
- WebsocketKeepaliveTimeout Duration
+ SendTimeout Duration
WebsocketClientEventQueue int
WebsocketServerEventQueue int
}
disp.logger.Printf("crunch-dispatch-slurm %s started", version)
+ loader.LegacyComponentConfig = loader.CrunchDispatchSlurmPath
cfg, err := loader.Load()
if err != nil {
return err
return nil
}
+ loader.LegacyComponentConfig = loader.WebsocketPath
cfg, err := loader.Load()
if err != nil {
log.Fatal(err)
func (rtr *router) setup() {
rtr.handler = &handler{
- PingTimeout: time.Duration(rtr.cluster.API.WebsocketKeepaliveTimeout),
+ PingTimeout: time.Duration(rtr.cluster.API.SendTimeout),
QueueSize: rtr.cluster.API.WebsocketClientEventQueue,
}
rtr.mux = http.NewServeMux()
func (*serverSuite) testConfig() (*arvados.Cluster, error) {
ldr := config.NewLoader(nil, nil)
- cfg, err := ldr.LoadDefaults()
+ ldr.LegacyComponentConfig = "ws-test"
+ cfg, err := ldr.Load()
if err != nil {
return nil, err
}