The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/8266

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) ===
Only apply to DB.

This is a commit from the stable-4.0 branch ported to the master branch for the bridge driver, and then a subsequent commit to align the non-stable-4.0 drivers with the bridge driver.
From 5409511b8014938594684d4d5625a31e6f1415ed 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 1/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 a733e5afc1..440b97dc35 100644
--- a/lxd/network/driver_bridge.go
+++ b/lxd/network/driver_bridge.go
@@ -1557,8 +1557,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)
        }
 

From f0a4beb75365d2e5e78ab596aa2602cc5edc5c66 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parr...@canonical.com>
Date: Thu, 17 Dec 2020 09:28:50 +0000
Subject: [PATCH 2/2] lxd/network/driver: Don't apply changes to node if
 network is pending

Aligns with 5409511b8 change for bridge driver from stable-4.0 branch.

Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com>
---
 lxd/network/driver_macvlan.go  | 6 ++++--
 lxd/network/driver_ovn.go      | 6 ++++--
 lxd/network/driver_physical.go | 6 ++++--
 lxd/network/driver_sriov.go    | 6 ++++--
 4 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/lxd/network/driver_macvlan.go b/lxd/network/driver_macvlan.go
index bba6d06369..7dededfd83 100644
--- a/lxd/network/driver_macvlan.go
+++ b/lxd/network/driver_macvlan.go
@@ -90,8 +90,10 @@ func (n *macvlan) Update(newNetwork api.NetworkPut, 
targetNode string, clientTyp
                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)
        }
 
diff --git a/lxd/network/driver_ovn.go b/lxd/network/driver_ovn.go
index 3e68e6018d..db9b7366d2 100644
--- a/lxd/network/driver_ovn.go
+++ b/lxd/network/driver_ovn.go
@@ -2002,8 +2002,10 @@ func (n *ovn) Update(newNetwork api.NetworkPut, 
targetNode string, clientType re
                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)
        }
 
diff --git a/lxd/network/driver_physical.go b/lxd/network/driver_physical.go
index 173fbfc774..6c019c628b 100644
--- a/lxd/network/driver_physical.go
+++ b/lxd/network/driver_physical.go
@@ -232,8 +232,10 @@ func (n *physical) Update(newNetwork api.NetworkPut, 
targetNode string, clientTy
                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)
        }
 
diff --git a/lxd/network/driver_sriov.go b/lxd/network/driver_sriov.go
index 2300a573c5..dff8b53b36 100644
--- a/lxd/network/driver_sriov.go
+++ b/lxd/network/driver_sriov.go
@@ -90,8 +90,10 @@ func (n *sriov) 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

Reply via email to