Use maas devices api for address allocation #2750

Merged
merged 86 commits into from Jul 9, 2015

Conversation

Projects
None yet
3 participants

Where address allocation is enabled, along with MAAS > 1.8, the new devices API will be used for container address allocation and deallocation. This allows MAAS to track that IP addresses for containers are associated with their host, and if the host goes away (for example with "destroy-environment --force" then the associated devices should be deleted and their IP addresses released. This prevents IP addresses leaking when "destroy-environment --force" is used.

The devices API requires a MAC address, and the device must be created before the address can be allocated which we need to do before the container is started (as the address is used in the container template to configure networking). This means we need to generate MAC addresses, and use them in the container templates (both lxc and kvm).

This PR includes generating MAC addresses on the API server and storing them with IP addresses in state, to be used for both IP address allocation and releasing.

Michael Foord and others added some commits Jun 3, 2015

Merge pull request #2493 from voidspace/container-macs
Use template generation for starting KVM instances with a MAC address

Generate and use an XML template for starting KVM instances when we specify a NIC with a MAC address.

I've manually tested that CreateMachine can successfully start KVM instances with a NIC using the specified MAC address.

(Review request: http://reviews.vapour.ws/r/1860/)
Merge pull request #2520 from voidspace/devices-master-merge-1
Merge master

Merge master back into the devices-api-maas feature branch.

(Review request: http://reviews.vapour.ws/r/1886/)
Merge pull request #2565 from voidspace/generate-macs
Generate MAC addresses for container

When addressable containers is enabled, the MAC address for templates are generated in advance. This PR also addresses a test issue in lxc-broker_test.go (asserts in the fake API were causing a data race and early test termination). The NetworkInfo member of the return value from lxcbroker.StartInstance is also populated (to ensure the network details are populated in state after provisioning).

(Review request: http://reviews.vapour.ws/r/1935/)
Merge pull request #2598 from voidspace/devices-master-merge-2
Merge master

Merge master into devices-api-maas feature branch. Only change from master is a minor conflict resolution in lxc-broker_test.go.

(Review request: http://reviews.vapour.ws/r/1970/)
Merge pull request #2719 from voidspace/allocate-with-device
Allocate IP addresses for containers using the devices API on MAAS if available

If the version of MAAS in use is 1.8 or higher, and addressable containers are in use, then use the devices API to allocate the IP address.

This moves generation of container MAC addresses to the api server as the MAC address is needed for the creation of the device. The MAC address is stored on the IP address as it will be needed for releasing the address again.

(Review request: http://reviews.vapour.ws/r/2097/)
Merge pull request #2725 from voidspace/devices-master-merge-3
Merge master

Merge master into feature branch.

(Review request: http://reviews.vapour.ws/r/2103/)
Merge pull request #2739 from voidspace/devices-address-release
Delete device on address release

If an address was allocated with a device, and it is the last address allocated to that device (with our current code it always will be as we only allocate one address per container) then the device is deleted on address release.

Manually tested against MAAS 1.9.

(Review request: http://reviews.vapour.ws/r/2116/)

@jujubot jujubot merged commit 9a6137f into juju:master Jul 9, 2015

Contributor

bz2 commented Jul 9, 2015

This proposal was landed as it is actually identical to #2749 which was instead intended to be a merge the other way.

@voidspace voidspace deleted the voidspace:merge-devices-api-maas branch Oct 6, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment