Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.1.6 api review #235

Open
wants to merge 1 commit into
base: release-v0.1.1
Choose a base branch
from

Conversation

astoycos
Copy link
Member

@astoycos astoycos commented Jun 18, 2024

What type of PR is this?
/kind api-change

What this PR does / why we need it:
This PR is a diff of /apis from v0.1.6 (main branch) to v0.1.1 (release-v0.1.1 branch).

Note: This PR is purely to facilitate review, it is not intended to merge.

Note2: This does not include FQDN support from from @rahulkjoshi in #233, which will come in our next 0.2.0 release

@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 18, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: astoycos

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 18, 2024
@shaneutt
Copy link
Member

/cc

@aojea
Copy link
Contributor

aojea commented Jun 27, 2024

/assign @danwinship @thockin @aojea

Signed-off-by: astoycos <astoycos@redhat.com>
@astoycos astoycos changed the title v0.1.6 api review v0.2.0 api review Jul 2, 2024
@astoycos astoycos changed the title v0.2.0 api review v0.1.6 api review Jul 2, 2024
@astoycos astoycos marked this pull request as ready for review July 2, 2024 16:21
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 2, 2024
@k8s-ci-robot
Copy link
Contributor

@astoycos: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-network-policy-api-crd-e2e 65d12fe link true /test pull-network-policy-api-crd-e2e

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

Comment on lines +65 to +66
// implementation can apply any of the matching policies to the connection, and
// there is no way for the user to reliably determine which one it will choose.
Copy link
Contributor

Choose a reason for hiding this comment

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

There are some implementations that are able to do this deterministically, I did it sorting by name here https://github.com/kubernetes-sigs/kube-network-policies/blob/db089bc6ed6c17a654ef0ea3f3a93d9122041c4e/pkg/networkpolicy/networkpolicyapi.go#L189-L196

I think we can guide users, and say that from the API point of view is difficult to define the exact behavior as it may depend on implementation details, but they should refer to the project implementing this API to understand what is the expected behavior

Copy link
Contributor

Choose a reason for hiding this comment

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

This was hashed out in #216 and #229.

Individual implementations may do something deterministic, but they are not required to. The point of the explanation here is that if you want an "expected behavior", then you have to avoid having two ANPs with the same priority that both match the same packet. (But also, if you do have two ANPs with the same priority that both match the same packet, the "undefined-ness" is much more restricted than it was before; the implementation must obey one of the matching policies. It can't just "always deny", or ignore both policies, etc.)

Copy link
Contributor

Choose a reason for hiding this comment

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

I was trying to point out that we can guide the users to ask their implementations about the behaviors, the way is worded now seems that "is impossible to know", when it really means "it is impossible to define a general behavior, but implementations may have a deterministic one"

Copy link
Contributor

Choose a reason for hiding this comment

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

What it really means is "don't do that".

The only scenario that is not well-defined is when you have two ANPs at the same priority that attempt to take different actions on the same packet. No matter what the implementation does, it will fail to obey the administrator's intent, because the administrator has requested that it do two contradictory things. Don't do that. Don't ask which policy it's actually going to use in that case, just fix your policies.

Copy link
Contributor

@aojea aojea Jul 18, 2024

Choose a reason for hiding this comment

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

as a developer is clear, but as a user you can do it if the implementation you are using is deterministic

@@ -130,11 +162,16 @@ type AdminNetworkPolicyIngressRule struct {
// AdminNetworkPolicyEgressRule describes an action to take on a particular
// set of traffic originating from pods selected by a AdminNetworkPolicy's
// Subject field.
// <network-policy-api:experimental:validation>
// +kubebuilder:validation:XValidation:rule="!(self.to.exists(peer, has(peer.networks) || has(peer.nodes)) && has(self.ports) && self.ports.exists(port, has(port.namedPort)))",message="networks/nodes peer cannot be set with namedPorts since there are no namedPorts for networks/nodes"
Copy link
Contributor

Choose a reason for hiding this comment

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

@thockin I think that you mention this to me at one point, about having a way to unit test or validate these expressions

//
// Support: Core
//
To []AdminNetworkPolicyEgressPeer `json:"to"`
Copy link
Contributor

Choose a reason for hiding this comment

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

why now the differentiation between Ingress and Egress?

Copy link
Contributor

Choose a reason for hiding this comment

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

The network selector was added to egress (egress controls by CIDR block). We didn't include Ingress yet due to the difficulties reliably determining the source IP of ingress traffic.

https://network-policy-api.sigs.k8s.io/npeps/npep-126-egress-traffic-control/#non-goals

// To be selected a Namespace must have all of the labels defined in SameLabels,
// AND they must all have the same value as the subject of this policy.
// If Samelabels is Empty then nothing is selected.
Namespaces *metav1.LabelSelector `json:"namespaces,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

much simpler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants