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

Issue 83070047: state: Add machine networks and interfaces (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 1 month ago by dimitern
Modified:
10 years, 1 month ago
Reviewers:
mp+213796, fwereade
Visibility:
Public.

Description

state: Add machine networks and interfaces Added a couple of entities (and related methods) in state: * Network - holds a name, CIDR and VLAN tag; used to describe actual configured networks that machines need to be on. * NetworkInterface - linked to a machine id and network name, holds the network interface name to MAC address mapping in state (MAC address as key for uniqueness); machines support adding one or more NICs. Renamed machine.Network() and st.networks to RequestedNetworks() and st.requestedNetworks (in code only, schema remains the same). This helps avoid confusion between the requested networks (to include/exclude on a machine, coming from the service; they are now called "requested networks"), and actually configured networks on a running machine (just "networks"). For now networks are immutable, can't be removed and NICs can be added to them only if their machine is not provisioned yet. NICs are only removed when the machine itself is removed. Provisioner API change: renamed Networks() to RequestedNetworks() which is fine, because Networks() was added recently and not released yet. We'll use the added machine NICs to show enabled networks in juju status later on, and they will be set at StartInstance() time inside the provisioner. Internally, MaaS provider changes will be needed to get NIC-to-MAC mapping for an acquired node and the list of networks for it. https://code.launchpad.net/~dimitern/juju-core/381-state-machine-nics/+merge/213796 Requires: https://code.launchpad.net/~dimitern/juju-core/380-provisioner-honors-networks/+merge/213647 (do not edit description out of merge proposal)

Patch Set 1 #

Patch Set 2 : state: Add machine.(Set)NetworkInterfaces #

Total comments: 2

Patch Set 3 : state: Add machine networks and interfaces #

Total comments: 48

Patch Set 4 : state: Add machine networks and interfaces #

Total comments: 16

Patch Set 5 : state: Add machine networks and interfaces #

Total comments: 2

Patch Set 6 : state: Add machine networks and interfaces #

Patch Set 7 : state: Add machine networks and interfaces #

Unified diffs Side-by-side diffs Delta from patch set Stats (+691 lines, -130 lines) Patch
A [revision details] View 1 2 3 4 5 6 1 chunk +2 lines, -0 lines 0 comments Download
M juju/conn_test.go View 1 2 3 3 chunks +7 lines, -7 lines 0 comments Download
M state/addmachine.go View 1 2 3 4 5 1 chunk +5 lines, -1 line 0 comments Download
M state/api/provisioner/machine.go View 1 2 3 1 chunk +4 lines, -4 lines 0 comments Download
M state/api/provisioner/provisioner_test.go View 1 2 3 2 chunks +2 lines, -2 lines 0 comments Download
M state/apiserver/provisioner/provisioner.go View 1 2 3 2 chunks +3 lines, -3 lines 0 comments Download
M state/apiserver/provisioner/provisioner_test.go View 1 2 3 2 chunks +2 lines, -2 lines 0 comments Download
M state/assign_test.go View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M state/cleanup.go View 1 2 3 2 chunks +0 lines, -13 lines 0 comments Download
M state/compat_test.go View 1 2 3 4 2 chunks +8 lines, -8 lines 0 comments Download
M state/machine.go View 1 2 3 4 5 6 4 chunks +133 lines, -7 lines 0 comments Download
M state/machine_test.go View 1 2 3 4 5 chunks +144 lines, -6 lines 0 comments Download
A state/networkinterfaces.go View 1 2 3 4 1 chunk +45 lines, -0 lines 0 comments Download
A state/networkinterfaces_test.go View 1 2 3 1 chunk +37 lines, -0 lines 0 comments Download
A state/networks.go View 1 2 3 1 chunk +68 lines, -0 lines 0 comments Download
A state/networks_test.go View 1 2 3 1 chunk +56 lines, -0 lines 0 comments Download
M state/open.go View 1 2 3 2 chunks +27 lines, -23 lines 0 comments Download
M state/requestednetworks.go View 1 2 3 1 chunk +19 lines, -16 lines 0 comments Download
M state/service.go View 1 2 3 2 chunks +2 lines, -2 lines 0 comments Download
M state/state.go View 1 2 3 4 5 4 chunks +81 lines, -28 lines 0 comments Download
M state/state_test.go View 1 2 3 1 chunk +38 lines, -0 lines 0 comments Download
M state/statecmd/machineconfig.go View 1 2 3 1 chunk +2 lines, -2 lines 0 comments Download
M worker/provisioner/provisioner_task.go View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M worker/provisioner/provisioner_test.go View 1 2 3 2 chunks +4 lines, -4 lines 0 comments Download

Messages

Total messages: 11
dimitern
Please take a look.
10 years, 1 month ago (2014-04-02 09:55:29 UTC) #1
dimitern
Please take a look.
10 years, 1 month ago (2014-04-02 10:12:45 UTC) #2
fwereade
Couple of tweaks please. https://codereview.appspot.com/83070047/diff/20001/state/machine.go File state/machine.go (right): https://codereview.appspot.com/83070047/diff/20001/state/machine.go#newcode915 state/machine.go:915: Update: bson.D{{"$set", bson.D{{"networkinterfaces", ifaces}}}}, I ...
10 years, 1 month ago (2014-04-02 10:18:45 UTC) #3
dimitern
Please take a look. https://codereview.appspot.com/83070047/diff/20001/state/machine.go File state/machine.go (right): https://codereview.appspot.com/83070047/diff/20001/state/machine.go#newcode915 state/machine.go:915: Update: bson.D{{"$set", bson.D{{"networkinterfaces", ifaces}}}}, On ...
10 years, 1 month ago (2014-04-03 15:14:05 UTC) #4
fwereade
Some naming quibbles; and quite a lot of freakouts wrt races. Most can be eliminated ...
10 years, 1 month ago (2014-04-03 16:37:08 UTC) #5
dimitern
Please take a look. https://codereview.appspot.com/83070047/diff/40001/juju/conn_test.go File juju/conn_test.go (right): https://codereview.appspot.com/83070047/diff/40001/juju/conn_test.go#newcode406 juju/conn_test.go:406: include, exclude, err := machine.LinkedNetworks() ...
10 years, 1 month ago (2014-04-04 09:14:43 UTC) #6
fwereade
LGTM with relatively trivial fixes: https://codereview.appspot.com/83070047/diff/40001/state/machine_test.go File state/machine_test.go (right): https://codereview.appspot.com/83070047/diff/40001/state/machine_test.go#newcode394 state/machine_test.go:394: net, err := st.AddMachineNetwork(networkName, ...
10 years, 1 month ago (2014-04-04 09:56:22 UTC) #7
dimitern
Please take a look. https://codereview.appspot.com/83070047/diff/40001/state/networkinterfaces.go File state/networkinterfaces.go (right): https://codereview.appspot.com/83070047/diff/40001/state/networkinterfaces.go#newcode69 state/networkinterfaces.go:69: func removeNetworkInterfacesOps(st *State, machineId string) ...
10 years, 1 month ago (2014-04-04 11:12:18 UTC) #8
dimitern
Please take a look.
10 years, 1 month ago (2014-04-04 11:22:38 UTC) #9
fwereade
LGTM, one last quibble https://codereview.appspot.com/83070047/diff/60001/state/machine.go File state/machine.go (right): https://codereview.appspot.com/83070047/diff/60001/state/machine.go#newcode941 state/machine.go:941: aliveAndNotProvisioned := append(isAliveDoc, bson.D{{"nonce", ""}}...) ...
10 years, 1 month ago (2014-04-04 12:10:01 UTC) #10
dimitern
10 years, 1 month ago (2014-04-04 13:10:12 UTC) #11
Please take a look.

https://codereview.appspot.com/83070047/diff/60001/state/machine.go
File state/machine.go (right):

https://codereview.appspot.com/83070047/diff/60001/state/machine.go#newcode941
state/machine.go:941: aliveAndNotProvisioned := append(isAliveDoc,
bson.D{{"nonce", ""}}...)
On 2014/04/04 12:10:03, fwereade wrote:
> On 2014/04/04 11:12:19, dimitern wrote:
> > On 2014/04/04 09:56:23, fwereade wrote:
> > > I think this is fine, assuming we have the provisioner pass the interfaces
> > into
> > > SetProvisioned, and inside the APi server call AddNetworkInterface before
> > > SetProvisioned?
> > 
> > I was thinking of having AddNetworkInterface on the Provisioner API later
and
> > call it as needed before calling SetProvisioned (and changing machine state
to
> > error if it happens, like we do after StartInstance errors).
> > 
> > Is there a particular reason you want NICs passed to SetProvisioned?
> 
> (1) chatty APIs suck (2) the quicker we can get all the instance info away
from
> the provisioner and into the api server the better.
> 
> ...in fact ...I'm almost tempted to say that this functionality should be of a
> transaction with the SetProvisioned method in state *anyway* -- consider what
> happens if a machine has a NIC set up but then the process fails before
> SetProvisioned.
> 
> That can be a minor refactoring when you hook up the provisioner, though.

Yes, I agree provisioning should be atomic, but it's not right now because of
StartInstance and SetProvisioned getting called in sequence (and adding a couple
of extra API calls will make it only a bit worse). I'm in favor of fixing it in
general, but this is out of scope for now.

https://codereview.appspot.com/83070047/diff/80001/state/machine.go
File state/machine.go (right):

https://codereview.appspot.com/83070047/diff/80001/state/machine.go#newcode567
state/machine.go:567: func (m *Machine) removeNetworkInterfacesOps() ([]txn.Op,
error) {
On 2014/04/04 12:10:03, fwereade wrote:
> just add a quick pedantic check that the machine really is Dead in here too

Done inside machine.Remove().
Sign in to reply to this message.

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