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

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) ===
If the storage pool cannot be initialized using the new storage backend,
try removing the storage pool volume the old way.

This fixes #6461.

Signed-off-by: Thomas Hipp <thomas.h...@canonical.com>
From 0007725a279c22dcadc7dcbd6698999ddf3e7d77 Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.h...@canonical.com>
Date: Fri, 15 Nov 2019 15:44:19 +0100
Subject: [PATCH] lxd: Cleanup storage volumes properly for VMs

If the storage pool cannot be initialized using the new storage backend,
try removing the storage pool volume the old way.

This fixes #6461.

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

diff --git a/lxd/vm_qemu.go b/lxd/vm_qemu.go
index 05601479ad..7215175cda 100644
--- a/lxd/vm_qemu.go
+++ b/lxd/vm_qemu.go
@@ -1834,7 +1834,23 @@ func (vm *vmQemu) Delete() error {
        // Attempt to initialize storage interface for the instance.
        pool, err := storagePools.GetPoolByInstance(vm.state, vm)
        if err != nil {
-               logger.Error("Failed to init storage pool", log.Ctx{"project": 
vm.Project(), "instance": vm.Name(), "err": err})
+               logger.Warn("Failed to init storage pool", log.Ctx{"project": 
vm.Project(), "instance": vm.Name(), "err": err})
+
+               // Remove the volume record from the database.
+               poolName, err := vm.StoragePool()
+               if err != nil {
+                       return err
+               }
+
+               poolID, err := vm.state.Cluster.StoragePoolGetID(poolName)
+               if err != nil {
+                       return err
+               }
+
+               err = vm.state.Cluster.StoragePoolVolumeDelete(vm.Project(), 
vm.Name(), db.StoragePoolVolumeTypeVM, poolID)
+               if err != nil {
+                       return err
+               }
        }
 
        if pool != nil {
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to