dmacvicar / terraform-provider-libvirt

Terraform provider to provision infrastructure with Linux's KVM using libvirt
Apache License 2.0
1.54k stars 457 forks source link

Cannot destroy VMs after reboot (probably due to network being down) #892

Closed vadorovsky closed 2 years ago

vadorovsky commented 2 years ago

System Information

Linux distribution

openSUSE 15.3

Terraform version

terraform -v
Terraform v0.13.4
+ provider registry.terraform.io/dmacvicar/libvirt v0.6.11
+ provider registry.terraform.io/hashicorp/template v2.2.0

Provider and libvirt versions

terraform-provider-libvirt -version
0.6.11

Libvirt version: 7.1.0-6.5.1

Checklist

Description of Issue/Question

Setup

(Please provide the full main.tf file for reproducing the issue (Be sure to remove sensitive information)

The whole environment, including main.tf, is here:

https://github.com/rancher-sandbox/lockc/tree/main/contrib/terraform/libvirt

Steps to Reproduce Issue

(Include debug logs if possible and relevant).

  1. Set up the virtual machines with
terraform apply
  1. After success, reboot your host machine.
  2. Try to remove the VMs and see the error:
❯ terraform destroy -force
data.template_file.control_plane_commands: Refreshing state... [id=4d9d2a56f2041f465e03c3f92bda337b5dd08bc82e482be6846453beee515c5d]
data.template_file.control_plane_cloud_init[0]: Refreshing state... [id=e13accf8c798d30ba980ba1867d12e5370fc7cddc6bc4d03ff6cf5e5baf51f51]
libvirt_volume.lockc_image: Refreshing state... [id=/var/lib/libvirt/images/lockc-image]
libvirt_network.lockc_network: Refreshing state... [id=b559738a-0cd4-473c-8fab-ac58c0d084a8]
libvirt_cloudinit_disk.control_plane[0]: Refreshing state... [id=/var/lib/libvirt/images/lockc-control-plane-cloudinit-disk-0;a7d18d66-afef-4f02-9612-b389fca90f44]
libvirt_volume.control_plane[0]: Refreshing state... [id=/var/lib/libvirt/images/lockc-control-plane-volume-0]
libvirt_volume.worker[0]: Refreshing state... [id=/var/lib/libvirt/images/lockc-worker-volume-0]
libvirt_domain.control_plane[0]: Refreshing state... [id=4ed32670-cf81-401e-8b8b-b6f83d1335c3]

Error: Invalid index

  on output.tf line 4, in output "ip_control_planes":
   4:     libvirt_domain.control_plane.*.network_interface.0.addresses.0,

The given key does not identify an element in this collection value.

Error: Invalid index

  on worker.tf line 11, in data "template_file" "worker_commands":
  11:     control_plane_ip = libvirt_domain.control_plane.0.network_interface.0.addresses.0
    |----------------
    | libvirt_domain.control_plane[0].network_interface[0].addresses is empty list of string

The given key does not identify an element in this collection value.

Additional information:

Do you have SELinux or Apparmor/Firewall enabled? Some special configuration? Have you tried to reproduce the issue without them enabled?

No, I don't have SELinux or Apparmor enabled.

vadorovsky commented 2 years ago

Nevermind, I managed to fix the issue on my side https://github.com/rancher-sandbox/lockc/pull/67