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

In a clustered incus_network the cluster-specific parts of the config is read back to the node-specific resource, causing a change #176

Open
vegardx opened this issue Nov 29, 2024 · 0 comments
Labels
Bug Confirmed to be a bug

Comments

@vegardx
Copy link

vegardx commented Nov 29, 2024

When you set up a cluster network the config argument in incus_network on the node-specific resources contains the cluster-specific changes, this causes terraform to think there's a drift, and try to correct it. When you try to apply the changes it will return that this is a node-specific argument.

Example code:

resource "incus_network" "node_network" {
  for_each = toset(["incus-01", "incus-02", "incus-03"])
  target   = each.value

  name = "foobar"
  type = "macvlan"

  config = {
    parent = "bond0"
  }
}

resource "incus_network" "cluster_network" {
  depends_on = [
    incus_network.node_network,
  ]

  name = "foobar"
  type = "macvlan"

  config = {
    vlan = 400
  }
}

After successfully applying it and re-running terraform you will see this:

  # incus_network.node_network["incus-01"] will be updated in-place
  ~ resource "incus_network" "node_network" {
      ~ config      = {
          - "vlan"   = "400" -> null
            # (1 unchanged element hidden)
        }
        name        = "foobar"
        # (4 unchanged attributes hidden)
    }

  # incus_network.node_network["incus-02"] will be updated in-place
  ~ resource "incus_network" "node_network" {
      ~ config      = {
          - "vlan"   = "400" -> null
            # (1 unchanged element hidden)
        }
        name        = "foobar"
        # (4 unchanged attributes hidden)
    }

  # incus_network.node_network["incus-03"] will be updated in-place
  ~ resource "incus_network" "node_network" {
      ~ config      = {
          - "vlan"   = "400" -> null
            # (1 unchanged element hidden)
        }
        name        = "foobar"
        # (4 unchanged attributes hidden)
    }

As a workaround you can ignore this change by just setting a lifecycle argument on the node-specific incus_network resource.

resource "incus_network" "node_network" {
  for_each = toset(["incus-01", "incus-02", "incus-03"])
  target   = each.value

  name = "foobar"
  type = "macvlan"

  config = {
    parent = "bond0"
  }

  lifecycle {
    ignore_changes = [
      config["vlan"],
    ]
  }
}
@stgraber stgraber added the Bug Confirmed to be a bug label Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Confirmed to be a bug
Development

No branches or pull requests

2 participants