Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(345)

Unified Diff: juju/agents/base.py

Issue 8583048: Agents play nice on run dir race.
Patch Set: Agents play nice on run dir race. Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « [revision details] ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « [revision details] ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b