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

Issue 9084045: state: SetCharm checks rel/endpoint compatibility (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years ago by dimitern
Modified:
11 years ago
Reviewers:
mp+162116
Visibility:
Public.

Description

state: SetCharm checks rel/endpoint compatibility This closes the loop around charm upgrades: now you cannot upgrade to a charm without compatible endpoints or relations. It also fixes bug #1032557. https://code.launchpad.net/~dimitern/juju-core/039-upgrade-charm-relations/+merge/162116 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 10

Patch Set 2 : state: SetCharm checks rel/endpoint compatibility #

Total comments: 12

Patch Set 3 : state: SetCharm checks rel/endpoint compatibility #

Total comments: 10

Patch Set 4 : state: SetCharm checks rel/endpoint compatibility #

Unified diffs Side-by-side diffs Delta from patch set Stats (+180 lines, -10 lines) Patch
A [revision details] View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download
M state/service.go View 1 2 3 3 chunks +34 lines, -3 lines 0 comments Download
M state/service_test.go View 1 3 chunks +144 lines, -7 lines 0 comments Download

Messages

Total messages: 11
dimitern
Please take a look.
11 years ago (2013-05-02 15:30:09 UTC) #1
fwereade
Wrong endpoints, I'm afraid -- we don't want to prevent changes that don't actively break ...
11 years ago (2013-05-02 15:44:32 UTC) #2
dimitern
Please take a look. https://codereview.appspot.com/9084045/diff/1/state/service.go File state/service.go (right): https://codereview.appspot.com/9084045/diff/1/state/service.go#newcode370 state/service.go:370: asserts := []txn.Op{{ On 2013/05/02 ...
11 years ago (2013-05-02 17:08:53 UTC) #3
rog
LGTM with only one substantive question. https://codereview.appspot.com/9084045/diff/5001/state/service.go File state/service.go (right): https://codereview.appspot.com/9084045/diff/5001/state/service.go#newcode361 state/service.go:361: var asserts []txn.Op ...
11 years ago (2013-05-02 17:19:48 UTC) #4
dimitern
Please take a look. https://codereview.appspot.com/9084045/diff/5001/state/service.go File state/service.go (right): https://codereview.appspot.com/9084045/diff/5001/state/service.go#newcode361 state/service.go:361: var asserts []txn.Op On 2013/05/02 ...
11 years ago (2013-05-02 17:44:57 UTC) #5
rog
https://codereview.appspot.com/9084045/diff/5001/state/service.go File state/service.go (right): https://codereview.appspot.com/9084045/diff/5001/state/service.go#newcode444 state/service.go:444: if len(relations) != s.doc.RelationCount { On 2013/05/02 17:44:58, dimitern ...
11 years ago (2013-05-02 18:05:58 UTC) #6
dimitern
Sorry, that wasn't a complete description perhaps, let me try again: https://codereview.appspot.com/9084045/diff/5001/state/service.go File state/service.go (right): ...
11 years ago (2013-05-02 18:28:46 UTC) #7
rog
https://codereview.appspot.com/9084045/diff/5001/state/service.go File state/service.go (right): https://codereview.appspot.com/9084045/diff/5001/state/service.go#newcode444 state/service.go:444: if len(relations) != s.doc.RelationCount { On 2013/05/02 18:28:46, dimitern ...
11 years ago (2013-05-03 07:35:11 UTC) #8
dimitern
https://codereview.appspot.com/9084045/diff/5001/state/service.go File state/service.go (right): https://codereview.appspot.com/9084045/diff/5001/state/service.go#newcode444 state/service.go:444: if len(relations) != s.doc.RelationCount { On 2013/05/03 07:35:11, rog ...
11 years ago (2013-05-03 09:50:49 UTC) #9
fwereade
LGTM given a quick chat online for confirmation https://codereview.appspot.com/9084045/diff/9001/state/service.go File state/service.go (right): https://codereview.appspot.com/9084045/diff/9001/state/service.go#newcode367 state/service.go:367: return ...
11 years ago (2013-05-03 10:13:18 UTC) #10
dimitern
11 years ago (2013-05-03 10:34:44 UTC) #11
*** Submitted:

state: SetCharm checks rel/endpoint compatibility

This closes the loop around charm upgrades:
now you cannot upgrade to a charm without
compatible endpoints or relations.

It also fixes bug #1032557.

R=fwereade, rog
CC=
https://codereview.appspot.com/9084045

https://codereview.appspot.com/9084045/diff/9001/state/service.go
File state/service.go (right):

https://codereview.appspot.com/9084045/diff/9001/state/service.go#newcode367
state/service.go:367: return nil, fmt.Errorf("cannot upgrade service %q to charm
%q: would break relation %q", s.doc.Name, ch, rel)
On 2013/05/03 10:13:18, fwereade wrote:
> fwiw you could just have s instead of s.doc.Name, I'm pretty sure it has a
> sensible String() method.

Done.

https://codereview.appspot.com/9084045/diff/9001/state/service.go#newcode375
state/service.go:375: return asserts, nil
On 2013/05/03 10:13:18, fwereade wrote:
> Just a thought -- maybe you could construct sameRelCount in here and return
it?
> Not sure though... if you think it's stupid, don't bother.

I think it's more logical to do that in changeCharmOps anyway, since that's
where we get the relations and construct the services collection operation.

https://codereview.appspot.com/9084045/diff/9001/state/service.go#newcode449
state/service.go:449: sameRelCount := D{{"relationcount", s.doc.RelationCount}}
On 2013/05/03 10:13:18, fwereade wrote:
> I think we discussed last night that we don't care about the current value of
> s.doc.RelationCount -- we can skip the length check, and just assert that the
> execution-time value is the same as the value we'd expect from having seen N
> relations.
> 
> So I think the above can just be:
> 
> relations, err := s.Relations()
> if err != nil {
>     return nil, err
> }
> sameRelCount := D{{"relationcount", len(relations)}}
> 
> ...and then there's no need for the errRefresh handling.

Done.

https://codereview.appspot.com/9084045/diff/9001/state/service.go#newcode456
state/service.go:456: Assert: sameRelCount, // txn.DocExists is implicit and
cannot be combined with another assert
On 2013/05/03 10:13:18, fwereade wrote:
> Hmm. I think we should have a check that it's alive... I don't think there's
any
> point upgrading a dying service, and the aborted check in SetCharm implies
that
> we service death is a reason to abort. Sorry about the DocExists, it was
almost
> certainly my bug.

Added isAliveDoc + sameRelCount as asserts.

https://codereview.appspot.com/9084045/diff/9001/state/service.go#newcode504
state/service.go:504: }
On 2013/05/03 10:13:18, fwereade wrote:
> Without errRefresh, I think we can revert this whole block.

Done.
Sign in to reply to this message.

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