diff --git a/app/vmstorage/main.go b/app/vmstorage/main.go index 54ead38f3d..8bda8ba7b3 100644 --- a/app/vmstorage/main.go +++ b/app/vmstorage/main.go @@ -32,7 +32,7 @@ var ( snapshotAuthKey = flag.String("snapshotAuthKey", "", "authKey, which must be passed in query string to /snapshot* pages") forceMergeAuthKey = flag.String("forceMergeAuthKey", "", "authKey, which must be passed in query string to /internal/force_merge pages") forceFlushAuthKey = flag.String("forceFlushAuthKey", "", "authKey, which must be passed in query string to /internal/force_flush pages") - snapshotsMaxAge = flag.Duration("snapshotsMaxAge", 0, "Automatically delete snapshots older than -snapshotsMaxAge if it is set to non-zero duration. Make sure that backup process has enough time to finish the backup before the corresponding snapshot is automatically deleted") + snapshotsMaxAge = flagutil.NewDuration("snapshotsMaxAge", "0", "Automatically delete snapshots older than -snapshotsMaxAge if it is set to non-zero duration. Make sure that backup process has enough time to finish the backup before the corresponding snapshot is automatically deleted") finalMergeDelay = flag.Duration("finalMergeDelay", 0, "The delay before starting final merge for per-month partition after no new data is ingested into it. "+ "Final merge may require additional disk IO and CPU resources. Final merge may increase query speed and reduce disk space usage in some cases. "+ @@ -253,9 +253,10 @@ func requestHandler(w http.ResponseWriter, r *http.Request, strg *storage.Storag func initStaleSnapshotsRemover(strg *storage.Storage) { staleSnapshotsRemoverCh = make(chan struct{}) - if *snapshotsMaxAge <= 0 { + if snapshotsMaxAge.Msecs <= 0 { return } + snapshotsMaxAgeDur := time.Duration(snapshotsMaxAge.Msecs) * time.Millisecond staleSnapshotsRemoverWG.Add(1) go func() { defer staleSnapshotsRemoverWG.Done() @@ -267,7 +268,7 @@ func initStaleSnapshotsRemover(strg *storage.Storage) { return case <-t.C: } - if err := strg.DeleteStaleSnapshots(*snapshotsMaxAge); err != nil { + if err := strg.DeleteStaleSnapshots(snapshotsMaxAgeDur); err != nil { // Use logger.Errorf instead of logger.Fatalf in the hope the error is temporary. logger.Errorf("cannot delete stale snapshots: %s", err) }