-
Notifications
You must be signed in to change notification settings - Fork 496
Open
Description
When using libvirt_domain with an explicitly empty list for hostdevs (i.e., hostdevs = []), the provider returns null instead of [] after apply. This causes Terraform/OpenTofu to report "Provider produced inconsistent result after apply" errors.
This is a problem when you want to explicitly declare that a domain has no PCI passthrough devices, or when using dynamic configurations where some domains have hostdevs and others don't.
Steps to Reproduce
- Create the following minimal configuration:
terraform {
required_providers {
libvirt = {
source = "dmacvicar/libvirt"
version = "~> 0.9.0"
}
}
}
provider "libvirt" {
uri = "qemu:///session"
}
resource "libvirt_volume" "test" {
name = "test-empty-list-bug.qcow2"
pool = "default"
capacity = 1073741824
target = {
format = {
type = "qcow2"
}
}
}
resource "libvirt_domain" "test" {
name = "test-empty-list-bug"
memory = 512
vcpu = 1
type = "kvm"
os = {
type = "hvm"
type_arch = "x86_64"
}
devices = {
disks = [
{
source = {
volume = {
pool = "default"
volume = libvirt_volume.test.name
}
}
target = {
dev = "vda"
bus = "virtio"
}
}
]
# Explicitly empty list - triggers the bug
hostdevs = []
}
}- Run
terraform init && terraform apply
Expected Behavior
Apply should succeed and terraform plan should show "No changes".
Actual Behavior
Apply fails with:
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to libvirt_domain.test, provider "provider[\"registry.opentofu.org/dmacvicar/libvirt\"]"
│ produced an unexpected new value: .devices.hostdevs: was cty.ListValEmpty(cty.Object(...)), but now null.
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
Metadata
Metadata
Assignees
Labels
No labels