[lxc-devel] [lxd/master] lxd/networks: Fix revert on update failure
stgraber on Github
lxc-bot at linuxcontainers.org
Fri Jul 20 14:55:09 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180720/46ac3d4a/attachment.bin>
-------------- next part --------------
From b6f1c56bc7b5c9622438a7ef38ae29aea98d934f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 20 Jul 2018 10:54:41 -0400
Subject: [PATCH] lxd/networks: Fix revert on update failure
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd/networks.go | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/lxd/networks.go b/lxd/networks.go
index 7b863f0dd..b81963be4 100644
--- a/lxd/networks.go
+++ b/lxd/networks.go
@@ -1751,8 +1751,15 @@ func (n *network) Update(newNetwork api.NetworkPut) error {
undoChanges := true
defer func() {
if undoChanges {
+ // Revert changes to the struct
n.config = oldConfig
n.description = oldDescription
+
+ // Update the database
+ n.state.Cluster.NetworkUpdate(n.name, n.description, n.config)
+
+ // Reset any change that was made to the bridge
+ n.Start()
}
}()
More information about the lxc-devel
mailing list