[lxc-devel] [lxd/master] Network: Don't apply node changes when network is in pending state
tomponline on Github
lxc-bot at linuxcontainers.org
Thu Dec 17 09:31:16 UTC 2020
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 505 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20201217/91b0d42d/attachment.bin>
-------------- next part --------------
From 5409511b8014938594684d4d5625a31e6f1415ed Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at 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.parrott at 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.parrott at 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.parrott at 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)
}
More information about the lxc-devel
mailing list