Skip to content

droplet: Refactor post-create polling code.#776

Merged
andrewsomething merged 3 commits intomainfrom
asb/droplet-refresh-refactor
Jan 14, 2022
Merged

droplet: Refactor post-create polling code.#776
andrewsomething merged 3 commits intomainfrom
asb/droplet-refresh-refactor

Conversation

@andrewsomething
Copy link
Copy Markdown
Member

This PR refactors the code used to poll a Droplet's status after the request to create it. #767 points out one issue with the existing implementation, but it also exposes another issue with it. So I've taken the opportunity to fix those and make the entire process more efficient.

It now first uses waitForAction to ensure that the Droplet create action completes successfully. This allows us to fail fast in the case of a real error instead of continuing to poll the non-existent Droplet. Polling the action endpoint allows for an error to be reported while polling the droplet endpoint just 404s (which we retry on) if the create fails.

The call to waitForDropletAttribute checking for the Droplet's status attribute to move from new to active is still made after that. This is possibly unnecessary, but I've kept it to make sure we don't introduce any unexpected behavior changes. (I'm not 100% positive that the action completing is entirely equivalent to the Droplet becoming active.)

It also removes the usage of resourceDigitalOceanDropletRead in dropletStateRefreshFunc in order to reduce the overall number of API calls made. Currently in main, each pass through newDropletStateRefreshFunc actually calls client.Droplets.Get twice. The final call in resourceDigitalOceanDropletCreate to resourceDigitalOceanDropletRead is also removed to cut another redundant API call.

So while this now makes calls to both the actions and droplets endpoints to make sure the Droplet has been successfully created, it is still more efficient and reduces the overall number of API call made substantially.

Additionally, there are a number of unrelated fixes to the Droplet acceptance tests so that they all now pass. These failure seem to be the result of moving the tests from using legacy Droplet plans to new ones without updating the expected disk sizes.

@andrewsomething andrewsomething requested a review from a team January 10, 2022 21:21
@andrewsomething andrewsomething temporarily deployed to Acceptance Tests January 10, 2022 21:22 Inactive
@andrewsomething andrewsomething temporarily deployed to Acceptance Tests January 14, 2022 19:17 Inactive
Copy link
Copy Markdown
Contributor

@scotchneat scotchneat left a comment

Choose a reason for hiding this comment

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

👍🏽

@andrewsomething andrewsomething merged commit 1ab865b into main Jan 14, 2022
@andrewsomething andrewsomething deleted the asb/droplet-refresh-refactor branch January 14, 2022 21:00
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.

4 participants