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

Closed
wants to merge 101 commits into 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

@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
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

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 16, 2024
@tssurya
Copy link
Contributor

tssurya commented Oct 21, 2024

@astoycos should I help with this? I know last time we spoke we wanted to setup a meeting with going through the PR and hashing out API changes?

@tssurya
Copy link
Contributor

tssurya commented Oct 21, 2024

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 21, 2024
Signed-off-by: astoycos <[email protected]>
@astoycos astoycos closed this Oct 29, 2024
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 29, 2024
@k8s-ci-robot
Copy link
Contributor

@astoycos: The following tests 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-verify b5ff96c link true /test pull-network-policy-api-verify
pull-network-policy-api-crd-e2e b5ff96c 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.

@astoycos
Copy link
Member Author

/reopen

@k8s-ci-robot
Copy link
Contributor

@astoycos: Failed to re-open PR: state cannot be changed. The review-v0.1.6 branch was force-pushed or recreated.

In response to this:

/reopen

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.

@astoycos
Copy link
Member Author

For some reason this won't let me re-open now 🤔

@astoycos
Copy link
Member Author

/reopen

@k8s-ci-robot
Copy link
Contributor

@astoycos: Failed to re-open PR: state cannot be changed. The review-v0.1.6 branch was force-pushed or recreated.

In response to this:

/reopen

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.

@astoycos astoycos mentioned this pull request Oct 29, 2024
@astoycos
Copy link
Member Author

Opened #260 to replace this 🤔 Unless someone can figure out how to re-open we can continue the discussion there

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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants