conformance: verify CNP ingress/egress directional isolation#386
Conversation
… Baseline) Adds dedicated conformance tests confirming a ClusterNetworkPolicy with rules in only one direction does not affect the subject's traffic in the other direction, for both Admin and Baseline tiers. See kubernetes-sigs#103. Signed-off-by: Vinay Pai <vinaypaibh@gmail.com>
|
@vpbh: The label(s) DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
✅ Deploy Preview for kubernetes-sigs-network-policy-api ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: vpbh The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @vpbh! |
|
Hi @vpbh. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
|
What type of PR is this?
/kind test
What this PR does / why we need it:
The existing
ClusterNetworkPolicyingress/egress rule conformance tests only probetraffic in the same direction as the rules under test — the ingress-rule tests probe
traffic toward the subject, the egress-rule tests probe traffic from the subject. They
never verify the API's directional-independence guarantee:
So an implementation with a cross-direction side-effect (e.g. one that treats "the
subject is selected by a policy" as "isolate the pod in both directions", the way plain
NetworkPolicy's
policyTypesworks) could pass the entire suite while silently breakingthe subject's traffic in the unspecified direction.
This PR closes that gap. For both the Admin and Baseline tiers it adds:
Each test first asserts a positive control (the one-directional rule is actually
enforced) so the isolation assertions are meaningful, then probes the opposite
direction to namespaces the policy does not reference.
New tests (all gated on the standard
ClusterNetworkPolicyfeature):CNPAdminTierIngressRulesEgressUnaffectedCNPAdminTierEgressRulesIngressUnaffectedCNPBaselineTierIngressRulesEgressUnaffectedCNPBaselineTierEgressRulesIngressUnaffectedWhich issue(s) this PR fixes:
Fixes #103
Special notes for your reviewer:
namespaces the policy never references — so the connection's reply path cannot be
affected by the rule under test and confound the result (e.g. a
deny-to-slytherinegress rule could affect the reply path of an inbound connection from slytherin on
a stateless dataplane). Using unreferenced peers isolates the property cleanly.
rather than appending probes to the existing
*-rules.gotests, because those testsmutate their policy mid-run (
PatchClusterNetworkPolicyrule-reordering), which wouldmake appended probes order-dependent. Happy to fold them into the existing files
instead if you'd prefer — the probe logic is identical.
UDP/SCTP variants if you'd like them.
Does this PR introduce a user-facing change?