summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMark Washenberger <mark.washenberger@rackspace.com>2011-11-18 17:18:41 -0500
committerMark Washenberger <mark.washenberger@rackspace.com>2011-11-18 17:37:48 -0500
commita46e2a6e00ab96a70b6cc4c429200f304606cbed (patch)
treed6355e6972d3e7db9de45f65a7c7f4b4f5473d1e /plugins
parent55ebe48ab8026d3806c3f0521fb4643634c1162b (diff)
downloadnova-a46e2a6e00ab96a70b6cc4c429200f304606cbed.tar.gz
nova-a46e2a6e00ab96a70b6cc4c429200f304606cbed.tar.xz
nova-a46e2a6e00ab96a70b6cc4c429200f304606cbed.zip
Workaround xenstore race conditions
Change-Id: I17791a78c2008e1bdc41f4f658200808ee72629c
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/xenserver/xenapi/etc/xapi.d/plugins/xenstore.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenstore.py b/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenstore.py
index c75013084..7e27b4ff7 100755
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenstore.py
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenstore.py
@@ -91,12 +91,15 @@ def read_record(self, arg_dict):
ret, result = _run_command(cmd)
return result.strip()
except XenstoreError, e:
- if arg_dict.get("ignore_missing_path", False):
- if not _record_exists(arg_dict):
- return "None"
- # Either we shouldn't ignore path errors, or another
- # error was hit. Re-raise.
- raise
+ if not arg_dict.get("ignore_missing_path", False):
+ raise
+ if not _record_exists(arg_dict):
+ return "None"
+ # Just try again in case the agent write won the race against
+ # the record_exists check. If this fails again, it will likely raise
+ # an equally meaningful XenstoreError as the one we just caught
+ ret, result = _run_command(cmd)
+ return result.strip()
@jsonify
@@ -128,7 +131,10 @@ def list_records(self, arg_dict):
except XenstoreError, e:
if not _record_exists(arg_dict):
return {}
- raise
+ # Just try again in case the path was created in between
+ # the "ls" and the existence check. If this fails again, it will
+ # likely raise an equally meaningful XenstoreError
+ ret, recs = _run_command(cmd)
base_path = arg_dict["path"]
paths = _paths_from_ls(recs)
ret = {}