The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/3930
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === In order to determine whether a given device needs to be updated LXD will diff the keys and values for the old and the new device settings. If LXD determines a difference it will append the key and the corresponding value to the device. If it determines they don't differ the key and value won't be in the updated devices list that is passed to the the container's update method. So we can simply rely on checking whether the given key exists in the device that is to be updated if it isn't we don't need to run the actual update. Closes #3920. Signed-off-by: Christian Brauner <[email protected]>
From abe8684cc47e9aa87613dbeeb125cf73c94bd6b6 Mon Sep 17 00:00:00 2001 From: Christian Brauner <[email protected]> Date: Wed, 11 Oct 2017 10:02:53 +0200 Subject: [PATCH] network: do not update limits unconditionally In order to determine whether a given device needs to be updated LXD will diff the keys and values for the old and the new device settings. If LXD determines a difference it will append the key and the corresponding value to the device. If it determines they don't differ the key and value won't be in the updated devices list that is passed to the the container's update method. So we can simply rely on checking whether the given key exists in the device that is to be updated if it isn't we don't need to run the actual update. Closes #3920. Signed-off-by: Christian Brauner <[email protected]> --- lxd/container.go | 2 ++ lxd/container_lxc.go | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lxd/container.go b/lxd/container.go index bde60418a..d53d91e19 100644 --- a/lxd/container.go +++ b/lxd/container.go @@ -81,6 +81,8 @@ func containerValidConfigKey(os *sys.OS, key string, value string) error { return nil } +var containerNetworkLimitKeys = []string{"limits.max", "limits.ingress", "limits.egress"} + func containerValidDeviceConfigKey(t, k string) bool { if k == "type" { return true diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go index ce8918179..535044c74 100644 --- a/lxd/container_lxc.go +++ b/lxd/container_lxc.go @@ -6777,6 +6777,18 @@ func (c *containerLXC) setNetworkLimits(name string, m types.Device) error { return fmt.Errorf("Network limits are only supported on bridged and p2p interfaces") } + needsUpdate := false + for _, v := range containerNetworkLimitKeys { + _, needsUpdate = m[v] + if needsUpdate { + break + } + } + + if !needsUpdate { + return nil + } + // Load the go-lxc struct err := c.initLXC() if err != nil { @@ -6796,9 +6808,10 @@ func (c *containerLXC) setNetworkLimits(name string, m types.Device) error { // Look for the host side interface name veth := c.getHostInterface(m["name"]) - if veth == "" { - return fmt.Errorf("LXC doesn't know about this device and the host_name property isn't set, can't find host side veth name") + return fmt.Errorf(`LXC doesn't know about this device and the ` + + `host_name property isn't set, can't find host side ` + + `veth name`) } // Apply max limit
_______________________________________________ lxc-devel mailing list [email protected] http://lists.linuxcontainers.org/listinfo/lxc-devel
