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

Issue 6820112: firewaller: use new style machine units watcher

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 5 months ago by aram
Modified:
11 years, 4 months ago
Reviewers:
mp+133269, dave, niemeyer, fwereade, rog
Visibility:
Public.

Description

firewaller: use new style machine units watcher https://code.launchpad.net/~aramh/juju-core/120-firewaller-new-watcher-units7/+merge/133269 (do not edit description out of merge proposal)

Patch Set 1 #

Patch Set 2 : firewaller: use new style machine units watcher #

Total comments: 22

Patch Set 3 : firewaller: use new style machine units watcher #

Total comments: 22
Unified diffs Side-by-side diffs Delta from patch set Stats (+90 lines, -48 lines) Patch
A [revision details] View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M state/assign_test.go View 1 2 4 chunks +5 lines, -5 lines 0 comments Download
M state/unit.go View 1 2 1 chunk +24 lines, -4 lines 3 comments Download
M worker/firewaller/firewaller.go View 1 2 4 chunks +58 lines, -39 lines 17 comments Download
M worker/firewaller/firewaller_test.go View 1 2 1 chunk +1 line, -0 lines 2 comments Download

Messages

Total messages: 9
aram
Please take a look.
11 years, 5 months ago (2012-11-08 15:58:55 UTC) #1
dave_cheney.net
I don't think i can lgtm as I don't know enough about the watchers, but ...
11 years, 5 months ago (2012-11-09 00:31:35 UTC) #2
rog
I'm not sure about some of the logic here. Concerns outlined below. https://codereview.appspot.com/6820112/diff/1003/worker/firewaller/firewaller.go File worker/firewaller/firewaller.go ...
11 years, 5 months ago (2012-11-09 10:16:05 UTC) #3
aram
https://codereview.appspot.com/6820112/diff/1003/worker/firewaller/firewaller.go File worker/firewaller/firewaller.go (right): https://codereview.appspot.com/6820112/diff/1003/worker/firewaller/firewaller.go#newcode109 worker/firewaller/firewaller.go:109: changed := []*unitData{} I like yours better, but currently ...
11 years, 5 months ago (2012-11-09 15:52:41 UTC) #4
aram
Please take a look.
11 years, 5 months ago (2012-11-09 15:52:59 UTC) #5
aram
https://codereview.appspot.com/6820112/diff/1005/state/unit.go File state/unit.go (right): https://codereview.appspot.com/6820112/diff/1005/state/unit.go#newcode417 state/unit.go:417: return &NotFoundError{fmt.Sprintf(format+" is not assigned to a machine", args...)} ...
11 years, 5 months ago (2012-11-09 16:16:49 UTC) #6
fwereade
LGTM assuming no disagreement below (I think it should be `unit.Life() == state.Dead`). https://codereview.appspot.com/6820112/diff/1005/worker/firewaller/firewaller.go File ...
11 years, 5 months ago (2012-11-13 16:19:32 UTC) #7
niemeyer
NOT LGTM until these are addressed: https://codereview.appspot.com/6820112/diff/1003/worker/firewaller/firewaller.go File worker/firewaller/firewaller.go (right): https://codereview.appspot.com/6820112/diff/1003/worker/firewaller/firewaller.go#newcode109 worker/firewaller/firewaller.go:109: changed := []*unitData{} ...
11 years, 5 months ago (2012-11-14 18:40:33 UTC) #8
fwereade
11 years, 4 months ago (2012-11-30 12:46:31 UTC) #9
Addressed in new branch: lp:~fwereade/juju-core/aramh-firewaller-changes

https://codereview.appspot.com/6820112/diff/1005/state/unit.go
File state/unit.go (right):

https://codereview.appspot.com/6820112/diff/1005/state/unit.go#newcode423
state/unit.go:423: }
On 2012/11/14 18:40:33, niemeyer wrote:
> Please replace all of the logic above by this:
> 
> type NotAssignedError struct {
>     Unit *Unit
> }
> 
> func (e *NotAssignedError) Error() string {
>     return fmt.Errorf("unit %q is not assigned to a machine", e.Unit)
> }

Done.

https://codereview.appspot.com/6820112/diff/1005/worker/firewaller/firewaller.go
File worker/firewaller/firewaller.go (right):

https://codereview.appspot.com/6820112/diff/1005/worker/firewaller/firewaller...
worker/firewaller/firewaller.go:116: var unassigned bool
On 2012/11/14 18:40:33, niemeyer wrote:
> machineId := -1
> 
> Please drop unassigned. These two variables overlap in meaning, and the logic
> below is a lot more confusing because one has to keep in mind that machineId
> zero is actually not necessarily real.

Done.

https://codereview.appspot.com/6820112/diff/1005/worker/firewaller/firewaller...
worker/firewaller/firewaller.go:125: unassigned = state.IsNotAssigned(err)
On 2012/11/14 18:40:33, niemeyer wrote:
> id, err := unit.AssignedMachineId()
> if <not found check> {
>     continue
> } else if err == nil {
>     machineId = id
> } else {
>     return err
> }

Done.

https://codereview.appspot.com/6820112/diff/1005/worker/firewaller/firewaller...
worker/firewaller/firewaller.go:129: if unit == nil || unit.Life() !=
state.Alive || unassigned || machineId != knownMachineId {
On 2012/11/14 18:40:33, niemeyer wrote:
> On 2012/11/13 16:19:32, fwereade wrote:
> > Why the Alive check? A unit can still open/close ports when it's Dying, and
I
> > think those should be honoured... a unit can take a long time to die, and it
> > should keep working until it does :).
> 
> +1
> 
> Also, || knownMachineId != machineId {

Done.

https://codereview.appspot.com/6820112/diff/1005/worker/firewaller/firewaller...
worker/firewaller/firewaller.go:134: } else if unit != nil && unit.Life() ==
state.Alive {
On 2012/11/14 18:40:33, niemeyer wrote:
> See William's comment above.

Done.

https://codereview.appspot.com/6820112/diff/1005/worker/firewaller/firewaller...
worker/firewaller/firewaller.go:136: fw.unitds[unit.Name()] = unitd
On 2012/11/14 18:40:33, niemeyer wrote:
> We have "name" in scope, here and below.

Done.

https://codereview.appspot.com/6820112/diff/1005/worker/firewaller/firewaller...
worker/firewaller/firewaller.go:137: if fw.machineds[machineId] == nil ||
unassigned {
On 2012/11/14 18:40:33, niemeyer wrote:
> Please avoid using variables unless they are initialized. It doesn't matter
what
> the settings for machine id zero are if this is not machine zero.

Done.

https://codereview.appspot.com/6820112/diff/1005/worker/firewaller/firewaller...
worker/firewaller/firewaller.go:141: unitd.machined.unitds[unit.Name()] = unitd
On 2012/11/14 18:40:33, niemeyer wrote:
> serviceName := unit.ServiceName()
> 
> There are 4 calls to this in the next ~10 lines. We can as well keep it
around.

Done.

https://codereview.appspot.com/6820112/diff/1005/worker/firewaller/firewaller...
worker/firewaller/firewaller.go:142: if fw.serviceds[unit.ServiceName()] == nil
{
On 2012/11/14 18:40:33, niemeyer wrote:
> unitd.serviced = fw.serviceds[serviceName]
> if unitd.serviced == nil {
>     ...
> }

I don't think this makes anything clearer or more readable... would you explain
please?

https://codereview.appspot.com/6820112/diff/1005/worker/firewaller/firewaller...
File worker/firewaller/firewaller_test.go (right):

https://codereview.appspot.com/6820112/diff/1005/worker/firewaller/firewaller...
worker/firewaller/firewaller_test.go:663: c.Skip("disabled until firewaller
initialization is fixed")
On 2012/11/14 18:40:33, niemeyer wrote:
> Why is it broken? The comment should have a bug # so we don't have to second
> guess.

Done; it was a MachineUnitsWatcher bug.
Sign in to reply to this message.

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