Debug *bool
}
-func (ldr *Loader) loadOldConfigHelper(component, path, defaultPath string, target interface{}) error {
+func (ldr *Loader) loadOldConfigHelper(component, path string, target interface{}) error {
if path == "" {
return nil
}
buf, err := ioutil.ReadFile(path)
- if os.IsNotExist(err) && path == defaultPath {
- return nil
- } else if err != nil {
+ if err != nil {
return err
- } else {
- ldr.Logger.Warnf("you should remove the legacy %v config file (%s) after migrating all config keys to the cluster configuration file (%s)", component, path, ldr.Path)
}
+ ldr.Logger.Warnf("you should remove the legacy %v config file (%s) after migrating all config keys to the cluster configuration file (%s)", component, path, ldr.Path)
+
err = yaml.Unmarshal(buf, target)
if err != nil {
return fmt.Errorf("%s: %s", path, err)
// update config using values from an old-style keepstore config file.
func (ldr *Loader) loadOldKeepstoreConfig(cfg *arvados.Config) error {
var oc oldKeepstoreConfig
- err := ldr.loadOldConfigHelper("keepstore", ldr.KeepstorePath, defaultKeepstoreConfigPath, &oc)
- if err != nil {
+ err := ldr.loadOldConfigHelper("keepstore", ldr.KeepstorePath, &oc)
+ if os.IsNotExist(err) && ldr.KeepstorePath == defaultKeepstoreConfigPath {
+ return nil
+ } else if err != nil {
return err
}
}
type oldCrunchDispatchSlurmConfig struct {
- Client arvados.Client
+ Client *arvados.Client
- SbatchArguments []string
- PollPeriod arvados.Duration
- PrioritySpread int64
+ SbatchArguments *[]string
+ PollPeriod *arvados.Duration
+ PrioritySpread *int64
// crunch-run command to invoke. The container UUID will be
// appended. If nil, []string{"crunch-run"} will be used.
//
// Example: []string{"crunch-run", "--cgroup-parent-subsystem=memory"}
- CrunchRunCommand []string
+ CrunchRunCommand *[]string
// Extra RAM to reserve (in Bytes) for SLURM job, in addition
// to the amount specified in the container's RuntimeConstraints
- ReserveExtraRAM int64
+ ReserveExtraRAM *int64
// Minimum time between two attempts to run the same container
- MinRetryPeriod arvados.Duration
+ MinRetryPeriod *arvados.Duration
// Batch size for container queries
- BatchSize int64
+ BatchSize *int64
}
const defaultCrunchDispatchSlurmConfigPath = "/etc/arvados/crunch-dispatch-slurm/crunch-dispatch-slurm.yml"
// update config using values from an crunch-dispatch-slurm config file.
func (ldr *Loader) loadOldCrunchDispatchSlurmConfig(cfg *arvados.Config) error {
var oc oldCrunchDispatchSlurmConfig
- err := ldr.loadOldConfigHelper("crunch-dispatch-slurm", ldr.CrunchDispatchSlurmPath, defaultCrunchDispatchSlurmConfigPath, &oc)
- if err != nil {
+ err := ldr.loadOldConfigHelper("crunch-dispatch-slurm", ldr.CrunchDispatchSlurmPath, &oc)
+ if os.IsNotExist(err) && ldr.CrunchDispatchSlurmPath == defaultCrunchDispatchSlurmConfigPath {
+ return nil
+ } else if err != nil {
return err
}
return err
}
- u := arvados.URL{}
- u.Host = oc.Client.APIHost
- if oc.Client.Scheme != "" {
- u.Scheme = oc.Client.Scheme
- } else {
- u.Scheme = "https"
+ if oc.Client != nil {
+ u := arvados.URL{}
+ u.Host = oc.Client.APIHost
+ if oc.Client.Scheme != "" {
+ u.Scheme = oc.Client.Scheme
+ } else {
+ u.Scheme = "https"
+ }
+ cluster.Services.Controller.ExternalURL = u
+ cluster.SystemRootToken = oc.Client.AuthToken
+ cluster.TLS.Insecure = oc.Client.Insecure
}
- cluster.Services.Controller.ExternalURL = u
- cluster.SystemRootToken = oc.Client.AuthToken
- cluster.TLS.Insecure = oc.Client.Insecure
- cluster.Containers.SLURM.SbatchArgumentsList = oc.SbatchArguments
- cluster.Containers.CloudVMs.PollInterval = oc.PollPeriod
- cluster.Containers.SLURM.PrioritySpread = oc.PrioritySpread
- if len(oc.CrunchRunCommand) >= 1 {
- cluster.Containers.CrunchRunCommand = oc.CrunchRunCommand[0]
+ if oc.SbatchArguments != nil {
+ cluster.Containers.SLURM.SbatchArgumentsList = *oc.SbatchArguments
}
- if len(oc.CrunchRunCommand) >= 2 {
- cluster.Containers.CrunchRunArgumentsList = oc.CrunchRunCommand[1:]
+ if oc.PollPeriod != nil {
+ cluster.Containers.CloudVMs.PollInterval = *oc.PollPeriod
+ }
+ if oc.PrioritySpread != nil {
+ cluster.Containers.SLURM.PrioritySpread = *oc.PrioritySpread
+ }
+ if oc.CrunchRunCommand != nil {
+ if len(*oc.CrunchRunCommand) >= 1 {
+ cluster.Containers.CrunchRunCommand = (*oc.CrunchRunCommand)[0]
+ }
+ if len(*oc.CrunchRunCommand) >= 2 {
+ cluster.Containers.CrunchRunArgumentsList = (*oc.CrunchRunCommand)[1:]
+ }
+ }
+ if oc.ReserveExtraRAM != nil {
+ cluster.Containers.ReserveExtraRAM = arvados.ByteSize(*oc.ReserveExtraRAM)
+ }
+ if oc.MinRetryPeriod != nil {
+ cluster.Containers.MinRetryPeriod = *oc.MinRetryPeriod
+ }
+ if oc.BatchSize != nil {
+ cluster.API.MaxItemsPerResponse = int(*oc.BatchSize)
}
- cluster.Containers.ReserveExtraRAM = arvados.ByteSize(oc.ReserveExtraRAM)
- cluster.Containers.MinRetryPeriod = oc.MinRetryPeriod
-
- cluster.API.MaxItemsPerResponse = int(oc.BatchSize)
cfg.Clusters[cluster.ClusterID] = *cluster
return nil