9956: Load volume config from YAML file
[arvados.git] / services / keepstore / trash_worker.go
index 65e3fbd2849593e44be94921cb7073a5aba3adaa..27d6216d01633feca360de94f0a8febaabfb475a 100644 (file)
@@ -4,6 +4,8 @@ import (
        "errors"
        "log"
        "time"
+
+       "git.curoverse.com/arvados.git/sdk/go/arvados"
 )
 
 // RunTrashWorker is used by Keepstore to initiate trash worker channel goroutine.
@@ -22,14 +24,14 @@ func RunTrashWorker(trashq *WorkQueue) {
 
 // TrashItem deletes the indicated block from every writable volume.
 func TrashItem(trashRequest TrashRequest) {
-       reqMtime := time.Unix(trashRequest.BlockMtime, 0)
-       if time.Since(reqMtime) < blobSignatureTTL {
+       reqMtime := time.Unix(0, trashRequest.BlockMtime)
+       if time.Since(reqMtime) < theConfig.BlobSignatureTTL.Duration() {
                log.Printf("WARNING: data manager asked to delete a %v old block %v (BlockMtime %d = %v), but my blobSignatureTTL is %v! Skipping.",
-                       time.Since(reqMtime),
+                       arvados.Duration(time.Since(reqMtime)),
                        trashRequest.Locator,
                        trashRequest.BlockMtime,
                        reqMtime,
-                       blobSignatureTTL)
+                       theConfig.BlobSignatureTTL)
                return
        }
 
@@ -39,15 +41,15 @@ func TrashItem(trashRequest TrashRequest) {
                        log.Printf("%v Delete(%v): %v", volume, trashRequest.Locator, err)
                        continue
                }
-               if trashRequest.BlockMtime != mtime.Unix() {
-                       log.Printf("%v Delete(%v): mtime on volume is %v does not match trash list value %v", volume, trashRequest.Locator, mtime.Unix(), trashRequest.BlockMtime)
+               if trashRequest.BlockMtime != mtime.UnixNano() {
+                       log.Printf("%v Delete(%v): stored mtime %v does not match trash list value %v", volume, trashRequest.Locator, mtime.UnixNano(), trashRequest.BlockMtime)
                        continue
                }
 
-               if neverDelete {
-                       err = errors.New("did not delete block because neverDelete is true")
+               if !theConfig.EnableDelete {
+                       err = errors.New("did not delete block because EnableDelete is false")
                } else {
-                       err = volume.Delete(trashRequest.Locator)
+                       err = volume.Trash(trashRequest.Locator)
                }
 
                if err != nil {