Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Device post stop hook #6043

Merged
merged 12 commits into from Aug 6, 2019

Conversation

@tomponline
Copy link
Member

commented Aug 5, 2019

This modifies the device interface to allow the Stop() function to return a RunConfig struct, similar to the Start() function.

This allows the Stop() function to return a partially populated RunConfig struct to communicate with LXD which devices it should detach from the container and how to do it (such as what interface name to use when detaching a NIC back onto the host).

It also allows a slice of functions to be returned in the PostHooks variable, which LXD will then execute after the device has been detached.

This also changes when the Stop() function is called, it is now executed before any devices are detached from a running container, however the PostHooks are called after the detaching has been completed.

It also has a nice side-effect of mirroring the behaviour of the Start() function.

The reason for this change is as follows:

  1. Allows NIC devices to indicate to LXD that it does not need to detach an interface (such as bridge and p2p veth devices), as the PostHooks will delete the parent device which will delete the veth peer.
  2. Allows NIC devices to specify the detach hostname directly, without having to use volatile, which pushes more detach logic down into the device package.
  3. Allows future unix devices to figure out which paths need to be detached inside the device package, without having to put device-type specific logic into LXD.

This PR also adds some more tests to check for volatile key clean up.

Part of #5819

@tomponline tomponline referenced this pull request Aug 5, 2019
3 of 3 tasks complete

tomponline added some commits Aug 5, 2019

container/lxc: Restructures deviceStop to support post stop hooks
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
device: Updates interface for Stop() to return RunConfig
For supporting post stop hooks.

Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
device/device/runconfig: Renames PostStartHooks to PostHooks
So it can be used with both Start() and Stop() device functions.

Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
device/nic/bridged: Updates for post stop hooks
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
device/nic/p2p: Updates for post stop hooks
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
device/nic/vlan: Updates for post stop hooks
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
device/nic/macvlan: Updates for post stop hooks
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
device/nic/physical: Updates for post stop hooks
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
device/nic/sriov: Updates for post stop hooks
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
device/proxy: Updates for post stop hooks
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>

@tomponline tomponline force-pushed the tomponline:tp-device-poststop-hook branch from daeffea to 9a72cca Aug 5, 2019

tomponline added some commits Aug 5, 2019

test: Renames ct_name to ctName for consistent naming in NIC tests
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
test: Updates NIC tests to check for volatile key cleanup
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>

@tomponline tomponline force-pushed the tomponline:tp-device-poststop-hook branch from 9a72cca to 9c8ded2 Aug 5, 2019

@tomponline

This comment has been minimized.

Copy link
Member Author

commented Aug 5, 2019

@stgraber those commits have been split.

@stgraber

This comment has been minimized.

Copy link
Member

commented Aug 5, 2019

jenkins: test this please

@stgraber stgraber merged commit 43eea09 into lxc:master Aug 6, 2019

5 checks passed

Branch target Branch target is correct
Details
DCO All commits signed-off
Details
Testsuite Testsuite passed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@tomponline tomponline deleted the tomponline:tp-device-poststop-hook branch Aug 6, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.