Repository navigation
fix(hetzner): support snapshot IDs in --image flag - #909
Merged
Merged
Conversation
Hetzner distinguishes named OS images ("ubuntu-22.04") from snapshots
referenced by numeric ID. The previous code always used hcloud.Image{Name}
which fails for snapshot IDs β the API requires hcloud.Image{ID} for those.
hcloudImage() now detects a purely numeric string and routes to ID, so
both forms work:
onctl create --image ubuntu-22.04 # named OS image
onctl create --image 185432 # snapshot or backup ID
This unblocks the onctl-runners prebaked image feature (RUNNER_IMAGE),
which passes a Hetzner snapshot ID to cut runner cold-start from ~60s
to VM-boot time only.
Codecov Reportβ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #909 +/- ##
==========================================
+ Coverage 22.01% 22.09% +0.08%
==========================================
Files 41 41
Lines 4107 4109 +2
==========================================
+ Hits 904 908 +4
+ Misses 3086 3084 -2
Partials 117 117 β View full report in Codecov by Harness. π New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--imagepreviously always usedhcloud.Image{Name: ...}, which works for named OS images (ubuntu-22.04) but fails for Hetzner snapshot/backup IDs (integers like185432) β the Hetzner API requireshcloud.Image{ID: ...}for thosehcloudImage()helper that detects a purely numeric string and routes toID, otherwise falls back toNameonctl create --image ubuntu-22.04andonctl create --image 185432Motivation
Unblocks the
RUNNER_IMAGEfeature inonctl-runners: the prebaked-image flow passes a Hetzner snapshot ID toonctl create --image <id>to cut GitHub Actions runner cold-start from ~60s (docker + runner download) to VM-boot time only (~15s).Test plan
go test ./pkg/cloud/...β three newTestHcloudImage_*unit tests cover named image, numeric snapshot ID, and negative integer casesonctl create --image <snapshot-id>against a real Hetzner snapshot boots from that snapshot instead of a fresh OS imageπ€ Generated with Claude Code