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

Issue 30390043: state: refactor addmachine.go

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 5 months ago by rog
Modified:
10 years, 5 months ago
Reviewers:
wallyworld, axw, mp+196177, fwereade
Visibility:
Public.

Description

state: refactor addmachine.go The current code had become a twisty maze. This change is intended to make things somewhat more straightforward. The key insight is that there are only four pathways through the code that require different control flow: - adding a top level machine - adding a top level machine with associated instance id - adding a machine within an existing machine - adding a machine within a newly created machine Each of these pathways now has its own function. One pathway was catered for by the old code but is not by the new: adding a machine within a machine with associated instance id. I don't believe that's a case we need to be bothered about (and it's easy to add if we are). For the time being, I have kept the external interface identical, but I'd like to change it to be a little more like the above set of functions, rather than having a single set of AddMachineParams suitable for every case. https://code.launchpad.net/~rogpeppe/juju-core/463-state-ensure-availability/+merge/196177 (do not edit description out of merge proposal)

Patch Set 1 #

Patch Set 2 : state: refactor addmachine.go #

Patch Set 3 : state: refactor addmachine.go #

Total comments: 4

Patch Set 4 : state: refactor addmachine.go #

Total comments: 12

Patch Set 5 : state: refactor addmachine.go #

Unified diffs Side-by-side diffs Delta from patch set Stats (+471 lines, -327 lines) Patch
A [revision details] View 1 2 3 4 1 chunk +2 lines, -0 lines 0 comments Download
M state/addmachine.go View 1 2 3 4 3 chunks +334 lines, -175 lines 0 comments Download
M state/assign_test.go View 2 chunks +3 lines, -0 lines 0 comments Download
M state/container.go View 2 chunks +38 lines, -86 lines 0 comments Download
M state/machine.go View 1 2 3 4 1 chunk +6 lines, -0 lines 0 comments Download
M state/state.go View 1 2 3 4 2 chunks +7 lines, -0 lines 0 comments Download
M state/unit.go View 1 2 3 4 8 chunks +81 lines, -66 lines 0 comments Download

Messages

Total messages: 7
rog
Please take a look.
10 years, 5 months ago (2013-11-21 18:35:16 UTC) #1
rog
Please take a look.
10 years, 5 months ago (2013-11-21 18:39:50 UTC) #2
wallyworld
I like the idea behind the refactoring. My personal view is that there is too ...
10 years, 5 months ago (2013-11-22 06:47:48 UTC) #3
rog
Please take a look. https://codereview.appspot.com/30390043/diff/40001/state/state.go File state/state.go (right): https://codereview.appspot.com/30390043/diff/40001/state/state.go#newcode92 state/state.go:92: logger.Infof("transaction 'after' hook start") On ...
10 years, 5 months ago (2013-11-22 07:59:31 UTC) #4
axw
On 2013/11/22 07:59:31, rog wrote: > Please take a look. LGTM > https://codereview.appspot.com/30390043/diff/40001/state/state.go > File ...
10 years, 5 months ago (2013-11-22 09:04:29 UTC) #5
fwereade
This is awesome, LGTM. Thank you very much. https://codereview.appspot.com/30390043/diff/60001/state/addmachine.go File state/addmachine.go (right): https://codereview.appspot.com/30390043/diff/60001/state/addmachine.go#newcode24 state/addmachine.go:24: // ...
10 years, 5 months ago (2013-11-27 16:13:35 UTC) #6
rog
10 years, 5 months ago (2013-12-03 18:12:13 UTC) #7
Please take a look.

https://codereview.appspot.com/30390043/diff/60001/state/addmachine.go
File state/addmachine.go (right):

https://codereview.appspot.com/30390043/diff/60001/state/addmachine.go#newcode24
state/addmachine.go:24: // an instance for the machine.
On 2013/11/27 16:13:36, fwereade wrote:
> These are the constraints *before* environment fallbacks are applied,right?
> Would be worth mentioning that here.

Done.

https://codereview.appspot.com/30390043/diff/60001/state/addmachine.go#newcode38
state/addmachine.go:38: // be associated with the machine.
On 2013/11/27 16:13:36, fwereade wrote:
> This is only meaningful if InstanceId is set, I think?

Done.

https://codereview.appspot.com/30390043/diff/60001/state/addmachine.go#newcode52
state/addmachine.go:52: Jobs []MachineJob
On 2013/11/27 16:13:36, fwereade wrote:
> I'd move jobs up above the optional parentid/containertype and
> instanceid/nonce/hardware field groups.

Done.

https://codereview.appspot.com/30390043/diff/60001/state/addmachine.go#newcod...
state/addmachine.go:242: // given hardward characteristics.
On 2013/11/27 16:13:36, fwereade wrote:
> s/hardward/hardware/

Done.

https://codereview.appspot.com/30390043/diff/60001/state/addmachine.go#newcod...
state/addmachine.go:243: // The template must contain a valid instance id and
nonce.
On 2013/11/27 16:13:36, fwereade wrote:
> Sucks that we don't require hardware characteristics, but looks like not all
> providers actually return them :/. Would you add a bug for that if it doesn't
> exist, please?

I'm not sure I understand this. Are you saying that we should check that some
minimal subset of h/w characteristics is set?

https://codereview.appspot.com/30390043/diff/60001/state/addmachine.go#newcod...
state/addmachine.go:323: )
On 2013/11/27 16:13:36, fwereade wrote:
> I'd just do `ops := []txn.Op{...}`, but as you like.

can't quite do that, as insertNewMachineOps returns a slice,
which can't go inside the above construct.
(we'd need the equivalent of the lisp ,@ operator :-])
Sign in to reply to this message.

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