[lxc-devel] [lxd/master] lxd: Fix duplicate scheduled snapshots
monstermunchkin on Github
lxc-bot at linuxcontainers.org
Mon Feb 18 08:47:14 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 448 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190218/2fda0a5f/attachment.bin>
-------------- next part --------------
From 31546ecfb806a79d5b9d318d7a218b0f47e1735e Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Mon, 18 Feb 2019 09:43:46 +0100
Subject: [PATCH] lxd: Fix duplicate scheduled snapshots
This fixes scheduled snapshots being created twice after each other.
This fixes #5504.
Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
lxd/container.go | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lxd/container.go b/lxd/container.go
index f42b04982d..467931c291 100644
--- a/lxd/container.go
+++ b/lxd/container.go
@@ -1584,7 +1584,11 @@ func autoCreateContainerSnapshotsTask(d *Daemon) (task.Func, task.Schedule) {
now := time.Now()
next := sched.Next(now)
- if now.Add(time.Minute).Before(next) {
+ // Ignore everything that is more precise than minutes.
+ now = now.Truncate(time.Minute)
+ next = next.Truncate(time.Minute)
+
+ if !now.Equal(next) {
continue
}
More information about the lxc-devel
mailing list