Skip to content

fix(hetzner): support snapshot IDs in --image flag - #909

Merged
cdalar merged 1 commit into
mainfrom
feat/hetzner-image-snapshot-id
Jun 16, 2026
Merged

cdalar merged 1 commit into
mainfrom
feat/hetzner-image-snapshot-id

Conversation

@cdalar

@cdalar cdalar commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • --image previously always used hcloud.Image{Name: ...}, which works for named OS images (ubuntu-22.04) but fails for Hetzner snapshot/backup IDs (integers like 185432) β€” the Hetzner API requires hcloud.Image{ID: ...} for those
  • Adds hcloudImage() helper that detects a purely numeric string and routes to ID, otherwise falls back to Name
  • Both forms now work: onctl create --image ubuntu-22.04 and onctl create --image 185432

Motivation

Unblocks the RUNNER_IMAGE feature in onctl-runners: the prebaked-image flow passes a Hetzner snapshot ID to onctl 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 new TestHcloudImage_* unit tests cover named image, numeric snapshot ID, and negative integer cases
  • Manual: onctl create --image <snapshot-id> against a real Hetzner snapshot boots from that snapshot instead of a fresh OS image

πŸ€– Generated with Claude Code

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.
@cdalar
cdalar merged commit eac0a45 into main Jun 16, 2026
13 checks passed
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
βœ… Project coverage is 22.09%. Comparing base (6aa63e5) to head (3353e4e).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
pkg/cloud/hetzner.go 80.00% 1 Missing ⚠️
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.
πŸ“’ Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cdalar
cdalar deleted the feat/hetzner-image-snapshot-id branch August 19, 2026 13:53
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.

1 participant

⌂ 捒网址