X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/45f10d80d1b584808a6e375214b5be6bc7d2a730..97b8ba6c2d2023f66cab62b7062cd0dbff837c67:/services/keepstore/trash_worker.go diff --git a/services/keepstore/trash_worker.go b/services/keepstore/trash_worker.go index 8f78658c3a..27d6216d01 100644 --- a/services/keepstore/trash_worker.go +++ b/services/keepstore/trash_worker.go @@ -4,16 +4,16 @@ import ( "errors" "log" "time" -) -/* - Keepstore initiates trash worker channel goroutine. - The channel will process trash list. - For each (next) trash request: - Delete the block indicated by the trash request Locator - Repeat -*/ + "git.curoverse.com/arvados.git/sdk/go/arvados" +) +// RunTrashWorker is used by Keepstore to initiate trash worker channel goroutine. +// The channel will process trash list. +// For each (next) trash request: +// Delete the block indicated by the trash request Locator +// Repeat +// func RunTrashWorker(trashq *WorkQueue) { for item := range trashq.NextItem { trashRequest := item.(TrashRequest) @@ -24,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) < blob_signature_ttl { - log.Printf("WARNING: data manager asked to delete a %v old block %v (BlockMtime %d = %v), but my blob_signature_ttl is %v! Skipping.", - time.Since(reqMtime), + 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.", + arvados.Duration(time.Since(reqMtime)), trashRequest.Locator, trashRequest.BlockMtime, reqMtime, - blob_signature_ttl) + theConfig.BlobSignatureTTL) return } @@ -41,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 never_delete { - err = errors.New("did not delete block because never_delete 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 {