Merge lp:~hazmat/pyjuju/var-run-mass-restart into lp:pyjuju
Proposed by
Kapil Thangavelu
Status: | Merged |
---|---|
Merged at revision: | 621 |
Proposed branch: | lp:~hazmat/pyjuju/var-run-mass-restart |
Merge into: | lp:pyjuju |
Diff against target: |
19 lines (+7/-1) 1 file modified
juju/agents/base.py (+7/-1) |
To merge this branch: | bzr merge lp:~hazmat/pyjuju/var-run-mass-restart |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+158980@code.launchpad.net |
Description of the change
Agents play nice on run dir race.
Previously a reboot of several agents could cause a race around
the creation of the /var/run/juju dir, even with an existence check,
instead just try/except and handle win or lose the race.
To post a comment you must log in.
Reviewers: mp+158980_ code.launchpad. net,
Message:
Please take a look.
Description:
Agents play nice on run dir race.
Previously a reboot of several agents could cause a race around
the creation of the /var/run/juju dir, even with an existence check,
instead just try/except and handle win or lose the race.
https:/ /code.launchpad .net/~hazmat/ juju/var- run-mass- restart/ +merge/ 158980
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/8583048/
Affected files:
A [revision details]
M juju/agents/base.py
Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>
Index: juju/agents/base.py base.py'
=== modified file 'juju/agents/
--- juju/agents/base.py 2013-02-01 16:53:27 +0000
+++ juju/agents/base.py 2013-04-15 17:20:47 +0000
@@ -32,8 +32,14 @@
def save_client_ id(path, client_id): dirname( path) exists( parent) :
os.makedirs( parent)
f.write( yaml.dump( client_ id)) chmod(path, stat.S_IRUSR | stat.S_IWUSR)
parent = os.path.
- if not os.path.
+ # 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:
+ except OSError, e:
+ if e.errno != 17:
+ raise
with open(path, "w") as f:
os.