Merge "Workaround xenstore race conditions"
This commit is contained in:
@@ -91,12 +91,15 @@ def read_record(self, arg_dict):
|
|||||||
ret, result = _run_command(cmd)
|
ret, result = _run_command(cmd)
|
||||||
return result.strip()
|
return result.strip()
|
||||||
except XenstoreError, e:
|
except XenstoreError, e:
|
||||||
if arg_dict.get("ignore_missing_path", False):
|
if not arg_dict.get("ignore_missing_path", False):
|
||||||
if not _record_exists(arg_dict):
|
raise
|
||||||
return "None"
|
if not _record_exists(arg_dict):
|
||||||
# Either we shouldn't ignore path errors, or another
|
return "None"
|
||||||
# error was hit. Re-raise.
|
# Just try again in case the agent write won the race against
|
||||||
raise
|
# 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
|
@jsonify
|
||||||
@@ -128,7 +131,10 @@ def list_records(self, arg_dict):
|
|||||||
except XenstoreError, e:
|
except XenstoreError, e:
|
||||||
if not _record_exists(arg_dict):
|
if not _record_exists(arg_dict):
|
||||||
return {}
|
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"]
|
base_path = arg_dict["path"]
|
||||||
paths = _paths_from_ls(recs)
|
paths = _paths_from_ls(recs)
|
||||||
ret = {}
|
ret = {}
|
||||||
|
Reference in New Issue
Block a user