X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/2ca82cf645eb7d9dad60f98e1feca67042c38c47..e9f7d73dc0d84ee7127b8f83a4955521e8091708:/lib/config/load.go diff --git a/lib/config/load.go b/lib/config/load.go index abb3a804ba..d504f7796c 100644 --- a/lib/config/load.go +++ b/lib/config/load.go @@ -26,6 +26,7 @@ import ( "github.com/imdario/mergo" "github.com/prometheus/client_golang/prometheus" "github.com/sirupsen/logrus" + "golang.org/x/crypto/ssh" "golang.org/x/sys/unix" ) @@ -345,6 +346,7 @@ func (ldr *Loader) Load() (*arvados.Config, error) { ldr.checkEnum("Containers.LocalKeepLogsToContainerLog", cc.Containers.LocalKeepLogsToContainerLog, "none", "all", "errors"), ldr.checkEmptyKeepstores(cc), ldr.checkUnlistedKeepstores(cc), + ldr.checkLocalKeepBlobBuffers(cc), ldr.checkStorageClasses(cc), ldr.checkCUDAVersions(cc), // TODO: check non-empty Rendezvous on @@ -366,7 +368,7 @@ func (ldr *Loader) checkClusterID(label, clusterID string, emptyStringOk bool) e if emptyStringOk && clusterID == "" { return nil } else if !acceptableClusterIDRe.MatchString(clusterID) { - return fmt.Errorf("%s: cluster ID should be 5 alphanumeric characters", label) + return fmt.Errorf("%s: cluster ID should be 5 lowercase alphanumeric characters", label) } return nil } @@ -447,6 +449,7 @@ func (ldr *Loader) setLoopbackInstanceType(cfg *arvados.Config) error { RAM: hostram, Scratch: scratch, IncludedScratch: scratch, + Price: 1.0, }} cfg.Clusters[id] = cc } @@ -503,6 +506,24 @@ cluster: return nil } +func (ldr *Loader) checkLocalKeepBlobBuffers(cc arvados.Cluster) error { + kbb := cc.Containers.LocalKeepBlobBuffersPerVCPU + if kbb == 0 { + return nil + } + for uuid, vol := range cc.Volumes { + if len(vol.AccessViaHosts) > 0 { + ldr.Logger.Warnf("LocalKeepBlobBuffersPerVCPU is %d but will not be used because at least one volume (%s) uses AccessViaHosts -- suggest changing to 0", kbb, uuid) + return nil + } + if !vol.ReadOnly && vol.Replication < cc.Collections.DefaultReplication { + ldr.Logger.Warnf("LocalKeepBlobBuffersPerVCPU is %d but will not be used because at least one volume (%s) has lower replication than DefaultReplication (%d < %d) -- suggest changing to 0", kbb, uuid, vol.Replication, cc.Collections.DefaultReplication) + return nil + } + } + return nil +} + func (ldr *Loader) checkStorageClasses(cc arvados.Cluster) error { classOnVolume := map[string]bool{} for volid, vol := range cc.Volumes { @@ -670,3 +691,17 @@ func (ldr *Loader) RegisterMetrics(reg *prometheus.Registry) { vec.WithLabelValues(hash).Set(float64(ldr.loadTimestamp.UnixNano()) / 1e9) reg.MustRegister(vec) } + +// Load an SSH private key from the given confvalue, which is either +// the literal key or an absolute path to a file containing the key. +func LoadSSHKey(confvalue string) (ssh.Signer, error) { + if fnm := strings.TrimPrefix(confvalue, "file://"); fnm != confvalue && strings.HasPrefix(fnm, "/") { + keydata, err := os.ReadFile(fnm) + if err != nil { + return nil, err + } + return ssh.ParsePrivateKey(keydata) + } else { + return ssh.ParsePrivateKey([]byte(confvalue)) + } +}