Change in vdsm[master]: jobs: Take lock once when deleting a job

nsoffer at redhat.com nsoffer at redhat.com
Sat Jan 2 13:35:50 UTC 2016


Nir Soffer has uploaded a new change for review.

Change subject: jobs: Take lock once when deleting a job
......................................................................

jobs: Take lock once when deleting a job

Previous we use get() for checking if a job exists before deleting it,
and then check again in _delete. Move all the logic to _delete, so we
take the lock once and during this flow.

With this change, test coverage for this module is 100%.

Change-Id: If6dfb378820ab95cbafb16f0a8df8399f3b8285e
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M lib/vdsm/jobs.py
1 file changed, 4 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/15/51215/1

diff --git a/lib/vdsm/jobs.py b/lib/vdsm/jobs.py
index 008c100..c28ac58 100644
--- a/lib/vdsm/jobs.py
+++ b/lib/vdsm/jobs.py
@@ -132,8 +132,6 @@
 
 def delete(job_id):
     try:
-        job = get(job_id)
-        job.validate_not_active()
         _delete(job_id)
     except ClientError as e:
         logging.info('Cannot delete job, error: %s', e)
@@ -181,6 +179,9 @@
 
 def _delete(job_id):
     with _lock:
-        if job_id not in _jobs:
+        try:
+            job = _jobs[job_id]
+        except KeyError:
             raise NoSuchJob("No such job %r" % job_id)
+        job.validate_not_active()
         del _jobs[job_id]


-- 
To view, visit https://gerrit.ovirt.org/51215
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If6dfb378820ab95cbafb16f0a8df8399f3b8285e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>


More information about the vdsm-patches mailing list