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

Problem with obtain ipv4 addresses for group of nodes #1349

Closed
krnworks opened this issue Jun 3, 2024 · 6 comments
Closed

Problem with obtain ipv4 addresses for group of nodes #1349

krnworks opened this issue Jun 3, 2024 · 6 comments
Labels
🐛 bug Something isn't working ⌛ pending author's response Requested additional information from the reporter

Comments

@krnworks
Copy link

krnworks commented Jun 3, 2024

Hello!

Occasionally, upon the initial run, I receive empty output for the IP-addresses of virtual machines. However, if I repeat the apply command, I get the expected lists.

output "ipv4_addresses" {
  value = {
    for vm_key, vm_value in proxmox_virtual_environment_vm.basic_vm:
    vm_key => flatten(vm_value.ipv4_addresses)
  }
}
Outputs:

ipv4_addresses = {
  "pve-1-1-12-0" = []
  "pve-1-1-12-1" = [
    "127.0.0.1",
    "10.0.200.35",
  ]
  "pve-1-1-13-0" = []
  "pve-1-1-13-1" = []
}

It appears that this behavior occurs because the output is retrieved before the virtual machines have acquired their IP addresses.

Is there a workaround for this issue or a way to introduce artificial delay to ensure that the output is retrieved after the virtual machines have acquired their IP addresses?

I use dhcp.

Best regards, Roman

@krnworks krnworks added the 🐛 bug Something isn't working label Jun 3, 2024
@bpg
Copy link
Owner

bpg commented Jun 4, 2024

Hi @krnwrks!

It won't be possible to reliably populate the VM IP addresses at the end of VM provisioning flow without using qemu guest agent.

This provider requires agent.enabled = true to populate ipv4_addresses,
ipv6_addresses and network_interface_names output attributes.

@bpg bpg added the invalid This doesn't seem right label Jun 4, 2024
@krnworks
Copy link
Author

krnworks commented Jun 4, 2024

The guest agent is enabled, you can see that in my output I received the address from 1 of nodes in the first try

@bpg bpg removed the invalid This doesn't seem right label Jun 4, 2024
@bpg
Copy link
Owner

bpg commented Jun 5, 2024

Hm... The provider actually does wait for a non-localhost IP address 🤔

@krnwrks Could you pls. provide additional details about your environment, and perhaps output from your plan execution? A debug log would be ideal.

@bpg bpg added the ⌛ pending author's response Requested additional information from the reporter label Jun 5, 2024
@bpg
Copy link
Owner

bpg commented Jun 5, 2024

As a workaround you may try adding something like this to your VM config:

  provisioner "local-exec" {
    when    = create
    command = "sleep 5s"
  }

@bpg
Copy link
Owner

bpg commented Jun 7, 2024

There is a good analysis on "wait for IP" behaviour in #668 (comment)

@bpg
Copy link
Owner

bpg commented Aug 9, 2024

I'm going to close this issue as I haven't heard back from the author with additional details.

@krnworks, please feel free to reopen it if you need more support on this.

@bpg bpg closed this as completed Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working ⌛ pending author's response Requested additional information from the reporter
Projects
None yet
Development

No branches or pull requests

2 participants