21126: Disable trash if BlobTrashConcurrency: 0, as documented.
[arvados.git] / services / keepstore / command.go
index 94dabfda6207d564fc605cce499c967f0af25b35..9761680fb5137e8601e1a389a918fadecf7a9bc3 100644 (file)
@@ -27,7 +27,6 @@ import (
 )
 
 var (
-       version = "dev"
        Command = service.Command(arvados.ServiceNameKeepstore, newHandlerOrErrorHandler)
 )
 
@@ -167,7 +166,7 @@ func (h *handler) setup(ctx context.Context, cluster *arvados.Cluster, token str
                return errors.New("no volumes configured")
        }
 
-       h.Logger.Printf("keepstore %s starting, pid %d", version, os.Getpid())
+       h.Logger.Printf("keepstore %s starting, pid %d", cmd.Version.String(), os.Getpid())
 
        // Start a round-robin VolumeManager with the configured volumes.
        vm, err := makeRRVolumeManager(h.Logger, h.Cluster, serviceURL, newVolumeMetricsVecs(reg))
@@ -187,7 +186,7 @@ func (h *handler) setup(ctx context.Context, cluster *arvados.Cluster, token str
 
        // Initialize the trashq and workers
        h.trashq = NewWorkQueue()
-       for i := 0; i < 1 || i < h.Cluster.Collections.BlobTrashConcurrency; i++ {
+       for i := 0; i < h.Cluster.Collections.BlobTrashConcurrency; i++ {
                go RunTrashWorker(h.volmgr, h.Logger, h.Cluster, h.trashq)
        }
 
@@ -209,7 +208,9 @@ func (h *handler) setup(ctx context.Context, cluster *arvados.Cluster, token str
        }
        h.keepClient.Arvados.ApiToken = fmt.Sprintf("%x", rand.Int63())
 
-       if d := h.Cluster.Collections.BlobTrashCheckInterval.Duration(); d > 0 {
+       if d := h.Cluster.Collections.BlobTrashCheckInterval.Duration(); d > 0 &&
+               h.Cluster.Collections.BlobTrash &&
+               h.Cluster.Collections.BlobDeleteConcurrency > 0 {
                go emptyTrash(h.volmgr.writables, d)
        }