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

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) ===

From 2a1d40ba25915c18baf839aeb0bd784a11de1255 Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.h...@canonical.com>
Date: Tue, 8 Oct 2019 14:03:46 +0200
Subject: [PATCH 1/2] lxd: Fix backup expiry

This fixes a bug which causes all backups to never expire.

Signed-off-by: Thomas Hipp <thomas.h...@canonical.com>
---
 lxd/container_backup.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lxd/container_backup.go b/lxd/container_backup.go
index cf6b834cb2..fb1f35e275 100644
--- a/lxd/container_backup.go
+++ b/lxd/container_backup.go
@@ -99,10 +99,10 @@ func containerBackupsPost(d *Daemon, r *http.Request) 
response.Response {
                return response.InternalError(err)
        }
 
-       expiry, _ := rj.GetString("expiry")
+       expiry, _ := rj.GetString("expires_at")
        if expiry == "" {
                // Disable expiration by setting it to zero time
-               rj["expiry"] = time.Date(1, time.January, 1, 0, 0, 0, 0, 
time.UTC)
+               rj["expires_at"] = time.Date(1, time.January, 1, 0, 0, 0, 0, 
time.UTC)
        }
 
        // Create body with correct expiry

From 1e9ae9c234ef76f93dcb3da691104d7bdb5e6b09 Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.h...@canonical.com>
Date: Tue, 8 Oct 2019 14:31:30 +0200
Subject: [PATCH 2/2] lxd: Fix backup expiry check

This fixes issues regarding timezones in combination with zero time.

Before, backups might have wrongfully been expired/removed due to
timezone issues.

Signed-off-by: Thomas Hipp <thomas.h...@canonical.com>
---
 lxd/db/containers.go | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lxd/db/containers.go b/lxd/db/containers.go
index daaab7ba0d..38336718af 100644
--- a/lxd/db/containers.go
+++ b/lxd/db/containers.go
@@ -1325,7 +1325,9 @@ func (c *Cluster) ContainerBackupsGetExpired() ([]string, 
error) {
                        return []string{}, err
                }
 
-               if backupExpiry.IsZero() {
+               // Since zero time causes some issues due to timezones, we 
check the
+               // unix timestamp instead of IsZero().
+               if backupExpiry.Unix() <= 0 {
                        // Backup doesn't expire
                        continue
                }
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to