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

refactor netpol/policies.go #99696

Merged
merged 1 commit into from
Apr 14, 2021

Conversation

JornShen
Copy link
Member

@JornShen JornShen commented Mar 3, 2021

/kind cleanup

cut down 400+ COL

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/test sig/network Categorizes an issue or PR as relevant to SIG Network. sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Mar 3, 2021
@JornShen
Copy link
Member Author

JornShen commented Mar 3, 2021

/cc @jayunit100 @knabben

Copy link
Contributor

@mattfenwick mattfenwick left a comment

Choose a reason for hiding this comment

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

👍 👍 this looks awesome, I'm excited about it and totally onboard! Left a couple comments, up to you to decide whether to action them or not!

Will wait to approve until @jayunit100 @knabben and @abhiraut have had a look!!

🎉 🎉

test/e2e/network/netpol/policies.go Outdated Show resolved Hide resolved
test/e2e/network/netpol/policies.go Show resolved Hide resolved
@mattfenwick
Copy link
Contributor

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Mar 3, 2021
@knabben
Copy link
Member

knabben commented Mar 3, 2021

@JornShen these testes are running on pull-kubernetes-e2e-ubuntu-gce-network-policies, take a look in the results.

@knabben
Copy link
Member

knabben commented Mar 5, 2021

/retest

@JornShen
Copy link
Member Author

JornShen commented Mar 5, 2021

/cc @knabben

I remove all the Get function and use our new structured function to replace them. Most of Get funcs are call less 3 times even one time. New set func is flexible and enough to use. There is no neccessary for us to maintain these Get function, most of them are very Customized. And in genernal, using Set function, we can get a wanted network netpolicy less 4 COL. I dont think We need new function to gather them.

@knabben
Copy link
Member

knabben commented Mar 5, 2021

/retest

@jayunit100
Copy link
Member

@danwinship ^ are you ok with using ordering conventions to generate these policies?

@jayunit100
Copy link
Member

thanks Jorn , this does look cool... lets make sure other folks are ok w/ this refactor, the original KEP here has some history on this, we went back and forth on wether a DSL style approach would be valid but couldnt get consensus .... history here https://github.com/kubernetes/enhancements/tree/master/keps/sig-network/1611-network-policy-validation

@JornShen
Copy link
Member Author

JornShen commented Mar 6, 2021

/test pull-kubernetes-unit

@JornShen
Copy link
Member Author

JornShen commented Mar 6, 2021

@jayunit100 do you mean utils.NetworkPolicySpecBuilder in doc? IMO, the Builder is objective. Comparing with it, the way this MR also take the same effect. And In Go, I recommend we using Duck typing to implement which I have seen similar in many place.

@knabben
Copy link
Member

knabben commented Mar 7, 2021

waiting for @danwinship review on this one.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 7, 2021
@JornShen JornShen changed the title refector netpol/policies.go refactor netpol/policies.go Mar 10, 2021
@danwinship
Copy link
Contributor

@danwinship ^ are you ok with using ordering conventions to generate these policies?

sorry, belatedly noticing this. I haven't paid any attention to what actually got done here so you probably don't want me offering opinions on the code at this point or I'll want you to rewrite the whole thing 🙂

@knabben
Copy link
Member

knabben commented Apr 14, 2021

@danwinship ^ are you ok with using ordering conventions to generate these policies?

sorry, belatedly noticing this. I haven't paid any attention to what actually got done here so you probably don't want me offering opinions on the code at this point or I'll want you to rewrite the whole thing 🙂

so.. we had agreed this is a good refactor in the PR history (and the rewriting start :)

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JornShen, knabben

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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 14, 2021
@mattfenwick
Copy link
Contributor

/retest

2 similar comments
@mattfenwick
Copy link
Contributor

/retest

@knabben
Copy link
Member

knabben commented Apr 14, 2021

/retest

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@knabben
Copy link
Member

knabben commented Apr 14, 2021

/test pull-kubernetes-node-e2e

@k8s-ci-robot k8s-ci-robot merged commit e824c59 into kubernetes:master Apr 14, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.22 milestone Apr 14, 2021
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. area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/network Categorizes an issue or PR as relevant to SIG Network. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants