hetzner-cloud-plugin icon indicating copy to clipboard operation
hetzner-cloud-plugin copied to clipboard

Use actions to wait for async tasks completion

Open jooola opened this issue 5 months ago • 0 comments

What feature do you want to see added?

I noticed that this plugin is not waiting for actions (Hetzner Cloud API async task) to be completed, instead the plugin relies on fetching e.g. server over and over until something has changed.

This leads to users being rate limited by our API, and may introduce a lot of errors while performing changes (e.g. locking) which in turn requires to retry a lot request and hitting the rate limits again. Also, sometimes a new change (action) may only be performed once the previous change (action) is completed.

Note that our API has a different rate limit for actions than for other endpoints. This is because we expect users to wait for actions to complete by calling the actions endpoint more than the other, more expensive, resource endpoints. You should leverage that to reduce the chances to run into rate limits.

I recommend you to implement a actions wait function similar to:

  • https://github.com/hetznercloud/hcloud-go/blob/v2.22.0/hcloud/action_waiter.go#L101-L120
  • https://github.com/hetznercloud/hcloud-go/blob/v2.22.0/hcloud/action_waiter.go#L18-L99

This will allow you to wait for the actions returned by e.g. the create server endpoint, instead of calling /servers/<id> repeatedly. This applies for all of the API resources that returns actions.

Upstream changes

No response

Are you interested in contributing this feature?

No, but I am happy to answer additional questions.

jooola avatar Sep 03 '25 12:09 jooola