Skip to content

Conversation

@Prakhar-Shankar
Copy link
Contributor

Problem:
Earlier the program was adding "/32" to every destination IP be it CIDR or IPv6.

Solution:
Introduced normalizeIPOrCIDR() to validate and normalize IPs:

  • Plain IPv4 - /32
  • Plain IPv6 - /128
  • Valid CIDR - kept as-is
  • Explicit errors on invalid IP/CIDR inputs.

fixes #717

Note - I have also added a test file to check everything is working fine.

Checklist:

  • Fixes DESTINATION_IPS in network experiments don't support CIDR blocks #717
  • PR messages has document related information
  • Labelled this PR & related issue with breaking-changes tag
  • PR messages has breaking changes related information
  • Labelled this PR & related issue with requires-upgrade tag
  • PR messages has upgrade related information
  • Commit has unit tests
  • Commit has integration tests
  • E2E run Required for the changes

Signed-off-by: Prakhar-Shankar <[email protected]>
Signed-off-by: Prakhar-Shankar <[email protected]>
@neelanjan00 neelanjan00 requested a review from Copilot September 27, 2025 19:04
Copy link

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 adds support for CIDR blocks and IPv6 addresses in the pod network partition functionality. Previously, the system was incorrectly appending "/32" to all destination IPs regardless of their format.

  • Introduces normalizeIPOrCIDR() function to properly handle IPv4, IPv6, and CIDR formats
  • Replaces the previous IP processing logic with proper validation and normalization
  • Adds comprehensive test coverage for the new functionality

Reviewed Changes

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

File Description
network-policy.go Implements new IP/CIDR normalization logic and refactors setExceptIPs method
network-policy_cidr_test.go Adds unit tests for CIDR handling and IP normalization functionality

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

@neelanjan00
Copy link
Member

Hey @Prakhar-Shankar thanks for the PR 🙏, can you please address the Copilot comments?

Signed-off-by: Prakhar-Shankar <[email protected]>
@Prakhar-Shankar
Copy link
Contributor Author

Prakhar-Shankar commented Sep 29, 2025

Hey @Prakhar-Shankar thanks for the PR 🙏, can you please address the Copilot comments?

Thanks for reviewing, I have changed the test file so that it won't take empty string as an error. I have also added the recommended comments.

Copy link
Member

@neelanjan00 neelanjan00 left a comment

Choose a reason for hiding this comment

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

LGTM.

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.

DESTINATION_IPS in network experiments don't support CIDR blocks

2 participants