Skip to content

Wait on srv.NextActions after creating server #119

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

Closed
apricote opened this issue Dec 13, 2023 · 3 comments
Closed

Wait on srv.NextActions after creating server #119

apricote opened this issue Dec 13, 2023 · 3 comments
Assignees

Comments

@apricote
Copy link

Julian from @hetznercloud here 👋

while investigating a customer ticket, I noticed that you are not waiting on the additional actions returned from the POST /v1/servers endpoint. Instead you poll the server to wait for it to startup.

log.Infof(" -> Creating server %s[%d] in %s[%d]", srv.Server.Name, srv.Server.ID, srv.Action.Command, srv.Action.ID)
if err = d.waitForAction(srv.Action); err != nil {
return errors.Wrap(err, "could not wait for action")
}
d.ServerID = srv.Server.ID
log.Infof(" -> Server %s[%d]: Waiting to come up...", srv.Server.Name, srv.Server.ID)
err = d.waitForRunningServer()
if err != nil {
return err
}

I would recommend you wait on the actions in srv.NextActions. In there is also the start_server action, which is marked as completed once the server is running. You can check out our CLI code for comparison: https://github.com/hetznercloud/cli/blob/50fe4ca15deea739279539cf0bb2628ee2693f0e/internal/cmd/server/create.go#L100-L110

There is also a helper client.Action.WatchOverallProgress that can watch multiple actions at the same time.

Based on the contents, the GET /v1/servers/:id endpoint which you currently use is less efficient than simply polling the actions. It also counts towards a different Rate Limit budget, which caused an issue for one customer because they exhausted the normal Rate Limit with these calls.

@JonasProgrammer
Copy link
Owner

Hi Julian,

thanks a lot for the input, I'll look into fixing this. Unfortunately, the way this currently works is yet another left-over from pre-hcloud-go times...

While I will provide a bug-fix release for this issue, I now seriously do consider re-implementing the whole creation logic at some point. Too many issues caused by the driver still basically doing what it has done since cloud-beta times with some more features and waitForActions sprinkled across. If there is any more input you want to share, I'd be glad to hear it.

@apricote
Copy link
Author

Awesome! Thanks for the quick improvement :)

I used to be a user of the project myself back in 2018-2020, its nice to see you still work on this after all these years!

@Wouter0100
Copy link

Thanks for the investigation, @apricote - and for the quick implementation of the suggested changes @JonasProgrammer!

I think we were the customer you were investigating for @apricote, and we now updated this docker-machine driver to ensure we won't hit any limits again :-).

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

No branches or pull requests

3 participants