-
Notifications
You must be signed in to change notification settings - Fork 44
Add support for IP address changes #62
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
base: main
Are you sure you want to change the base?
Conversation
|
JFYI This Merge Request didn't work for me - same issue |
|
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! |
b5fc2d3 to
d25dc0f
Compare
|
while your'e at it |
d25dc0f to
01d5455
Compare
|
@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! |
01d5455 to
b9d8cb6
Compare
b9d8cb6 to
2376943
Compare
| } | ||
| }(*c, ui, config) | ||
|
|
||
| time.Sleep(500 * time.Millisecond) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The purpose of this time.sleep is, as you mentioned in your other comment, a minimum wait time to prevent the Predicate from resolving early. I have replaced the hardcoded value with a configurable one instead.
| Predicate: func() (result bool, err error) { | ||
| var ok bool | ||
| if ip, ok = state.Get("instance_ssh_address").(string); ok && ip != "" { | ||
| return true, nil | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion! I have added a configurable wait time, named "dhcp_wait" that will be used as an initial wait time before executing the Predicate. I have also, in a separate commit, aligned the XVA builder so that it uses the same self.config.InstallTimeout value as the ISO builder. However, I could not successfully update "config.hcl2spec.go" by executing make generate. I got an error that I have not (yet) been able to understand. If you haven't seen it before, I'll spend some time to figure it out, as I assume that I have to include the changes made by make generate in this PR? The error I get is the following:
mapstructure-to-hcl2: common.[Config]: internal error: package "fmt" without types was imported from "github.com/xenserver/packer-builder-xenserver/builder/xenserver/common"
builder/xenserver/common/config.go:1: running "packer-sdc": exit status 1
make: *** [generate] Error 1|
@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. |
2376943 to
b8d6908
Compare
|
Hi @ddelnano, apologies for the delay on my side as well. I've been having quite a lot to tend to personally for a while. I have answered and addressed your comments. I have one question regarding |
|
ran into this issue as well, fetched @Erik142's branch, rebased to current master and it solved my issue as well. N.B. I did have to install guest-utilities as part of the d-i preseed in order for it to work; although I believe that is intended based on the original code. while my testing was done @ddelnano if that's the case, what if any hold ups are remaining on this PR? |
|
Hey @enkaskal thanks for your message. I'll try to reboot and merge this old PR.
Indeed, the VM IP information goes like this: VM --> Guest Agent (old or new rust ones) --> XCP-ng --> Packer. So without agent at some point the IP cannot be retrieved.
Let's fix this in another PR
Time 😅 |
b8d6908 to
2bca591
Compare
|
Hi @enkaskal, @nathanael-h! Thanks for reviving this PR. I have rebased my branch onto the latest main. Let me know if anything else is required from my side! |
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. The goroutine will check for IP address changes every 500ms. Finally, a configurable initial delay has been added, with the intention of waiting for the initial IP address to be retrieved via DHCP. This configuration item is called "dhcp_wait", inspired by the already existing "boot_wait".
This commit aligns the timeout value in StepWaitForIP so that the ISO and XVA builder use the value coming from the configuration, instead of hardcoding a value for the XVA builder.
2bca591 to
ba91910
Compare
|
Thanks, I'll try to fix the code generation first and then merge this PR. (As this PR adds a config field, it would be better to do things like this). Work is in progress on my laptop 😅 |
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