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

Terraform loses track of instances that reaches timeout for wait_for_network in incus_instance #174

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 the argument wait_for_network true in incus_network and it for some reason fails to obtain an IP-address before the timeout then terraform loses track of the instance. All subsequent runs will return an error that the instance already exists, but since terraform doesn't have it in the state file, it doesn't know about it.

Example code:

resource "incus_instance" "this" {
  count = 10

  type                     = "container"
  name                     = "instance-${count.index}"
  image                    = "images:debian/12/cloud"
  wait_for_network         = true

  config = {
    "boot.autostart" = true
  }
}

output "instance_ips" {
  value = { for idx, instance in incus_instance.this : instance.name => instance.ipv4_address }
}

Expected results:

instance_ip = {
  "instance-0" = "..."
...
}

Actual results:

incus_instance.this[8]: Creating...
incus_instance.this[4]: Creating...
incus_instance.this[5]: Creating...
incus_instance.this[6]: Creating...
incus_instance.this[2]: Creating...
incus_instance.this[7]: Creating...
incus_instance.this[9]: Creating...
incus_instance.this[3]: Creating...
incus_instance.this[1]: Creating...
incus_instance.this[4]: Still creating... [10s elapsed]
...
incus_instance.this[6]: Still creating... [3m10s elapsed]
╷
│ Error: Failed to wait for instance "instance-4" to get an IP address
│
│   with incus_instance.this[4],
│   on main.tf line 74, in resource "incus_instance" "this":
│   74: resource "incus_instance" "this" {
│
│ timeout while waiting for state to become 'OK' (last state: 'Waiting for network',
│ timeout: 3m0s)
╵
╷
│ Error: Failed to wait for instance "instance-9" to get an IP address
│
│   with incus_instance.this[9],
│   on main.tf line 74, in resource "incus_instance" "this":
│   74: resource "incus_instance" "this" {
│
│ timeout while waiting for state to become 'OK' (last state: 'Waiting for network',
│ timeout: 3m0s)
╵
╷
│ Error: Failed to wait for instance "instance-1" to get an IP address
│
│   with incus_instance.this[1],
│   on main.tf line 74, in resource "incus_instance" "this":
│   74: resource "incus_instance" "this" {
│
│ timeout while waiting for state to become 'OK' (last state: 'Waiting for network',
│ timeout: 3m0s)
╵
╷
│ Error: Failed to wait for instance "instance-6" to get an IP address
│
│   with incus_instance.this[6],
│   on main.tf line 74, in resource "incus_instance" "this":
│   74: resource "incus_instance" "this" {
│
│ timeout while waiting for state to become 'OK' (last state: 'Waiting for network',
│ timeout: 3m0s)
╵
╷
│ Error: Failed to wait for instance "instance-2" to get an IP address
│
│   with incus_instance.this[2],
│   on main.tf line 74, in resource "incus_instance" "this":
│   74: resource "incus_instance" "this" {
│
│ timeout while waiting for state to become 'OK' (last state: 'Waiting for network',
│ timeout: 3m0s)
╵
╷
│ Error: Failed to wait for instance "instance-3" to get an IP address
│
│   with incus_instance.this[3],
│   on main.tf line 74, in resource "incus_instance" "this":
│   74: resource "incus_instance" "this" {
│
│ timeout while waiting for state to become 'OK' (last state: 'Waiting for network',
│ timeout: 3m0s)
╵
╷
│ Error: Failed to wait for instance "instance-5" to get an IP address
│
│   with incus_instance.this[5],
│   on main.tf line 74, in resource "incus_instance" "this":
│   74: resource "incus_instance" "this" {
│
│ timeout while waiting for state to become 'OK' (last state: 'Waiting for network',
│ timeout: 3m0s)
╵
╷
│ Error: Failed to wait for instance "instance-8" to get an IP address
│
│   with incus_instance.this[8],
│   on main.tf line 74, in resource "incus_instance" "this":
│   74: resource "incus_instance" "this" {
│
│ timeout while waiting for state to become 'OK' (last state: 'Waiting for network',
│ timeout: 3m0s)
╵
╷
│ Error: Failed to wait for instance "instance-7" to get an IP address
│
│   with incus_instance.this[7],
│   on main.tf line 74, in resource "incus_instance" "this":
│   74: resource "incus_instance" "this" {
│
│ timeout while waiting for state to become 'OK' (last state: 'Waiting for network',
│ timeout: 3m0s)
@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