Repository navigation
destroy: a paused Hetzner VM is a snapshot, deleted only when asked as one - #1274
Merged
Merged
Conversation
…s one Hetzner's pause deletes the server, so destroying a paused VM by name failed with "No Server found with name". Destroy still deletes only servers; the new SnapshotDestroyer (Hetzner's DestroySnapshot) deletes a paused VM's snapshot and the public IP kept for it. The tui's ctrl-d and onctl destroy say the VM is only a snapshot, that it can never be resumed after, and ask before calling it. Destroy also returns Hetzner's errors instead of log.Fatalln, which would have killed the tui.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1274 +/- ##
==========================================
+ Coverage 50.14% 50.44% +0.30%
==========================================
Files 83 83
Lines 9764 9822 +58
==========================================
+ Hits 4896 4955 +59
+ Misses 4868 4867 -1 ☔ 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.
What
On Hetzner, destroying a paused VM failed with
No Server found with name: test. That happened in the TUI'sctrl-dand inonctl destroy testalike. Hetzner's pause deletes the server and keeps only a snapshot and the public IP.Destroylooks for a server, so it found nothing.Now a paused Hetzner VM is called a snapshot, and it's deleted only after you've been asked as one:
cloud.SnapshotDestroyer: a new optional interface, implemented by Hetzner asDestroySnapshot(name). It deletes the VM's pause snapshots and the primary IPs kept for it. Both cost money until deleted: storage, and the IP's monthly fee. IPs attached to a server are never touched.Destroy: still deletes only servers, so it can never delete a snapshot by surprise. For a name with no server it returnsno server named "test".ctrl-don a paused VM:onctl destroy <name>: a paused VM gets the same explanation before the[y/N].--forcestill skips the question.pausedcounts. A powered-off server (off, AWS'sstopped) is filed with the paused VMs, but it's still a server and is destroyed as one.Destroyreturns API errors instead of callinglog.Fatalln, which would have killed the TUI.Testing
TestProviderHetzner_DestroyPausedruns against a fake Hetzner API.Destroydeletes nothing for a paused VM and still deletes a running server.DestroySnapshotdeletes the snapshot and the unassigned IP only, and errors for an unknown name. It fails on the oldDestroy.TestTUIDestroySnapshotchecks the single and marked questions' wording, that the snapshot goes toDestroySnapshot, and that astoppedVM still goes toDestroy. Two mutation checks failed it: using the broader paused state group, and never treating a VM as a snapshot.go test ./...passes, andgolangci-lintis clean.onctl destroyprompt has no automated test, because its[y/N]is interactive. It hasn't been run against real Hetzner snapshots either. Yourtestandqweare left for you to try.🤖 Generated with Claude Code
https://claude.ai/code/session_01Ba6Vc6KwaV9dTWbzYVKA78