Skip to content

Claims surface failure reasons in status rather than HTTP errors#28

Open
scotwells wants to merge 1 commit into
ippool-ipclaim-ipallocationfrom
async-compatible-e2e-tests
Open

Claims surface failure reasons in status rather than HTTP errors#28
scotwells wants to merge 1 commit into
ippool-ipclaim-ipallocationfrom
async-compatible-e2e-tests

Conversation

@scotwells
Copy link
Copy Markdown
Contributor

What this does

When a claim can't be satisfied — because a pool is full, no pool matches a selector, or the requested size exceeds the pool's limits — the claim is now saved with a clear failure reason in its status rather than being rejected outright.

Before this change, a failed claim attempt left no record: the request was rejected and the caller had to interpret the error message to understand why. Now the claim object exists and its status tells the full story:

status:
  conditions:
    - type: Allocated
      status: "False"
      reason: PoolExhausted
      message: "no available block of size /24 in pool us-east-consumer-ipv4"

Callers can check status.conditions to see whether their claim succeeded or failed and why, without any special error handling.

Why it matters

This change is foundational for the federated edge model described in #27. In that model, allocations happen asynchronously on edge clusters via a reconciler rather than synchronously at request time. Both paths now converge on the same outcome: a claim object with a status condition that reflects what happened.

The test suite has been updated to match — tests now assert on final claim state rather than on whether the HTTP request succeeded or failed. This means the same tests run against both the current implementation and future edge deployments.

Test plan

  • All 9 e2e suites pass on a live kind cluster
  • Pool exhaustion, out-of-bounds prefix length, and no-selector-match cases all produce Allocated=False claims with typed reason codes
  • Successful claims are unchanged — Allocated=True with allocatedCIDR set synchronously in the response

🤖 Generated with Claude Code

…or async allocation

When a claim cannot be satisfied (pool exhausted, no matching pool, prefix
length out of bounds), the claim is now persisted with an Allocated=False
condition rather than returning a transport-level error. Callers can observe
the failure reason from status.conditions without special error handling.

This prepares the service for federated edge deployments where allocation
happens asynchronously via a reconciler rather than synchronously in the
request path — both models converge on the same final resource state.

E2e tests updated to assert on final resource state (status conditions and
capacity fields) rather than HTTP response codes, making the suite runnable
against both the current hub implementation and future edge deployments.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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