fix(network): relax constraints for resizing dynamic range reservations - #280
fix(network): relax constraints for resizing dynamic range reservations#280bryanfraschetti wants to merge 6 commits into
Conversation
|
Check where you would like a Mattermost message to be sent to when CI completes and this PR is merged
|
735e40e to
fc872ef
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes validation for resizing existing dynamic IP ranges when there are already allocated IPs inside the current range, which previously caused the “Requested dynamic range conflicts…” error by treating the range as discontinuous.
Changes:
- Updates dynamic range overlap validation to permit resizing when only the newly-added segments are within unused space.
- Adds regression tests ensuring an existing dynamic range can shrink/expand even with an allocated IP inside the original range.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/maasserver/models/iprange.py |
Adjusts overlap/duplicate validation to allow certain dynamic-range resizes with in-range allocations. |
src/maasserver/models/tests/test_iprange.py |
Adds tests covering shrink/expand of an existing dynamic range when an IP inside it is allocated. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thanks for the fix. Implementation
TestingI ran additional cases on top of the PR tests, including the subnet-change guard. Expected to pass on resize:
All of the above passed. Expected to fail on resize:
All of the above were rejected as expected. |
|
Nice work on the caching and subnet guard! Could you rebase onto upstream master when you get a chance? Some of the tests were failing are fixed there now. On v3 side, the logic lives in src/maasapiserver/v3/api/public/models/requests/ipranges.py inside to_builder(), called from update_fabric_vlan_subnet_iprange() in the handler. Subnet move is less of an issue there since the URL pins the subnet, but the resize-with-lease-inside-pool bug will still show up. We can create a seperate PR for that. |
22860a9 to
34b548d
Compare
|
Thanks for the review! Good idea to add tests for the failure cases. I just rebased and added some tests to cover the ones you mentioned: resizing, moving, or creating dynamic ranges over a busy IP. I'll look into the v3 API and put up changes in a separate PR. Thank you for the pointers regarding that |
d1d5d25 to
638b2fa
Compare
|
lgtm. Thank you for the edits. Just one last test to make this concrete. |
|
@bryanfraschetti there are test failures |
…ns LP: #2143090 When an IP is allocated in a dynamic range reservation, the resize operation validator views the range as discontinuous and instead sees multiple contiguous blocks separated by each allocated IP. As a result, shrinking and expanding the reservation are both rejected with "Requested dynamic range conflicts with an existing IP address or range" despite the requested action being otherwise sensible (LP: #2143090) This commit addresses the issue by making sure the new boundaries are contained by an unused range
…ging Subnets Add tests to cover the expected failure of a resize over a busy IP, ensure that moving a dynamic range to a new subnet with a busy IP fails validation, and finally ensure that creation of a range over a busy IP is also disallowed
Head branch was pushed to by a user without write access
1fe7d0f to
df687ea
Compare
|
Thanks @r00ta! I fixed the failing tests by rebasing |
When an IP is allocated inside a dynamic range reservation, the validation performed during a resize sees the range as discontinuous, since an allocated IP splits the available space into separate contiguous blocks. As a result, both shrinking and expanding the reservation are rejected with "Requested dynamic range conflicts with an existing IP address or range", even when the requested change is otherwise valid.
This commit addresses the issue by comparing the requested range against the previously persisted range and requiring only the newly added segments (i.e., the expanded portions) to be contained within an unused range. Pure shrinks add no segments and are always allowed.
Resolves LP:2143090