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

Issue 6683048: state: aggressive LeaveScope

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 6 months ago by fwereade
Modified:
11 years, 6 months ago
Reviewers:
mp+129584
Visibility:
Public.

Description

state: aggressive LeaveScope The last RelationUnit to leave a Dying scope will now remove the associated relation. https://code.launchpad.net/~fwereade/juju-core/aggressive-leave-scope/+merge/129584 Requires: https://code.launchpad.net/~fwereade/juju-core/service-lifecycles/+merge/129570 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 7

Patch Set 2 : state: aggressive LeaveScope #

Total comments: 11

Patch Set 3 : state: aggressive LeaveScope #

Unified diffs Side-by-side diffs Delta from patch set Stats (+153 lines, -59 lines) Patch
A [revision details] View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M state/relation.go View 1 2 3 chunks +99 lines, -23 lines 0 comments Download
M state/relation_test.go View 1 2 5 chunks +42 lines, -11 lines 0 comments Download
M state/state.go View 1 2 1 chunk +10 lines, -25 lines 0 comments Download

Messages

Total messages: 7
fwereade
Please take a look.
11 years, 6 months ago (2012-10-14 08:59:46 UTC) #1
niemeyer
A few comments.. we'd probably benefit from some live chat on this: https://codereview.appspot.com/6683048/diff/1/state/life.go File state/life.go ...
11 years, 6 months ago (2012-10-15 20:38:46 UTC) #2
niemeyer
A few comments.. we'd probably benefit from some live chat on this: https://codereview.appspot.com/6683048/diff/1/state/life.go File state/life.go ...
11 years, 6 months ago (2012-10-15 20:38:46 UTC) #3
fwereade
https://codereview.appspot.com/6683048/diff/1/state/life.go File state/life.go (right): https://codereview.appspot.com/6683048/diff/1/state/life.go#newcode73 state/life.go:73: decorate := func(err error) error { On 2012/10/15 20:38:46, ...
11 years, 6 months ago (2012-10-15 21:20:02 UTC) #4
fwereade
Please take a look. https://codereview.appspot.com/6683048/diff/1/state/life.go File state/life.go (right): https://codereview.appspot.com/6683048/diff/1/state/life.go#newcode73 state/life.go:73: decorate := func(err error) error ...
11 years, 6 months ago (2012-10-16 23:15:45 UTC) #5
niemeyer
LGTM https://codereview.appspot.com/6683048/diff/9001/state/relation.go File state/relation.go (right): https://codereview.appspot.com/6683048/diff/9001/state/relation.go#newcode158 state/relation.go:158: func (r *Relation) removeOps(asserts D) []txn.Op { Nice ...
11 years, 6 months ago (2012-10-17 01:36:15 UTC) #6
fwereade
11 years, 6 months ago (2012-10-18 14:41:21 UTC) #7
*** Submitted:

state: aggressive LeaveScope

The last RelationUnit to leave a Dying scope will now remove the associated
relation.

R=niemeyer
CC=
https://codereview.appspot.com/6683048

https://codereview.appspot.com/6683048/diff/9001/state/relation.go
File state/relation.go (right):

https://codereview.appspot.com/6683048/diff/9001/state/relation.go#newcode351
state/relation.go:351: // than we can resolve.
On 2012/10/17 01:36:15, niemeyer wrote:
> Logic looks great, but the comment feels a bit hard to understand. Here is a
> suggestion for a more prosaic version:
> 
> // The logic below is involved because we remove a dying relation
> // with the last unit that leaves a scope in it. It handles three
> // possible cases:
> //
> // 1. Relation is alive: just leave the scope.
> //
> // 2. Relation is dying, and other units remain: just leave the scope.
> //
> // 3. Relation is dying, and this is the last unit: leave the scope
> //    and remove the relation.
> //
> // In each of those cases, proper assertions are done to guarantee
> // that the condition observed is still valid when the transaction is
> // applied. If an abort happens, it observes the new condition and
> // retries. In theory, a worst case will try at most all of the
> // conditions once, because units cannot join a scope once its relation
> // is dying.
> //
> // Keep in mind that in the first iteration of the loop it's possible
> // to have a Dying relation with a smaller-than-real unit count, because
> // EnsureDying changes the Life attribute in memory (units could join
> // before the database is actually changed).

Excellent-- took it verbatim. Thanks :).

https://codereview.appspot.com/6683048/diff/9001/state/relation.go#newcode353
state/relation.go:353: for i := 0; i <= limit; i++ {
On 2012/10/17 01:36:15, niemeyer wrote:
> 
> What do you think of:
> 
> for attempt := 0; attempt < 3; attempt++ {

Done.

https://codereview.appspot.com/6683048/diff/9001/state/relation.go#newcode360
state/relation.go:360: return fmt.Errorf("unit %q cannot leave relation %q
scope: inconsistent state", ru.unit, ru.relation)
On 2012/10/17 01:36:15, niemeyer wrote:
> This can be moved to after the for loop in place of the unreachable panic, and
> the loop condition changed to <.

Done.

https://codereview.appspot.com/6683048/diff/9001/state/relation.go#newcode395
state/relation.go:395: }
On 2012/10/17 01:36:15, niemeyer wrote:
> This is the same as:
> 
>     if err = ru.st.runner.Run(ops, "", nil); err != txn.ErrAborted {
>         return err
>     }
>     if err := ru.relation.Refresh(); IsNotFound(err) {
>         return nil
>     } else if err != nil {
>         return err
>     }
> }

Done, but wrapped the mgo error when not nil.
Sign in to reply to this message.

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