-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Add the ability to spin up Hetzner servers from custom snapshots #4153
Add the ability to spin up Hetzner servers from custom snapshots #4153
Conversation
Welcome @marvinpinto! |
cc: @LKaemmerling |
Hey @marvinpinto, thank you for your contribution. I would suggest using the ID of the image instead of the description. The description is not unique and can be changed really fast. The ID is stable. Another point: hcloud-go All Method with Filtering: https://pkg.go.dev/github.com/hetznercloud/hcloud-go/hcloud#ImageClient.AllWithOpts |
Hey @LKaemmerling, thank you for taking time to review this!
Understood, I will move all logic out of hcloud-go 👍
The original lookup for an image was done purely using the image name, e.g. "ubuntu-20.04". This of course works well for pre-baked images but not so well for custom snapshots because it seems that snapshots don't get a In the lookup function I modified, it first attempts to look up an image by its ID (e.g. if someone supplies an int), then if it doesn't find anything it attempts a lookup using the In the final case, it returns the most recent (custom snapshot) image, which is useful in scenarios where these images are churned regularly and one only wishes to use the newest. Do you still have concerns about using the |
The description is basically just a description (this sentence should get an Oscar!). You should not query against it as it may change easily. For your use case I would suggest using labels on the snapshot and then a label selector as a way to query all images with this selector. Ideally this should be only one image, but if there are more images with a specific label you can use the most recent one. So as I said using the description is not recommended. |
What needs to be taken into account as well is that every request you send against the API counts towards your Ratelimit. So you shouldn't to this on every node creation (because this might be a problem when you need a lot of nodes in a short time) |
Sounds good to me 👍
I was thinking the logic to retrieve the image ID could go somewhere in this block. Which I believe would only run on startup and use the "found" image ID until the autoscaler is restarted. Does this sound reasonable to you, or would you prefer I implement caching + periodic updating (possibly via the Refresh mechanism)? |
Personally from a hcloud provider perspective I'm fine with both 😀 but I using the on startup is fine, as the images shouldn't change that often |
dfa2ce2
to
4344a17
Compare
This comes in handy when using tools such as Packer to generate customized images.
4344a17
to
b2ead3b
Compare
I've rebased this PR against My updated docker image is available at: docker pull ghcr.io/marvinpinto/autoscaler:d234dc55 |
Hey @marvinpinto, thank you this looks good, I just have a few smaller minor things but than from my side everything is ready :) Good job! |
Thank you again for taking the time @LKaemmerling, really appreciate it 😊 |
Hey @marvinpinto, this looks good to me! Great job :) |
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.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: LKaemmerling, marvinpinto, mwielgus The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This comes in handy when using tools such as Packer to generate customized images.
I have a working docker image built off this feature and I've not run into issues thus far. The image below is linked from my
autoscaler
fork.