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

Add --ipvs-exclude-cidrs flag to kube-proxy. #62083

Merged

Conversation

rramkumar1
Copy link
Contributor

@rramkumar1 rramkumar1 commented Apr 3, 2018

What this PR does / why we need it:
Add a flag to kube-proxy called --ipvs-exclude-cidrs. This flag allows a user to specify a list of CIDR ranges that should not be included in the cleanup of IPVS rules.

Fixes: #59507

Release note:

Use --ipvs-exclude-cidrs to specify a list of CIDR's which the IPVS proxier should not touch when cleaning up IPVS rules.

/assign @m1093782566

@k8s-ci-robot k8s-ci-robot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 3, 2018
for cs := range currentServices {
svc := currentServices[cs]
for _, excludedCidr := range proxier.excludeCIDRs {
_, net, err := net.ParseCIDR(excludedCidr)
Copy link
Contributor

Choose a reason for hiding this comment

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

bad naming of variable ... conflicts with imported package name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

}
// Only remove if the service VIP is not in the list of CIDR's to exclude
// and if it was not processed in the latest sync loop.
if net.Contains(svc.Address) && !activeServices[cs] {
Copy link
Contributor

Choose a reason for hiding this comment

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

net.Contains() or !net.Contains() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

@rramkumar1 rramkumar1 force-pushed the ipvs-exclude-cidrs-flag branch 2 times, most recently from fa7db76 to 22943bf Compare April 5, 2018 17:00
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 5, 2018
@rramkumar1 rramkumar1 force-pushed the ipvs-exclude-cidrs-flag branch 2 times, most recently from 95109c6 to 516b354 Compare April 5, 2018 17:06
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Apr 5, 2018
@rramkumar1 rramkumar1 changed the title Add --ipvs-exclude-cidrs flag to kube-proxy. [WIP] Add --ipvs-exclude-cidrs flag to kube-proxy. Apr 5, 2018
@rramkumar1
Copy link
Contributor Author

/assign @m1093782566

@rramkumar1
Copy link
Contributor Author

/cc @pires @GoelDeepak

@k8s-ci-robot k8s-ci-robot requested a review from pires April 5, 2018 20:40
@k8s-ci-robot
Copy link
Contributor

@rramkumar1: GitHub didn't allow me to request PR reviews from the following users: GoelDeepak.

Note that only kubernetes members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @pires @GoelDeepak

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/test-infra repository.

for i := range excludeCIDRs {
if _, _, err := net.ParseCIDR(excludeCIDRs[i]); err != nil {
allErrs = append(allErrs, field.Invalid(fldPath, excludeCIDRs, "must be a valid IP block"))
break
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be a good UX if all CIDRs were validated and all that are invalid were reported, instead of reporting the first invalid and breaking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

// make sure it does not fall within an excluded CIDR range.
okayToDelete := true
for _, excludedCIDR := range proxier.excludeCIDRs {
_, n, err := net.ParseCIDR(excludedCIDR)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we validating this again? Isn't it supposed to be validated during configuration check?

Copy link
Contributor

Choose a reason for hiding this comment

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

If we can't ignore the error here, then I'd say we can skip configuration validation completely and just have the validation happen here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The intent was not validation but rather to convert the string representation of the CIDR to net struct. I guess I could remove the error check since we know from the previous validation that no error is possible? Does that sound okay?

Copy link
Contributor

Choose a reason for hiding this comment

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

SGTM.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 9, 2018
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 9, 2018
allErrs := field.ErrorList{}

for i := range excludeCIDRs {
if _, _, err := net.ParseCIDR(excludeCIDRs[i]); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Single IP should be valid as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

Single IP as in x.x.x.x/32 is a valid CIDR.

@@ -2393,11 +2392,93 @@ func Test_syncService(t *testing.T) {
}
}

<<<<<<< HEAD
Copy link
Contributor

Choose a reason for hiding this comment

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

Ouch!

func buildFakeProxier(nodeIP []net.IP) (*iptablestest.FakeIPTables, *Proxier) {
ipt := iptablestest.NewFake()
ipvs := ipvstest.NewFake()
ipset := ipsettest.NewFake(testIPSetVersion)
return ipt, NewFakeProxier(ipt, ipvs, ipset, nil)
=======
Copy link
Contributor

Choose a reason for hiding this comment

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

Bad rebase :/

t.Errorf("Expected ipvs5 to be removed after cleanup. It still remains")
}
}
>>>>>>> Add --ipvs-exclude-cidrs flag to kube-proxy.
Copy link
Contributor

Choose a reason for hiding this comment

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

Again.

@rramkumar1
Copy link
Contributor Author

rramkumar1 commented Apr 9, 2018

@m1093782566 Seems like the test failures for pull-kubernetes-bazel-test are being caused by something I did not touch.

nodePortLocalSetUDP: NewIPSet(ipset, KubeNodePortLocalSetUDP, utilipset.BitmapPort, false),
nodePortSetUDP: NewIPSet(ipset, KubeNodePortSetUDP, utilipset.BitmapPort, false),
nodePortAddresses: make([]string, 0),
networkInterfacer: proxyutiltest.NewFakeNetwork(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did this change? Maybe this is where the test break comes from.

// make sure it does not fall within an excluded CIDR range.
okayToDelete := true
for _, excludedCIDR := range proxier.excludeCIDRs {
// Any validation of this CIDR already should have occured.
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that verify steps now include spellchecking.

W0409 19:58:08.458] pkg/proxy/ipvs/proxier.go:1474:55: "occured" is a misspelling of "occurred"
I0409 19:58:09.113] +++ exit code: 1
I0409 19:58:09.117] +++ error: 1
I0409 19:58:09.235] FAILED   verify-spelling.sh	4s

@rramkumar1 rramkumar1 force-pushed the ipvs-exclude-cidrs-flag branch 2 times, most recently from 4afe2b9 to b063079 Compare April 12, 2018 15:57
@rramkumar1
Copy link
Contributor Author

@pires Fixed the test failures. Any more comments on your end?

@rramkumar1
Copy link
Contributor Author

@m1093782566 Any comments?

@m1093782566
Copy link
Contributor

m1093782566 commented Apr 13, 2018

LGTM except one comment.

@@ -149,6 +149,7 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) {
fs.DurationVar(&o.config.IPTables.MinSyncPeriod.Duration, "iptables-min-sync-period", o.config.IPTables.MinSyncPeriod.Duration, "The minimum interval of how often the iptables rules can be refreshed as endpoints and services change (e.g. '5s', '1m', '2h22m').")
fs.DurationVar(&o.config.IPVS.SyncPeriod.Duration, "ipvs-sync-period", o.config.IPVS.SyncPeriod.Duration, "The maximum interval of how often ipvs rules are refreshed (e.g. '5s', '1m', '2h22m'). Must be greater than 0.")
fs.DurationVar(&o.config.IPVS.MinSyncPeriod.Duration, "ipvs-min-sync-period", o.config.IPVS.MinSyncPeriod.Duration, "The minimum interval of how often the ipvs rules can be refreshed as endpoints and services change (e.g. '5s', '1m', '2h22m').")
fs.StringSliceVar(&o.config.IPVS.ExcludeCIDRs, "ipvs-exclude-cidrs", o.config.IPVS.ExcludeCIDRs, "A list of CIDR's which the ipvs proxier should not touch when cleaning up IPVS rules.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is that a comma separated list? Comment, please.

@pires
Copy link
Contributor

pires commented Apr 13, 2018

LGTM as well but @m1093782566 comment is spot on.

@rramkumar1
Copy link
Contributor Author

Done.
/assign @thockin

@rramkumar1
Copy link
Contributor Author

/retest

@pires
Copy link
Contributor

pires commented Apr 15, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 15, 2018
@Lion-Wei
Copy link

/test pull-kubernetes-integration

@thockin
Copy link
Member

thockin commented Apr 24, 2018

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pires, rramkumar1, thockin

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 24, 2018
@rramkumar1
Copy link
Contributor Author

/test pull-kubernetes-integration

1 similar comment
@rramkumar1
Copy link
Contributor Author

/test pull-kubernetes-integration

@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@rramkumar1
Copy link
Contributor Author

/test pull-kubernetes-e2e-kops-aws

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit c0d1ab8 into kubernetes:master Apr 24, 2018
@voidengineer
Copy link

It would be great if this could be cherrypicked into v1.10.x.

@pires
Copy link
Contributor

pires commented Apr 27, 2018

This is a change in behavior, so I don't think that is possible.

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. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

None yet

9 participants