Index: juju/agents/base.py |
=== modified file 'juju/agents/base.py' |
--- juju/agents/base.py 2013-02-01 16:53:27 +0000 |
+++ juju/agents/base.py 2013-04-15 21:48:46 +0000 |
@@ -1,4 +1,5 @@ |
import argparse |
+import errno |
import os |
import logging |
import stat |
@@ -32,8 +33,14 @@ |
def save_client_id(path, client_id): |
parent = os.path.dirname(path) |
- if not os.path.exists(parent): |
+ # On reboot the run dir is wiped, with multiple agents |
+ # we get a race trying to create the directory, hence try/except |
+ # instead of checking to see if dir exists first. |
+ try: |
os.makedirs(parent) |
+ except OSError, e: |
+ if e.errno != errno.EEXIST: |
+ raise |
with open(path, "w") as f: |
f.write(yaml.dump(client_id)) |
os.chmod(path, stat.S_IRUSR | stat.S_IWUSR) |