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

Add support for IP address changes #62

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Erik142
Copy link

@Erik142 Erik142 commented Apr 10, 2023

This PR improves upon the existing "Wait for IP step", by continuously checking for changes to the IP address for the VM, even after the IP address has been retrieved.

The implementation is using a simple goroutine which encapsulates the existing method used to wait for the IP address. When an IP address has been found, the goroutine will put the IP address directly in the state, which will be queried when the IP address should be retrieved.

A minor customization has been made to the "SSH port forward step", to retrieve the IP address from the state instead of using a string variable.

Closes #61

@sergej-brazdeikis
Copy link

JFYI This Merge Request didn't work for me - same issue

TCP connection to SSH ip/port failed: dial tcp 192.168.178.104:22: connect: connection refused
TCP connection to SSH ip/port failed: dial tcp 192.168.178.104:22: i/o timeout
TCP connection to SSH ip/port failed: dial tcp 192.168.178.104:22: connect: host is down
TCP connection to SSH ip/port failed: dial tcp 192.168.178.104:22: connect: host is down
TCP connection to SSH ip/port failed: dial tcp 192.168.178.104:22: connect: host is down
TCP connection to SSH ip/port failed: dial tcp 192.168.178.104:22: i/o timeout

@Erik142
Copy link
Author

Erik142 commented Jun 23, 2023

Thank you for this feedback @sjevs! The PR has worked flawlessly for me. Could you describe in more detail how to reproduce the fault you described? A minimal set of steps to reproduce the issue would be preferable, that way I can start to work on a fix directly. Or if possible, please post the complete Packer HCL file that you are using when this error occurs.

Thanks!

@Erik142 Erik142 force-pushed the 61-support-ip-address-changes branch from b5fc2d3 to d25dc0f Compare June 23, 2023 07:56
@hoerup
Copy link

hoerup commented Jul 5, 2023

while your'e at it
ip_getter is not a documented option could you add it to docs/builders/iso/xenserver-iso.html.markdown ?

@Erik142 Erik142 force-pushed the 61-support-ip-address-changes branch from d25dc0f to 01d5455 Compare July 16, 2023 06:47
@Erik142
Copy link
Author

Erik142 commented Jul 16, 2023

@hoerup I could definitely take a look at that. However, I believe that should be a separate issue/pull request, no? If you think it's OK to include it in this PR, I can take care of that!

@Erik142 Erik142 force-pushed the 61-support-ip-address-changes branch from 01d5455 to b9d8cb6 Compare July 16, 2023 06:51
This commit improves upon the existing "Wait for IP step", by
continuously checking for changes to the IP address for the VM, even
after the IP address has been retrieved.

The implementation is using a simple goroutine which encapsulates the
existing method used to wait for the IP address. When an IP address has
been found, the goroutine will put the IP address directly in the state,
which will be queried when the IP address should be retrieved.
}
}(*c, ui, config)

time.Sleep(500 * time.Millisecond)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of this time.Sleep?

Comment on lines +83 to +87
Predicate: func() (result bool, err error) {
var ok bool
if ip, ok = state.Get("instance_ssh_address").(string); ok && ip != "" {
return true, nil
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the InterruptibleWait could still return a stale value. I'm wondering if it makes sense to introduce a minimum wait time to prevent the Predicate from resolving early. This would allow end users to further delay resolving the predicate if the default runtime isn't enough time for their DHCP to converge. I think we could account for the existing time.Sleep call above as the default for this value.

In addition to that, it looks like the Timeout is hard coded to 300 seconds for the xva builder (source). We should update to be consistent with the iso version so the maximum can be tuned as well.

@ddelnano
Copy link
Owner

ddelnano commented Feb 8, 2024

@Erik142 sorry for the delay. The overall idea sounds good to me. I have a few questions about hardening a bit to make sure if there is still a race with DHCP converging, that it can be tuned appropriately.

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

Successfully merging this pull request may close these issues.

Support changes of IP address on reboot of VM
4 participants