close
Skip to content

IPAM: try to reclaim empty IPAM blocks if pool is empty#11149

Merged
fasaxc merged 8 commits into
projectcalico:masterfrom
fasaxc:ipam-reclaim
Oct 21, 2025
Merged

IPAM: try to reclaim empty IPAM blocks if pool is empty#11149
fasaxc merged 8 commits into
projectcalico:masterfrom
fasaxc:ipam-reclaim

Conversation

@fasaxc
Copy link
Copy Markdown
Member

@fasaxc fasaxc commented Oct 8, 2025

Description

Fixes a corner case for special-purpose block-size-/32 pools where all the blocks are "stranded" on nodes that don't need them.

Related issues/PRs

CORE-11223

Todos

  • Tests
  • Documentation
  • Release note

Release Note

IPAM: when a pool is full, try to reclaim empty blocks from other nodes before giving up. Helps the most with special-purpose block-size-/32 pools; prevents blocks from getting stranded on nodes that can't use them. 

Reminder for the reviewer

Make sure that this PR has the correct labels and milestone set.

Every PR needs one docs-* label.

  • docs-pr-required: This change requires a change to the documentation that has not been completed yet.
  • docs-completed: This change has all necessary documentation completed.
  • docs-not-required: This change has no user-facing impact and requires no docs.

Every PR needs one release-note-* label.

  • release-note-required: This PR has user-facing changes. Most PRs should have this label.
  • release-note-not-required: This PR has no user-facing changes.

Other optional labels:

  • cherry-pick-candidate: This PR should be cherry-picked to an earlier release. For bug fixes only.
  • needs-operator-pr: This PR is related to install and requires a corresponding change to the operator.

@marvin-tigera marvin-tigera added this to the Calico v3.32.0 milestone Oct 8, 2025
@marvin-tigera marvin-tigera added release-note-required Change has user-facing impact (no matter how small) docs-pr-required Change is not yet documented labels Oct 8, 2025
Fixes a corner case for special-purpose block-size-/32 pools where
all the blocks are "stranded" on nodes that don't need them.
Add timestamp on claim and avoid reclaiming a block that's less than
1min old.
@fasaxc fasaxc added docs-not-required Docs not required for this change and removed docs-pr-required Change is not yet documented labels Oct 9, 2025
@fasaxc fasaxc marked this pull request as ready for review October 9, 2025 14:12
@fasaxc fasaxc requested a review from a team as a code owner October 9, 2025 14:12
Copilot AI review requested due to automatic review settings October 9, 2025 14:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a mechanism to reclaim empty IPAM blocks from other nodes when a pool is full, specifically targeting corner cases in special-purpose block-size-/32 pools where blocks become "stranded" on nodes that don't need them.

Key changes:

  • Adds AffinityClaimTime field to IPAM blocks to track when affinity was claimed
  • Implements block reclamation logic that attempts to free empty blocks from other nodes when no free blocks are available
  • Updates block release logic to clear the claim time when affinity is removed

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Multiple CRD manifests Add affinityClaimTime field to IPAM block schema definitions
libcalico-go/lib/backend/model/block.go Add AffinityClaimTime field to AllocationBlock struct
libcalico-go/lib/apis/v3/ipam_block.go Add AffinityClaimTime field to IPAMBlockSpec
libcalico-go/lib/ipam/ipam_block_reader_writer.go Implement block reclamation logic and update affinity release methods
libcalico-go/lib/ipam/ipam_block.go Add helper method to extract affinity claim time
libcalico-go/lib/ipam/ipam.go Update all calls to releaseBlockAffinity with new signature
Test files Add comprehensive tests for block reclamation functionality

Comment thread libcalico-go/lib/ipam/ipam_block_reader_writer_test.go
Comment thread libcalico-go/lib/ipam/ipam_block_reader_writer_test.go Outdated
Comment thread libcalico-go/lib/ipam/ipam_block_reader_writer.go Outdated
Comment thread libcalico-go/lib/ipam/ipam_block_reader_writer.go Outdated
Comment thread libcalico-go/lib/ipam/ipam_block_reader_writer.go Outdated
Comment thread libcalico-go/lib/ipam/ipam_block_reader_writer.go
Comment thread libcalico-go/lib/backend/model/block.go
@fasaxc
Copy link
Copy Markdown
Member Author

fasaxc commented Oct 13, 2025

Seeing failures in kube-controllers. Pushed some extra diags to see if it's anything to do with my change.

@fasaxc fasaxc force-pushed the ipam-reclaim branch 2 times, most recently from 73745d4 to c8faa51 Compare October 14, 2025 14:22
@fasaxc
Copy link
Copy Markdown
Member Author

fasaxc commented Oct 20, 2025

Passed on a rerun, I moved the extra diags to #11184, which is now merged.

@fasaxc fasaxc merged commit 41d469b into projectcalico:master Oct 21, 2025
2 of 3 checks passed
fasaxc added a commit to fasaxc/docs that referenced this pull request Oct 24, 2025
- /31 pools rely on IP borrowing, which is a global setting that may be
  disabled for other reasons.
- As of projectcalico/calico#11149 the IPAM logic can reclaim /32 blocks
  from other nodes once they are empty avoiding problems with blocks
  getting stranded on the wrong node.
ctauchen pushed a commit to tigera/docs that referenced this pull request Oct 29, 2025
- /31 pools rely on IP borrowing, which is a global setting that may be
  disabled for other reasons.
- As of projectcalico/calico#11149 the IPAM logic can reclaim /32 blocks
  from other nodes once they are empty avoiding problems with blocks
  getting stranded on the wrong node.
sabags pushed a commit to sabags/calico that referenced this pull request Dec 1, 2025
…o#11149)

* IPAM: try to reclaim empty IPAM blocks if pool is empty

Fixes a corner case for special-purpose block-size-/32 pools where
all the blocks are "stranded" on nodes that don't need them.

* Avoid reclaiming just-claimed blocks.

Add timestamp on claim and avoid reclaiming a block that's less than
1min old.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-not-required Docs not required for this change release-note-required Change has user-facing impact (no matter how small)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants