16347: Add LocalKeepLogsToContainerLog config (none/errors/all).
[arvados.git] / lib / config / load.go
index 248960beb99f875620dca5ee7738f8575877c57d..a7419331f0788df0c41dbe9031db17ad73562ce3 100644 (file)
@@ -295,8 +295,10 @@ func (ldr *Loader) Load() (*arvados.Config, error) {
                        ldr.checkToken(fmt.Sprintf("Clusters.%s.SystemRootToken", id), cc.SystemRootToken),
                        ldr.checkToken(fmt.Sprintf("Clusters.%s.Collections.BlobSigningKey", id), cc.Collections.BlobSigningKey),
                        checkKeyConflict(fmt.Sprintf("Clusters.%s.PostgreSQL.Connection", id), cc.PostgreSQL.Connection),
+                       ldr.checkEnum("Containers.LocalKeepLogsToContainerLog", cc.Containers.LocalKeepLogsToContainerLog, "none", "all", "errors"),
                        ldr.checkEmptyKeepstores(cc),
                        ldr.checkUnlistedKeepstores(cc),
+                       ldr.checkLocalKeepstoreVolumes(cc),
                        ldr.checkStorageClasses(cc),
                        // TODO: check non-empty Rendezvous on
                        // services other than Keepstore
@@ -338,6 +340,15 @@ func (ldr *Loader) checkToken(label, token string) error {
        return nil
 }
 
+func (ldr *Loader) checkEnum(label, value string, accepted ...string) error {
+       for _, s := range accepted {
+               if s == value {
+                       return nil
+               }
+       }
+       return fmt.Errorf("%s: unacceptable value %q: must be one of %q", label, value, accepted)
+}
+
 func (ldr *Loader) setImplicitStorageClasses(cfg *arvados.Config) error {
 cluster:
        for id, cc := range cfg.Clusters {
@@ -361,6 +372,18 @@ cluster:
        return nil
 }
 
+func (ldr *Loader) checkLocalKeepstoreVolumes(cc arvados.Cluster) error {
+       if cc.Containers.LocalKeepBlobBuffersPerVCPU < 1 {
+               return nil
+       }
+       for _, vol := range cc.Volumes {
+               if len(vol.AccessViaHosts) == 0 {
+                       return nil
+               }
+       }
+       return fmt.Errorf("LocalKeepBlobBuffersPerVCPU is %d, but no volumes would be accessible from a worker instance", cc.Containers.LocalKeepBlobBuffersPerVCPU)
+}
+
 func (ldr *Loader) checkStorageClasses(cc arvados.Cluster) error {
        classOnVolume := map[string]bool{}
        for volid, vol := range cc.Volumes {