Merge lp:~hazmat/pyjuju/sane-relation-ids into lp:pyjuju
Proposed by
Kapil Thangavelu
Status: | Merged |
---|---|
Merged at revision: | 612 |
Proposed branch: | lp:~hazmat/pyjuju/sane-relation-ids |
Merge into: | lp:pyjuju |
Diff against target: |
206 lines (+44/-21) 4 files modified
juju/hooks/invoker.py (+11/-6) juju/hooks/protocol.py (+4/-2) juju/hooks/tests/test_invoker.py (+17/-13) juju/state/errors.py (+12/-0) |
To merge this branch: | bzr merge lp:~hazmat/pyjuju/sane-relation-ids |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+146033@code.launchpad.net |
Description of the change
Fix relation-ids cache coherency for hooks.
Relation-ids was answering questions about relations
directly from state, whilst other pieces of relation-*
cli was using a hook execution cache. This led to
odd races where a hook would query relation-ids
and then attempt to use relation-list/etc against
that relation resulting in a relation not found error.
This branch also does a drive by to improve the error
reporting for relation not found to include the relation
id where applicable.
To post a comment you must log in.
Reviewers: mp+146033_ code.launchpad. net,
Message:
Please take a look.
Description:
Fix relation-ids cache coherency for hooks.
Relation-ids was answering questions about relations
directly from state, whilst other pieces of relation-*
cli was using a hook execution cache. This led to
odd races where a hook would query relation-ids
and then attempt to use relation-list/etc against
that relation resulting in a relation not found error.
This branch also does a drive by to improve the error
reporting for relation not found to include the relation
id where applicable.
https:/ /code.launchpad .net/~hazmat/ juju/sane- relation- ids/+merge/ 146033
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/7241062/
Affected files: invoker. py protocol. py tests/test_ invoker. py errors. py
A [revision details]
M juju/hooks/
M juju/hooks/
M juju/hooks/
M juju/state/
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/hooks/ invoker. py invoker. py' invoker. py 2013-01-15 19:53:21 +0000 invoker. py 2013-02-01 03:35:02 +0000 python. failure import Failure
=== modified file 'juju/hooks/
--- juju/hooks/
+++ juju/hooks/
@@ -6,7 +6,7 @@
from twisted.
from juju import errors tFound, Identity tFound, Identity
-from juju.state.errors import RelationStateNo
InvalidRelation
+from juju.state.errors import RelationIdentNo
InvalidRelation
from juju.state.hook import RelationHookContext
@@ -172,7 +172,8 @@ relation_ idents( None))) get_relation_ idents( None))) relation_ idents( None))) self._context, RelationHookCon text):
relation_ idents. discard( self._context. relation_ ident)
raise InvalidRelation Identity( relation_ ident) tFound( ) tFound( relation_ ident)
def start(self):
"""Cache relation hook contexts for all relation idents."""
# Get all relation idents (None means "all")
- relation_idents = set((yield self.get_
+ relation_idents = set((yield
self._context.
+ #relation_idents = set((yield self.get_
if isinstance(
# Exclude the parent context for being looked up as a child
@@ -244,10 +245,14 @@
if len(parts) != 2 or not parts[1].isdigit():
else:
- raise RelationStateNo
+ raise RelationIdentNo
+ @inlineCallbacks idents( self, relation_name): get_relation_ idents( relation_ name) get_relation_ idents( relation_ name) idents) .intersection( set(self. _relation_ contexts) )))
def get_relation_
- return self._context.
+ """Returns valid relation instances for the given name."""
+ idents = yield self._context.
+ returnValue(
+ list(set(
def validate_hook(self, hook_filename):
"""Verify that the hook_filename exists and is executable. """
Index: juju/hooks/ protocol. py protocol. py' protocol. py 2012-10-16 23:19:55 +0...
=== modified file 'juju/hooks/
--- juju/hooks/