https://codereview.appspot.com/6814108/diff/2001/state/watcher.go#newcode1259
state/watcher.go:1259: type MachinePrincipalUnitsWatcher struct {
> please can we put code block moves in their own CL? i don't
> disagree on principle (it is indeed better next to the
> MachineUnitsWatcher) but it means we can't easily see the diffs.
Sorry, no, it was intentional. This is 100% new code, it's not
a variation of the old code. It's a variation of the current
MachineUnitsWatcher code.
I wish we had, but niemeyer rules against it in one of the Lisbon
sprints, didn't he?
https://codereview.appspot.com/6814108/diff/2001/state/watcher.go#newcode1293
state/watcher.go:1293: func (w *MachinePrincipalUnitsWatcher)
updateMachine(pending []string) (new []string, err error) {
> i found the name "pending" slightly confusing here. how about using
"changed"
> and "newChanged" throughout (replacing "pending" and "new")? then the
> relationship between updateMachine, merge and the main loop becomes
clearer, i
> think.
I agree, but what about the MachineUnitsWatcher? This code is a proper
subset of that. If we change anything here, we should change it
everywhere.
Also, I don't want to change anything in this watcher, and the machine
units watcher. The implementation will change completely in a few days
once we have containers inside state.
https://codereview.appspot.com/6814108/diff/2001/worker/machiner/machiner.go#newcode78
worker/machiner/machiner.go:78: if err := m.localContainer.Deploy(u,
m.stateInfo, m.tools); err != nil {
On 2012/11/09 09:08:08, rog wrote:
> i'm not sure this is quite right. if the unit's life state changes
from Alive to
> Dying, the unit will still appear to be assigned to the machine, and
we're going
> to call Deploy again, even though the unit is already in the units
map.
> i think we should check that the unit is not in the units map before
calling
> Deploy.
https://codereview.appspot.com/6814108/diff/2001/worker/machiner/machiner_test.go#newcode76
worker/machiner/machiner_test.go:76: tests := []struct {
On 2012/11/09 09:08:08, rog wrote:
> we need some tests that check what happens when lifecycle changes
happen here. i
> suggest adding the tests before changing the code to verify that
current
> behaviour is actually broken.
Please take a look.
https:/ /codereview. appspot. com/6814108/ diff/2001/ cmd/jujud/ machine. go machine. go (right):
File cmd/jujud/
https:/ /codereview. appspot. com/6814108/ diff/2001/ cmd/jujud/ machine. go#newcode107 machine. go:107: t = machiner. NewMachiner( m, st,
cmd/jujud/
&a.Conf.StateInfo, a.Conf.DataDir)
> i think st should probably be the first argument here, so the workers
are
> consistent in that respect.
I agree. Done.
https:/ /codereview. appspot. com/6814108/ diff/2001/ state/machine_ test.go test.go (right):
File state/machine_
https:/ /codereview. appspot. com/6814108/ diff/2001/ state/machine_ test.go# newcode763 test.go: 763: var machinePrincipa lsWatchTests = []struct {
state/machine_
On 2012/11/09 09:08:08, rog wrote:
> can we please leave this in the same place, please, so i can easily
see what has
> remained the same?
Done.
https:/ /codereview. appspot. com/6814108/ diff/2001/ state/machine_ test.go# newcode771 test.go: 771: []string(nil),
state/machine_
On 2012/11/09 09:08:08, rog wrote:
> just nil?
No, DeepEquals fails with just nil.
https:/ /codereview. appspot. com/6814108/ diff/2001/ state/unit. go
File state/unit.go (right):
https:/ /codereview. appspot. com/6814108/ diff/2001/ state/unit. go#newcode409
state/unit.go:409: func (u *Unit) IsAssignedTo(m *Machine) bool {
On 2012/11/09 09:08:08, rog wrote:
> is this necessary? can't we just use AssignedMachineId instead?
It was impossible to use the previous version of AssignedMachineId, but
I fixed that function instead to return usable errors and I deleted
this.
https:/ /codereview. appspot. com/6814108/ diff/2001/ state/watcher. go
File state/watcher.go (right):
https:/ /codereview. appspot. com/6814108/ diff/2001/ state/watcher. go#newcode1259 go:1259: type MachinePrincipa lUnitsWatcher struct { cher) but it means we can't easily see the diffs.
state/watcher.
> please can we put code block moves in their own CL? i don't
> disagree on principle (it is indeed better next to the
> MachineUnitsWat
Sorry, no, it was intentional. This is 100% new code, it's not
a variation of the old code. It's a variation of the current
MachineUnitsWatcher code.
https:/ /codereview. appspot. com/6814108/ diff/2001/ state/watcher. go#newcode1278 go:1278: machine: &Machine{m.st, m.doc}, // Copy so
state/watcher.
it may be freely refreshed
> i wonder if we should have a Clone or Copy method on Machine, Unit,
etc.
I wish we had, but niemeyer rules against it in one of the Lisbon
sprints, didn't he?
https:/ /codereview. appspot. com/6814108/ diff/2001/ state/watcher. go#newcode1293 go:1293: func (w *MachinePrincip alUnitsWatcher) pending []string) (new []string, err error) {
state/watcher.
updateMachine(
> i found the name "pending" slightly confusing here. how about using
"changed"
> and "newChanged" throughout (replacing "pending" and "new")? then the
> relationship between updateMachine, merge and the main loop becomes
clearer, i
> think.
I agree, but what about the MachineUnitsWat cher? This code is a proper
subset of that. If we change anything here, we should change it
everywhere.
https:/ /codereview. appspot. com/6814108/ diff/2001/ state/watcher. go#newcode1310 go:1310: doc := unitDoc{}
state/watcher.
On 2012/11/09 09:08:08, rog wrote:
> could we just use w.st.Unit(unit) here? then the logic below could
just use the
> normal Unit methods (e.g. IsPrincipal, AssignedMachineId).
I don't know, but see above.
https:/ /codereview. appspot. com/6814108/ diff/2001/ state/watcher. go#newcode1344 go:1344: w.st.watcher. Watch(w. st.machines. Name, doc.TxnRevno, machineCh)
state/watcher.
w.machine.doc.Id, w.machine.
On 2012/11/09 09:08:08, rog wrote:
> could we just use MachineWatcher here?
See above.
Also, I don't want to change anything in this watcher, and the machine
units watcher. The implementation will change completely in a few days
once we have containers inside state.
https:/ /codereview. appspot. com/6814108/ diff/2001/ state/watcher. go#newcode1346 go:1346: changes, err := w.updateMachine ([]string( nil)) nil)/nil/
state/watcher.
> s/[]string(
No, clients really expect []string(nil). Perhaps we should fix teh
clients but that's outside of the scope of this CL.
https:/ /codereview. appspot. com/6814108/ diff/2001/ worker/ machiner/ machiner. go machiner/ machiner. go (right):
File worker/
https:/ /codereview. appspot. com/6814108/ diff/2001/ worker/ machiner/ machiner. go#newcode27 machiner/ machiner. go:27: func NewMachiner(machine *state.Machine,
worker/
st *state.State, info *state.Info, dataDir string) *Machiner {
On 2012/11/09 09:08:08, rog wrote:
> make st the first arg.
Done.
https:/ /codereview. appspot. com/6814108/ diff/2001/ worker/ machiner/ machiner. go#newcode32 machiner/ machiner. go:32: func newMachiner(machine *state.Machine, Container) *Machiner {
worker/
st *state.State, info *state.Info, dataDir string, cont
container.
On 2012/11/09 09:08:08, rog wrote:
> ditto.
Done.
https:/ /codereview. appspot. com/6814108/ diff/2001/ worker/ machiner/ machiner. go#newcode67 machiner/ machiner. go:67: var assigned bool
worker/
On 2012/11/09 09:08:08, rog wrote:
> assigned := false ?
Done.
https:/ /codereview. appspot. com/6814108/ diff/2001/ worker/ machiner/ machiner. go#newcode78 machiner/ machiner. go:78: if err := m.localContaine r.Deploy( u,
worker/
m.stateInfo, m.tools); err != nil {
On 2012/11/09 09:08:08, rog wrote:
> i'm not sure this is quite right. if the unit's life state changes
from Alive to
> Dying, the unit will still appear to be assigned to the machine, and
we're going
> to call Deploy again, even though the unit is already in the units
map.
> i think we should check that the unit is not in the units map before
calling
> Deploy.
Done.
https:/ /codereview. appspot. com/6814108/ diff/2001/ worker/ machiner/ machiner_ test.go machiner/ machiner_ test.go (right):
File worker/
https:/ /codereview. appspot. com/6814108/ diff/2001/ worker/ machiner/ machiner_ test.go# newcode76 machiner/ machiner_ test.go: 76: tests := []struct {
worker/
On 2012/11/09 09:08:08, rog wrote:
> we need some tests that check what happens when lifecycle changes
happen here. i
> suggest adding the tests before changing the code to verify that
current
> behaviour is actually broken.
Done.
https:/ /codereview. appspot. com/6814108/