Skip to content

Conversation

dashashutosh80
Copy link

@dashashutosh80 dashashutosh80 commented Jul 27, 2025

What this PR does / why we need it:

This PR fixes the pod network partition experiment by removing redundant target pod selection logic and simplifying the network policy creation. The experiment was using both TARGETS and POD_SELECTOR/NAMESPACE_SELECTOR for target selection, but only the latter were actually used in network policy creation. Network Partition experiment differs from other chaos experiments as over here, the chaos isn't injected into any workloads. A NetworkPolicy is created to implement this chaos. Hence, usage of functions to fetch list of target pods or environment variables specifying pod names is redundant particularly when we provide POD_SELECTOR/NAMESPACE_SELECTOR which is used to filter targets for ingress/egress rules and APP_LABEL for workload selector on which NP will be applied.

Which issue this PR fixes : fixes #751

Checklist:

  • Fixes Chaos injection fails for pod-network-partition experiment #751
  • 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

Changes Made

  1. Target Selection:

    • Removed redundant target pod selection using TARGETS env var
    • Network policy is now created solely based on POD_SELECTOR and NAMESPACE_SELECTOR
    • Improved error messages to clearly indicate required selectors
  2. Code Cleanup and Improvements:

    • Removed unused fields and environment variables
    • Fixed variable naming conventions
    • Added descriptive comments for environment variables
    • Simplified status tracking to use network policy instead of individual pods
    • Rectified function name spelling
    • Removed unused environment variable fields from experiment
    • Handle cases for both names and labels to get target pods when TARGET_PODS env is not set but TARGETS is
  3. Documentation:

    • Added clear comments explaining the purpose of each selector
    • Fixed variable names to follow Go conventions

Environment Variables Used

  • POD_SELECTOR: Pod selector for network policy ingress/egress rules
  • NAMESPACE_SELECTOR: Namespace selector for network policy ingress/egress rules
  • APP_LABEL: Target pod labels for network partition
  • POLICY_TYPES: Type of network policy (ingress/egress/all)
  • PORTS: Ports to be used for network partition

Testing Done

  • Verified network policy creation with pod selector
  • Verified network policy creation with namespace selector
  • Verified network policy creation with both selectors
  • Verified error handling when no selectors are provided

Signed-off-by: dashashutosh80 <dashashutosh80@gmail.com>
@dashashutosh80 dashashutosh80 force-pushed the fix/pod-network-partition-target-selection branch from 9d98004 to 2ba5c4e Compare July 27, 2025 16:36
@dashashutosh80
Copy link
Author

@neelanjan00 / @uditgaurav Please let me know your inputs on this. TIA!

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.

Chaos injection fails for pod-network-partition experiment

1 participant