fix(load_balancer): lift delete protection when deleting the resource - #1480
nikolauspschuetz wants to merge 1 commit into
Conversation
The delete-protection docs state that a protected resource can still be deleted by Terraform (protection only guards against other API consumers), but `hcloud_load_balancer` returned "load balancer deletion is protected" instead of deleting (hetznercloud#1206). Before deleting, disable delete protection if it is enabled, mirroring the behaviour already implemented for `hcloud_zone_rrset`. Adds a regression acceptance test that destroys a still-protected Load Balancer. Closes hetznercloud#1206 Assisted-by: Claude Code (Anthropic, Opus 4.x)
|
Thanks @jooola — that's fair. Silently changing delete-protection behavior in a Happy to implement that. Before I rework this PR: do you have a preferred shape |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1480 +/- ##
===========================================
- Coverage 73.19% 37.88% -35.32%
===========================================
Files 115 115
Lines 12776 12779 +3
===========================================
- Hits 9352 4841 -4511
- Misses 2347 7874 +5527
+ Partials 1077 64 -1013
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Closes #1206.
Problem
The delete-protection docs state that a protected resource can still be deleted by Terraform — protection only prevents other API consumers (e.g. the Cloud Console) from deleting it. But
hcloud_load_balancerfailed withload balancer deletion is protectedinstead of deleting.As @apricote noted in the issue, only
hcloud_zone_rrsetcurrently lifts protection to make its changes; the other resources don't follow the documented behaviour.Fix
In
resourceLoadBalancerDelete, if the Load Balancer has delete protection enabled, disable it (via the existingsetProtectionhelper) before deleting — mirroringhcloud_zone_rrset. AddsTestAccLoadBalancerResource_DeleteProtectionLifted, which creates a Load Balancer withdelete_protection = trueand never disables it, so the framework'sCheckDestroymust delete a still-protected resource (fails without this change).Scope
I've scoped this to
hcloud_load_balancer— the resource in the issue (and the one that bites thehcloud-cloud-controller-manageruse case). Your inventory in #1206 lists the same gap forfloating_ip,network,primary_ip,server,volume, andzone. Happy to extend this PR to cover the rest in one coordinated change if you'd prefer that over per-resource PRs — just let me know.Testing
go build ./...,go vet, andgofmtare clean; the new acceptance test compiles and is skipped withoutTF_ACC. I haven't run it against a live account in this PR — glad for CI / a maintainer to run it, and I can also run it against my own throwaway project if useful.AI assistance
Implemented with Claude Code; I directed the change (reusing the in-repo
setProtectionhelper and thezone_rrsetpattern) and verified build/vet/test-compile locally.