Skip to content

fix(lb): delete the balancer with a single request - #57

Open
lexfrei wants to merge 1 commit into
fix/release-balancerfrom
fix/cleanup-single-delete
Open

lexfrei wants to merge 1 commit into
fix/release-balancerfrom
fix/cleanup-single-delete

Conversation

@lexfrei

@lexfrei lexfrei commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

cleanup now deletes a load balancer with one API call instead of removing every service and target first. A balancer with 3 ports and 10 targets used to cost 14 calls, which hurts when the project is close to the 3600 requests/hour limit. The lookup is untouched: recorded ID first, then the name.

The Hetzner API reference only says "Deletes a Load Balancer" for this endpoint and doesn't say what happens to the services and targets. I based the change on how Hetzner's own clients delete a balancer. They send one delete and remove nothing first:

I did not test this against a live project.

Network handling stays as it was: cleanup doesn't detach the balancer from its network, and neither of those clients does.

One side effect: an error in the middle of the old loop left a balancer with some services already removed. That can't happen now.

The loops also carried the only log lines inside cleanup, so the delete itself is no longer logged there with the balancer name and ID. A single tracing::info! before the delete would bring that back; I left it out to keep the change minimal.

There is no unit test for the call itself, since the HTTP path has no mock in this repo. Existing tests and cargo fmt pass, and clippy reports the same warnings as the base.

Stacked on #47, so it targets fix/release-balancer.

Closes #44

cleanup removed every service and every target one request at a time
and only then deleted the balancer, so a balancer with 3 ports and 10
targets cost 14 API calls instead of 1. That matters when the project
is close to the hourly rate limit.

The API reference only says "Deletes a Load Balancer" and does not
describe what happens to its services and targets. The change follows
how Hetzner's own cloud controller manager and CLI delete a balancer:
one delete call, with no prior removal of services or targets and no
network detach. Network handling is left as it was.

A failure part-way no longer leaves a balancer with some services
already removed.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
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