fix(load_balancer): lift delete protection when deleting the resource#1480
Open
nikolauspschuetz wants to merge 1 commit into
Open
fix(load_balancer): lift delete protection when deleting the resource#1480nikolauspschuetz wants to merge 1 commit into
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)
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.
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.