Skip to content

ICNAS-928: Reduce Cloud API requests on stuck deletes - #421

Open
mcaratas-ionos wants to merge 14 commits into
masterfrom
fix/ICNAS-928
Open

mcaratas-ionos wants to merge 14 commits into
masterfrom
fix/ICNAS-928

Conversation

@mcaratas-ionos

@mcaratas-ionos mcaratas-ionos commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Description of your changes

This PR adds backoff and wait mechanisms that reduce the number of Cloud API requests when a delete request takes long or gets stuck, which also avoids repeated 422/429 responses.

This PR adds:

  • Status polling with backoff: check every second for the first minute, then 2s, 4s, 8s and at most 10s, instead of every 1s for the whole wait (up to the reconcile timeout).
  • One attempt per SDK call (MaxRetries = 1). Transient status errors (429, 5xx, short network errors) keep the poll going instead of failing it.
  • No duplicate DELETEs: the DELETE request ID is stored in the ionos.cloud/delete-request-id annotation (Server, Nic, Volume, FirewallRule, Lan). Later reconciles check that request instead of sending a new DELETE.
  • LAN waits for its NICs: a LAN is only deleted after its NICs are gone.
  • Two opt-in flags, both off by default:
    • --delete-request-wait: how long a Delete waits for its request before ending the reconcile.
    • --api-throttle-wait / --api-throttle-max-wait: after a 429, writes to that datacenter are held (Retry-After is honoured); after a 422, that DELETE is held. Held requests get a local 429 with errorCode PROVIDER_THROTTLED.
  • CI: Go 1.27.3 + golang.org/x/net v0.62.0, golangci-lint v2.15.0, and a Trivy image ID fix for Docker 29 runners (CI is red without these).

Checklist

I have:

  • Add PR name as appropriate (e.g. feat/fix/doc/test/refactor)
  • Run make reviewable and make crds.clean to ensure the PR is ready for review
  • Add or update tests (if applicable)
  • Add or update Documentation using make docs.update (if applicable)
  • Update docs/CHANGELOG.md file (label: upcoming release)
  • Check Sonar Cloud Scan
  • Update Github or Jira Issue - not applicable

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Process-wide throttle keys omit the request origin, allowing throttling on one API endpoint to incorrectly suppress requests to another healthy endpoint.

1 open issue
What changed in this PR

This PR reduces Cloud API traffic during stuck or long-running deletions in the IONOS Cloud provider.

Changes:

  • Persists DELETE request IDs, adds configurable wait limits, and delays LAN deletion while NICs remain attached.
  • Adds polling backoff, disables rapid SDK retries, and introduces optional write throttling.
  • Adds tests and documentation, updates Go dependencies, and adjusts CI image lookup.
File Description
internal/​controller/​compute/​volume/​volume.go Tracks pending volume deletes and applies wait limits.
internal/​controller/​compute/​server/​server.go Tracks pending server deletes and applies wait limits.
internal/​controller/​compute/​nic/​nic.go Tracks pending NIC deletes and applies wait limits.
internal/​controller/​compute/​lan/​lan.go Checks attached NICs and tracks pending LAN deletes.
internal/​controller/​compute/​lan/​lan_mock_test.go Tests attached-NIC and pending-delete behavior.
internal/​controller/​compute/​firewallrule/​firewallrule.go Tracks pending firewall-rule deletes and applies wait limits.
internal/​clients/​throttle_transport.go Adds shared throttling after 429 and DELETE 422 responses.
internal/​clients/​throttle_transport_test.go Tests throttle behavior and transport integration.
internal/​clients/​ionoscloud.go Configures single-attempt requests and optional throttling.
internal/​clients/​ionoscloud_test.go Updates expected SDK retry settings.
internal/​clients/​compute/​compute.go Adds polling backoff, delete tracking, and bounded waits.
internal/​clients/​compute/​compute_test.go Tests polling, persistence, and wait limits.
go.sum Updates dependency checksums.
go.mod Updates Go and dependency versions.
docs/​README.md Documents polling, throttling, and delete-wait flags.
docs/​CHANGELOG.md Records behavior and tooling changes.
cmd/​provider/​main.go Registers and validates the new flags.
.github/​workflows/​ci.yml Updates lint tooling and image ID lookup.
.github/​workflows/​ci-weekly.yml Updates image ID lookup for vulnerability scanning.
.github/​workflows/​cd.yml Updates image ID lookup for vulnerability scanning.

Review effort: Balanced

Comment on lines +130 to +131
datacenterID := datacenterIDFromPath(req.URL.Path)
requestKey := req.Method + " " + req.URL.Path
dvlad-ionos
dvlad-ionos previously approved these changes Nov 20, 2026

@dvlad-ionos dvlad-ionos left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcaratas-ionos
mcaratas-ionos marked this pull request as ready for review November 25, 2026 09:10
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.

3 participants