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

incus_instance argument wait_for_network shouldn't assume IPv4 #175

Open
vegardx opened this issue Nov 29, 2024 · 1 comment
Open

incus_instance argument wait_for_network shouldn't assume IPv4 #175

vegardx opened this issue Nov 29, 2024 · 1 comment

Comments

@vegardx
Copy link

vegardx commented Nov 29, 2024

Currently the wait_for_network argument when set to true will wait for the instance to have an IPv4 address. This means that you can only use this argument reliably in networks where IPv4 is available, which makes it a little harder to do things like updating DNS records with the output of an instance creation on IPv6-only networks, or where IPv6 is the network you're actually relying on.

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.ipv6_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)
@antifob
Copy link

antifob commented Dec 25, 2024

I've been hit by this too. I worked around it by importing the instance after the "failure".

I am not familiar enough with terraform to be confident, but how about a bool | string type for wait_for_network: true, false, ipv4, ipv6?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants