Closed rascasoft closed 1 year ago
Digging more around the issue I discovered that the problem is something that can be easily solved by using Terraform dependencies.
Starting from the original main.tf
I reported originally these are the additional sections that make everything behave as expected:
...
# Libvirt Storage Volumes
resource "libvirt_volume" "almalinux-8" {
name = "almalinux-8.qcow2"
pool = "kubelab"
source = "/home/rasca/Work/VMS/images/almalinux-8.qcow2"
format = "qcow2"
depends_on = [libvirt_pool.kubelab]
}
resource "libvirt_volume" "kubernetes-1-qcow2" {
name = "kubernetes-1.qcow2"
pool = "kubelab"
base_volume_id = libvirt_volume.almalinux-8.id
format = "qcow2"
depends_on = [libvirt_pool.kubelab]
}
...
# kubernetes-1
resource "libvirt_domain" "kubernetes-1" {
name = "kubernetes-1"
memory = "4096"
vcpu = "4"
cloudinit = libvirt_cloudinit_disk.commoninit.id
network_interface {
network_id = libvirt_network.kubelab.id
addresses = ["10.0.0.31"]
}
console {
type = "pty"
target_port = "1"
target_type = "virtio"
}
disk {
volume_id = libvirt_volume.kubernetes-1-qcow2.id
}
depends_on = [libvirt_volume.kubernetes-1-qcow2]
...
The depends_on
is what makes the trick, which is in the end quite logical. Sorry for the noise.
System Information
Linux distribution
Ubuntu 22.04
Provider & Terraform version
Libvirt versions
Checklist
[ ] Is your issue/contribution related with enabling some setting/option exposed by libvirt that the plugin does not yet support, or requires changing/extending the provider terraform schema?
[X] Is it a bug or something that does not work as expected? Please make sure you fill the version information below:
Description of Issue/Question
Setup
The main.tf I'm using:
Steps to Reproduce Issue
Simply run:
These are the relevant logs:
Note that the deletion of the volumes seems to work fine:
But physical files are still there and so the pool deletion cannot be completed:
Additional information: