Skip to content

Conversation

@fmoehler
Copy link
Contributor

@fmoehler fmoehler commented Oct 22, 2025

What is this change about?

We have to clear duplicate ip address with a smaller prefix in the addresses we cant allocate during dynamic ip allocation.

Please provide contextual information.

In the context of introducing prefix delegation for the bosh director we refactored the way restricted_ips are handled in the code. Instead of having single ips as an array we switched to having the biggest cidr ranges possible. This would solve a bug where the bosh director would become unresponsive (out of memory) if the number of ip addresses exceeded a certain limit, especially relevant for ipv6 use cases where ranges get very big very easily.

E.g. a /80 network contains 281,474,976,710,656 (approximately 281.5 trillion) addresses. Previously this would result in an array with the same amount of elements. With the change it could be as low as only 1.

However this leads to issues when existing addresses randomly match one of the restricted ips cidr range, because in the code we delete all ip addresses below the current ip we are trying to allocate not paying attention to the cidr range.

This can result in the error:

Failed to reserve IP '10.0.72.2/32' for network 'diego-cells': IP belongs to reserved range

What tests have you run against this PR?

Unit tests

How should this change be described in bosh release notes?

Fix for "Failed to reserve IP 'xxx' for network 'xxx': IP belongs to reserved range"

Does this PR introduce a breaking change?

no

Tag your pair, your PM, and/or team!

@dudejas

a-hassanin
a-hassanin previously approved these changes Oct 23, 2025
Copy link
Contributor

@a-hassanin a-hassanin left a comment

Choose a reason for hiding this comment

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

LGTM

@github-project-automation github-project-automation bot moved this from Inbox to Pending Merge | Prioritized in Foundational Infrastructure Working Group Oct 23, 2025
@rkoster rkoster requested a review from Copilot October 23, 2025 15:04
Copy link
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 fixes a bug in dynamic IP allocation where existing IP addresses could incorrectly match restricted IP CIDR ranges, causing "IP belongs to reserved range" errors. The fix removes duplicate IP addresses with smaller prefixes from the list of addresses that cannot be allocated, ensuring only the largest CIDR ranges are considered.

Key Changes:

  • Added deduplication logic to remove IP addresses with smaller prefixes when they're contained within larger CIDR ranges
  • Added test coverage for the scenario where existing IPs overlap with restricted IPs

Reviewed Changes

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

File Description
src/bosh-director/lib/bosh/director/deployment_plan/ip_provider/ip_repo.rb Implements deduplication logic to filter out IP addresses with smaller prefixes when contained in larger CIDR ranges
src/bosh-director/spec/unit/bosh/director/deployment_plan/ip_provider/ip_repo_spec.rb Adds test case verifying that duplicate IPs with smaller prefixes are properly handled during allocation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

aramprice
aramprice previously approved these changes Oct 23, 2025
@fmoehler fmoehler merged commit e60874e into main Oct 23, 2025
28 of 31 checks passed
@github-project-automation github-project-automation bot moved this from Pending Merge | Prioritized to Done in Foundational Infrastructure Working Group Oct 23, 2025
@a-hassanin a-hassanin deleted the remove-addresses-we-cant-allocate branch October 24, 2025 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants