summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Dodson <sdodson@redhat.com>2016-10-26 14:06:59 -0400
committerGitHub <noreply@github.com>2016-10-26 14:06:59 -0400
commit52ab71a6f741f2477ab395d48dacfe609cf1411a (patch)
tree55d0e03fa7d23cc7fca66a5a4af293dedce6824e
parentff1d5889a6585b08c6ebe79b23087f6cf01ce284 (diff)
parent07113bc31ffa60a5fc3f34b392576d4639474485 (diff)
downloadopenshift-52ab71a6f741f2477ab395d48dacfe609cf1411a.tar.gz
openshift-52ab71a6f741f2477ab395d48dacfe609cf1411a.tar.bz2
openshift-52ab71a6f741f2477ab395d48dacfe609cf1411a.tar.xz
openshift-52ab71a6f741f2477ab395d48dacfe609cf1411a.zip
Merge pull request #2667 from smunilla/BZ1385449
Fix race condtion in openshift_facts
-rwxr-xr-xroles/openshift_facts/library/openshift_facts.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py
index 61ce55b7f..1d611f010 100755
--- a/roles/openshift_facts/library/openshift_facts.py
+++ b/roles/openshift_facts/library/openshift_facts.py
@@ -1380,8 +1380,11 @@ def save_local_facts(filename, facts):
"""
try:
fact_dir = os.path.dirname(filename)
- if not os.path.exists(fact_dir):
- os.makedirs(fact_dir)
+ try:
+ os.makedirs(fact_dir) # try to make the directory
+ except OSError as exception:
+ if exception.errno != errno.EEXIST: # but it is okay if it is already there
+ raise # pass any other exceptions up the chain
with open(filename, 'w') as fact_file:
fact_file.write(module.jsonify(facts))
os.chmod(filename, 0o600)