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

Graceful shutdown of domain resource when recreate is required #1060

Open karelvanhecke opened 6 months ago

karelvanhecke commented 6 months ago

System Information

Linux distribution

CentOS Stream 8

Terraform version

$ terraform -v
Terraform v1.6.6
on linux_amd64
+ provider registry.terraform.io/dmacvicar/libvirt v0.7.6

Provider and libvirt versions

dmacvicar/libvirt v0.7.6
libvirtd (libvirt) 8.0.0

Description of Issue/Question

Currently, when a domain resource has been modified and requires a recreate, the domain is destroyed and recreated. While this is the most performant solution, it isn't necessarily the safest when you consider that the attached volumes aren't necessarily destroyed and recreated.

This could in theory lead to data corruption.

In #356 graceful shutdown was proposed, but this issue was closed.

marshallford commented 5 months ago

I'm interested in this feature as well, particularly for the use case of running immutable infrastructure with Fedora CoreOS or Flatcar Container Linux where the established pattern is to replace VMs when making configuration/version changes (with ignition) rather than using a config mgmt tool over the top.

Silvenga commented 2 months ago

This seems important, as changing the memory of a domain will cause the domain to be replaced. This means the next boot of the same volume will be after an unclean shutdown.