Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Generate ENI and push to LXD container before start #6276
Conversation
anastasiamac
reviewed
Sep 20, 2016
Code looks good but lack of unit tests in the area worries me. Especially, lack of checking the error conditions.
Please get another network-savy reviewer to PTAL as well :D
| @@ -202,17 +202,19 @@ func PrepareNetworkConfigFromInterfaces(interfaces []network.InterfaceInfo) *Pre | ||
| // might include per-interface networking config if both networkConfig | ||
| // is not nil and its Interfaces field is not empty. |
anastasiamac
Sep 20, 2016
Member
Is this comment still valid? Looks like a change in behavior, I would have liked to see a change in comment too \o/
macgreagoir
Sep 20, 2016
Contributor
To my reading of this comment, this change makes it more correct, in that we can now have networkConfig that is nil.
| - userData, err := containerinit.CloudInitUserData(instanceConfig, networkConfig) | ||
| + // Do not pass networkConfig, as we want to directly inject our own ENI | ||
| + // rather than using cloud-init. | ||
| + userData, err := containerinit.CloudInitUserData(instanceConfig, nil) | ||
| if err != nil { | ||
| return |
anastasiamac
Sep 20, 2016
Member
I think you've changed err scope here because it is used in := statement. Please provide an explicit return as above with errors.Trace \o/
macgreagoir
Sep 20, 2016
Contributor
I stand to be corrected :-) but think it's OK. err is already declared in the signature and err here is not in a new lexical block, so is only assigned.
I am not keen to introduce a mixture of bare and explicit returns in this function, if we don't need to, but I'll let the second reviewer you ask for push me that way too :-)
| @@ -143,6 +145,7 @@ func (manager *containerManager) CreateContainer( | ||
| return |
| @@ -143,6 +145,7 @@ func (manager *containerManager) CreateContainer( | ||
| return | ||
| } | ||
| + // TODO This might be dead code. Do we always get len(nics) > 0? |
anastasiamac
Sep 20, 2016
Member
Please add a "juju" TODO - TODO(your nick) so that we'd know who to ask if questions arise.
Also this one looks like it might be worth a bug/a card/a tech-debt card... Please add one of these and reference it in TODO as well.
| + eni, err := containerinit.GenerateNetworkConfig(networkConfig) | ||
| + if err != nil { | ||
| + err = errors.Annotatef(err, "failed to generate /etc/network/interfaces content") | ||
| + return |
macgreagoir
referenced this pull request
Sep 20, 2016
Closed
Update LXD network templates for Juju #6267
voidspace
commented
Sep 26, 2016
|
My current experience with this branch is that with two NICs, with PXE subnet on the "second" NIC, a container will fail to get an address at all. That's both with the "first" NIC as an unconfigured NIC and a NIC on a different subnet. I'm doing:
|
voidspace
commented
Sep 26, 2016
•
|
|
I've retested with rc1 and with rc1 plus this patch, with and without a statically configured address on the second interface (and with PXE/DHCP on the higher-sorted, first, interface in all cases). I can reproduce the bug without this patch and see the bug fixed with this patch. Let's compare MAAS environments and see what we're doing differently. |
voidspace
commented
Sep 26, 2016
|
So, the QA instructions suggest to rename the NIC on the PXE subnet to ethZ so that it sorts "second" - which is what I have been doing. I've also been using auto-assign rather than "static" - which may not work without DHCP but shouldn't cause a non-functioning container. I'm using a MAAS controller inside a KVM container, with two virsh networks, and nodes that are also KVM containers. |
dimitern
approved these changes
Sep 28, 2016
QA OK and LGTM - tested with xenial, trusty, and precise containers
|
$$merge$$ |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju |
macgreagoir commentedSep 19, 2016
Uses PushFile to write the correct /etc/network/interfaces config to the
container rootfs between (lxc) init and start.
This prevents the default LXD behaviour, which is to expect DHCP on
eth0, breaking container provisioning when DHCP is not available in the
eth0 space.
Fixes lp:1611981
QA steps:
juju add-machine lxd:<host>for a xenial container/etc/network/interfacesshould configure its interfaces and nameservers correct for the environment (eth0 with an address in nicA's space, in this example, and eth1 in nicZ's) and should not source/etc/network/interfaces.d/*.cfgjuju add-machine --series trusty lxd:<host>