Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to remove storage pool because of remnant actual volume #1083

Open
jordibalcellss opened this issue Apr 24, 2024 · 0 comments
Open

Failed to remove storage pool because of remnant actual volume #1083

jordibalcellss opened this issue Apr 24, 2024 · 0 comments

Comments

@jordibalcellss
Copy link

System Information

Linux distribution

AlmaLinux 9.3 (Shamrock Pampas Cat)

Terraform version

Terraform v1.7.5
on linux_amd64

Provider and libvirt versions

v0.7.6


Description of Issue/Question

Setup

terraform {                                                                    
  required_providers {                                                         
    libvirt = {                                                                
      source = "dmacvicar/libvirt"                                             
    }                                                                          
  }                                                                            
}                                                                              
                                                                               
provider "libvirt" {                                                           
  uri = "qemu:///system"                                                       
}                                                                              
                                                                               
resource "libvirt_pool" "disks" {                                              
  name = "disks"                                                               
  type = "dir"                                                                 
  path = "/mnt/kvm/disks"                                                      
}                                                                              
                                                                               
resource "libvirt_volume" "base_volume" {                                      
  name = "base.qcow2"                                                          
  pool = "disks"                                                               
  source = "http://mirror.netzwerge.de/almalinux/9/cloud/x86_64/images/AlmaLinux-9-GenericCloud-9.3-20231113.x86_64.qcow2"
  format = "qcow2"                                                             
}

Steps to Reproduce Issue

Apparently there's a bug related to libvirt_volume which prevents the actual qcow2 file from being removed.

This causes a failure during removal of the storage pool (which comes next during execution of terraform destroy). Removal of libvirt_volume.base_volume times out and the next action fails:

...
libvirt_volume.base_volume: Still destroying... [id=/mnt/kvm/disks/base.qcow2, 4m40s elapsed]
libvirt_volume.base_volume: Still destroying... [id=/mnt/kvm/disks/base.qcow2, 4m50s elapsed]
libvirt_volume.base_volume: Still destroying... [id=/mnt/kvm/disks/base.qcow2, 5m0s elapsed]
╷
│ Error: error deleting storage pool: failed to remove pool '/mnt/kvm/disks': Directory not empty
│ 
│ 
╵
╷
│ Error: error refreshing pool for volume: Requested operation is not valid: storage pool 'disks' is not active

If /mnt/kvm/disks/base.qcow2 is manually removed and terraform destroy rerun, it works. Same for the underlying virsh management:

virsh vol-delete base.qcow2 --pool disks
virsh pool-destroy disks
virsh pool-undefine disks

Additional information:

Do you have SELinux or Apparmor/Firewall enabled? Some special configuration? SELinux enabled
Have you tried to reproduce the issue without them enabled? Yes, I did disable SELinux, getting the same result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant