The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/8267
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) === And don't allow re-create attempts on errored networks, as we don't track per-node state and so cannot tell which nodes have successfully been setup and which ones haven't. So the only valid approach is to require the user to delete and start again.
From ae88adbb97e31c12e6b5ac569ffe539372c3229c Mon Sep 17 00:00:00 2001 From: Thomas Parrott <thomas.parr...@canonical.com> Date: Thu, 17 Dec 2020 09:23:21 +0000 Subject: [PATCH 1/2] lxd/networks: Prevent re-create attempts on errored networks This is because the stable-4.0 branch does not have per-node state and so we cannot track which nodes have been successfully setup and which are still pending. Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com> --- lxd/networks.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lxd/networks.go b/lxd/networks.go index 03acf7aac3..cdf15b2386 100644 --- a/lxd/networks.go +++ b/lxd/networks.go @@ -203,6 +203,12 @@ func networksPost(d *Daemon, r *http.Request) response.Response { return response.InternalError(err) } + // If the network has previously had a create attempt that failed, then because we cannot track per-node + // status, we need to prevent any further create attempts and require the user to delete and re-create. + if netInfo != nil && netInfo.Status == api.NetworkStatusErrored { + return response.BadRequest(fmt.Errorf("Network is in errored state, please delete and re-create")) + } + // Check if we're clustered. count, err := cluster.Count(d.State()) if err != nil { From 642de5bf4f34b888f44f762f88a16cfeb8419ba2 Mon Sep 17 00:00:00 2001 From: Thomas Parrott <thomas.parr...@canonical.com> Date: Thu, 17 Dec 2020 09:25:43 +0000 Subject: [PATCH 2/2] lxd/network/driver/bridge: Don't apply updates to node when network is pending If no network create attempt has been attempted then we should just update the DB and await the global create attempt. Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com> --- lxd/network/driver_bridge.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lxd/network/driver_bridge.go b/lxd/network/driver_bridge.go index 74d3e107e3..c55644cced 100644 --- a/lxd/network/driver_bridge.go +++ b/lxd/network/driver_bridge.go @@ -1497,8 +1497,10 @@ func (n *bridge) Update(newNetwork api.NetworkPut, targetNode string, clientType return nil // Nothing changed. } - if n.LocalStatus() == api.NetworkStatusPending { - // Apply DB change to local node only. + // If the network as a whole has not had any previous creation attempts, or the node itself is still + // pending, then don't apply the new settings to the node, just to the database record (ready for the + // actual global create request to be initiated). + if n.Status() == api.NetworkStatusPending || n.LocalStatus() == api.NetworkStatusPending { return n.common.update(newNetwork, targetNode, clientType) }
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel