mirror of
https://github.com/trailofbits/dropkit
synced 2026-06-21 14:11:54 +00:00
Offer to delete leftover hibernation snapshot on droplet destroy (#49)
* Offer to delete leftover hibernation snapshot on droplet destroy When a user hibernates a droplet then wakes it up but declines to delete the snapshot, the snapshot is left behind. If they later `dropkit destroy` the droplet, the orphaned snapshot persists silently, incurring storage costs. After destroying the droplet, check for a matching hibernation snapshot and prompt the user to delete it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Change snapshot deletion default to 'no' in destroy command Respect the user's earlier choice: if they declined to delete the snapshot during wakeup, defaulting to 'yes' here would second-guess that decision. Default to 'no' so the prompt is informational rather than presumptive. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
parent
212306c568
commit
b4df5c9d3a
@@ -2786,6 +2786,32 @@ def destroy(droplet_name: str = typer.Argument(..., autocompletion=complete_drop
|
||||
tailscale_ip=droplet_tailscale_ip,
|
||||
)
|
||||
|
||||
# Check for leftover hibernation snapshot
|
||||
snapshot_name = get_snapshot_name(droplet_name)
|
||||
user_tag = get_user_tag(username)
|
||||
snapshot = api.get_snapshot_by_name(snapshot_name, tag=user_tag)
|
||||
|
||||
if snapshot:
|
||||
snapshot_id_str = snapshot.get("id")
|
||||
if snapshot_id_str:
|
||||
snapshot_id = int(snapshot_id_str)
|
||||
size_gb = snapshot.get("size_gigabytes", 0)
|
||||
console.print()
|
||||
console.print(
|
||||
f"[yellow]Found leftover hibernation snapshot:[/yellow] "
|
||||
f"{snapshot_name} ({size_gb} GB)"
|
||||
)
|
||||
delete_snap = Prompt.ask(
|
||||
"[yellow]Delete this snapshot too?[/yellow]",
|
||||
choices=["yes", "no"],
|
||||
default="no",
|
||||
)
|
||||
if delete_snap == "yes":
|
||||
api.delete_snapshot(snapshot_id)
|
||||
console.print("[green]✓[/green] Snapshot deleted")
|
||||
else:
|
||||
console.print("[dim]Snapshot kept[/dim]")
|
||||
|
||||
console.print()
|
||||
console.print("[bold green]Droplet successfully destroyed[/bold green]")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user