From 89de29529309ea1d5d93017ddf588d1fb3049082 Mon Sep 17 00:00:00 2001 From: Mehran Kholdi Date: Sat, 26 Jun 2021 01:18:00 +0430 Subject: [PATCH] Fix race condition by making the scrub function idempotent Under certain situtations, a race condition could lead to pvc deletion tasks getting stuck in a failing state. --- remote.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/remote.py b/remote.py index 6e3f138..56436dc 100644 --- a/remote.py +++ b/remote.py @@ -6,6 +6,10 @@ def scrub(volume_id): import time import rawfile_util + img_dir = rawfile_util.img_dir(volume_id) + if not img_dir.exists(): + return + now = time.time() deleted_at = now gc_at = now # TODO: GC sensitive PVCs later