Skip to content

libvirt_network resource cannot be updated after creation #1251

@phkrl

Description

@phkrl

Example for ips.dhcp.ranges.block

Initial configuration

resource "libvirt_network" "network" {
  name      = "test"
  autostart = true

  ips = [
    {
      address = "10.0.5.0"
      prefix  = 25
      dhcp = {
        ranges = [
          {
            start = "10.0.5.20"
            end   = "10.0.5.30"
          }
        ]
      }
    }
  ]
}

terraform apply successfully creates this one

Updated configuration

resource "libvirt_network" "network" {
  name      = "test"
  autostart = true

  ips = [
    {
      address = "10.0.5.0"
      prefix  = 25
      dhcp = {
        ranges = [
          {
            start = "10.0.5.20"
            end   = "10.0.5.35"
          }
        ]
      }
    }
  ]
}

The only thing changed is ranges.end address. The plan shows:

  # libvirt_network.network will be updated in-place
  ~ resource "libvirt_network" "network" {
        id        = "d4319b03-1a5e-412a-bb01-4d084cf08e6a"
      ~ ips       = [
          ~ {
              ~ dhcp    = {
                  ~ ranges = [
                      ~ {
                          ~ end   = "10.0.5.30" -> "10.0.5.35"
                            # (1 unchanged attribute hidden)
                        },
                    ]
                }
                # (2 unchanged attributes hidden)
            },
        ]
        name      = "test"
        # (2 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

However, on apply there is:

libvirt_network.network: Modifying... [id=d4319b03-1a5e-412a-bb01-4d084cf08e6a]
╷
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to libvirt_network.network, provider "provider[\"terraform.local.org/dmacvicar/libvirt\"]" produced an unexpected new value:
│ .ips[0].dhcp.ranges[0].end: was cty.StringVal("10.0.5.35"), but now cty.StringVal("10.0.5.30").
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

And the network is not changed.

It seems to affect other options too. To this moment i faced same issue with any dns configuration and it seems other network parameters suffer from this too.

Versions information:

Terraform v1.14.3
on linux_arm64
+ provider terraform.local.org/dmacvicar/libvirt v0.9.1

I was not able to find any function that could handle resource update in generated code - were they not meant to exist in this version or is this an actual error?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions