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

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) ===
Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com>
From 61ea7804fc3352f8c44929544e6c5c8ef7407ea4 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parr...@canonical.com>
Date: Fri, 15 May 2020 15:06:50 +0100
Subject: [PATCH] lxd/instances/post: Delete restored instance on backup post
 hook failure

Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com>
---
 lxd/instances_post.go | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lxd/instances_post.go b/lxd/instances_post.go
index 01878626fe..d036908234 100644
--- a/lxd/instances_post.go
+++ b/lxd/instances_post.go
@@ -687,15 +687,18 @@ func createFromBackup(d *Daemon, project string, data 
io.Reader, pool string) re
                        return fmt.Errorf("Internal import request: %v", 
resp.String())
                }
 
-               c, err := instance.LoadByProjectAndName(d.State(), project, 
bInfo.Name)
+               inst, err := instance.LoadByProjectAndName(d.State(), project, 
bInfo.Name)
                if err != nil {
                        return errors.Wrap(err, "Load instance")
                }
 
+               // Clean up created instance if the post hook fails below.
+               runRevert.Add(func() { inst.Delete() })
+
                // Run the storage post hook to perform any final actions now 
that the instance has been created
                // in the database (this normally includes unmounting volumes 
that were mounted).
                if postHook != nil {
-                       err = postHook(c)
+                       err = postHook(inst)
                        if err != nil {
                                return errors.Wrap(err, "Post hook")
                        }
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to