From 2f6118e53e22a8abbfc1245295ed167519c2811e Mon Sep 17 00:00:00 2001 From: Bin Yang Date: Mon, 6 May 2019 12:03:51 +0000 Subject: Fix the intermittent error to get Infra_workload Fix the operation of update backlog to make sure at least one copy of backlog item exists Change-Id: I4b1e6f3ce330c1d8f37a46c547f18e1ef95e67af Issue-ID: MULTICLOUD-603 Signed-off-by: Bin Yang --- share/common/msapi/helper.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'share/common/msapi') diff --git a/share/common/msapi/helper.py b/share/common/msapi/helper.py index 69b91953..de8852c8 100644 --- a/share/common/msapi/helper.py +++ b/share/common/msapi/helper.py @@ -281,6 +281,15 @@ class MultiCloudThreadHelper(object): return False + def expire(self, backlog_id): + # important: the order of operation should make sure + # there is at least 1 copy of backlog item in either backlog or expired backlog + # self.lock.acquire() + backlogitem = self.backlog.get(backlog_id, None) + self.owner.expired_backlog[backlog_id] = backlogitem + self.backlog.pop(backlog_id, None) + # self.lock.release() + def remove(self, backlog_id): # self.lock.acquire() self.backlog.pop(backlog_id, None) @@ -345,7 +354,7 @@ class MultiCloudThreadHelper(object): "status": item["status"] } if item.get("repeat", 0) == 0: - self.owner.remove(backlog_id) + self.owner.expire(backlog_id) # keep only the id and status self.owner.expired_backlog[backlog_id] = {"status": item["status"]} -- cgit 1.2.3-korg