Merge lp://staging/~fwereade/pyjuju/always-break-broken-relations into lp://staging/pyjuju
Proposed by
William Reade
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Kapil Thangavelu | ||||
Approved revision: | 442 | ||||
Merged at revision: | 450 | ||||
Proposed branch: | lp://staging/~fwereade/pyjuju/always-break-broken-relations | ||||
Merge into: | lp://staging/pyjuju | ||||
Prerequisite: | lp://staging/~fwereade/pyjuju/restrict-relation-broken-context | ||||
Diff against target: |
651 lines (+266/-148) 6 files modified
juju/agents/unit.py (+10/-13) juju/control/tests/test_resolved.py (+2/-1) juju/unit/lifecycle.py (+144/-78) juju/unit/tests/test_lifecycle.py (+58/-22) juju/unit/tests/test_workflow.py (+47/-32) juju/unit/workflow.py (+5/-2) |
||||
To merge this branch: | bzr merge lp://staging/~fwereade/pyjuju/always-break-broken-relations | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Kapil Thangavelu (community) | Approve | ||
Jim Baker (community) | Approve | ||
Review via email: mp+85268@code.staging.launchpad.net |
Description of the change
Part 2 extracted from the horrifyingly overgrown restart-transitions branch:
UnitLifecycle now (effectively) persists the current RelationWorkflo
To post a comment you must log in.
[0]
Relative offset path usage into a (grand)parent aren't kosher. Child
usage is, or pass the path in. Also the state directory isn't
namespaced, so usage needs qualification among multiple units.
+ self._state_ dir_path = os.path.abspath( join(unit_ path, "../../state"))
+ os.path.
[1]
+ # Before we get into serially executing all the relation-broken
+ # hooks, stop all the lifecycles, to minimise the chances of them
+ # running redundant hooks between now and the point at which their
+ # own relation-departed hook is fired.
+ # If they do run redundant hooks, nothing *bad* should happen, but
+ # it's a potentially significant waste of time.
This manages to not capture the key part from the original
documentation on why this is code is structured the way it is.
Namely, concurrent events for subsequent watch firings should not
be executed post rel break watch firing and stopping.
[2]
+ # Actually depart relations, one by one; waiting time should be
+ # minimal thanks to the loop above.
That's not true, executing a stop hook is arbitrary time.
[3] _load/store_ relations could use doc strings. at minimum noting storage of presence not state of relations.
[4]
+ state = yaml.dump(dict( service_ id, workflow. relation_ name)) .items( )))
+ (relation_id, (workflow.
+ for (relation_id, workflow) in self._relations
- # changes relation delta of global zk state with our memory state. service_ relation. internal_ relation_ id, relation. internal_ relation_ id, service_relation)
- new_relations = dict([(
- service_relation) for
- service_relation in new_relations])
+ # Calculate delta between zookeeper state and our stored state.
+ new_relations = dict(
+ (service_
+ for service_relation in new_relations)
py2.7 specific, i'd like to retain compatibility for 2.6 (lucid).
[6]
(relation_id, (workflow. service_ id, workflow. relation_ name))
Storing service id is superflous, its in the context of a unit, which
always knows its service.
[7] wState
nitpick test_lifecycle, unused
from juju.unit.workflow import RelationWorkflo
[8] untested bits
! lifecycle- >_load_ relations
self. _relations[ relation_ id] = workflow
lifecycle- >execute_ change_ hook
hook_ names = [hook_name]
else: