[lxc-devel] [lxd/master] lxd/backup: Re-order checks for backup.yaml

stgraber on Github lxc-bot at linuxcontainers.org
Thu Mar 7 18:26:57 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 370 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190307/07ae3ca5/attachment.bin>
-------------- next part --------------
From 345847ab5eedb6fe306521f18eafad2460112ee3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 7 Mar 2019 13:26:09 -0500
Subject: [PATCH] lxd/backup: Re-order checks for backup.yaml
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #5553

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/container_lxc.go | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index b439650a48..1af7dac903 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -3834,13 +3834,6 @@ func writeBackupFile(c container) error {
 		return os.ErrNotExist
 	}
 
-	/* deal with the container occasionally not being monuted */
-	rootfs := c.RootfsPath()
-	if !shared.PathExists(rootfs) {
-		logger.Warn("Unable to update backup.yaml at this time", log.Ctx{"name": c.Name(), "rootfs": rootfs})
-		return nil
-	}
-
 	ci, _, err := c.Render()
 	if err != nil {
 		return errors.Wrap(err, "Failed to render container metadata")
@@ -3888,6 +3881,12 @@ func writeBackupFile(c container) error {
 		return err
 	}
 
+	// Ensure the container is currently mounted
+	if !shared.PathExists(c.RootfsPath()) {
+		logger.Debug("Unable to update backup.yaml at this time", log.Ctx{"name": c.Name(), "project": c.Project()})
+		return nil
+	}
+
 	f, err := os.Create(filepath.Join(c.Path(), "backup.yaml"))
 	if err != nil {
 		return err


More information about the lxc-devel mailing list