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

feat(hcloud): select the location randomly from a given list #89

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

Conversation

ebostijancic
Copy link

Hetzner cloud can run out of instances in a given location. To avoid reconfiguring the driver every time this happens, this PR implements a random location selection based on the list of whitelisted locations.

Copy link
Owner

@JonasProgrammer JonasProgrammer left a comment

Choose a reason for hiding this comment

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

Hi and first of all, thank you for the PR.

There are some minor nit-picks I could also fix myself, but I wanted to know if there is a specific design rationale behind.

In general, I have one more comment regarding the architecture: Would it be feasible to select the random location directly at configuration time (i.e. by indexing directly into the string slice) and then resolve all of the strings in the PreCreateCheck, just keeping one cachedLocation around? This should have pretty much the same effect, but the configuration will be in a specified state directly after create.

Also, without having tested it, I think that the current implementation may fail if no location is passed at all?

@@ -29,8 +30,8 @@ type Driver struct {
cachedImage *hcloud.Image
Type string
cachedType *hcloud.ServerType
Location string
cachedLocation *hcloud.Location
Locations []string
Copy link
Owner

Choose a reason for hiding this comment

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

Personally I think the final location should still be in Location, as there are some downstream projects that depend on the 'public' data of the driver.

Keeping the location pool around in a separate public field seems like the best downward-compatible solution IMHO, that would still allow downstream tools to support this option in the future.

@stale
Copy link

stale bot commented Jun 18, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the no-response Issue was marked stale and no response has been received in time. label Jun 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-response Issue was marked stale and no response has been received in time.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants