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

Fix bug in apiserver service cidr split #85937

Closed
wants to merge 2 commits into from

Conversation

darshanime
Copy link
Contributor

@darshanime darshanime commented Dec 5, 2019

What type of PR is this?
/kind bug

What this PR does / why we need it:
Fix bug where kube-apiserver would fail to start when not providing service CIDR

Which issue(s) this PR fixes:
NA

Special notes for your reviewer:
The strings.Split documentation states:

// If s does not contain sep and sep is not empty, Split returns a
// slice of length 1 whose only element is s.

import (
	"fmt"
	"strings"
)

func main() {
	serviceClusterIPRanges := ""
	serviceClusterIPRangeList := strings.Split(serviceClusterIPRanges, ",")
	fmt.Printf("len: %d, value: %+v", len(serviceClusterIPRangeList), serviceClusterIPRangeList)

}

// Output
// len: 1, value: []

playground link

This would fail the if check here and apiserver wouldn't start. This PR fixes this bug.

Does this PR introduce a user-facing change?:
NA

Release note:

NONE

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 5, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @darshanime. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added area/apiserver sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Dec 5, 2019
@BenTheElder
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 5, 2019
@BenTheElder
Copy link
Member

/sig network

@k8s-ci-robot k8s-ci-robot added the sig/network Categorizes an issue or PR as relevant to SIG Network. label Dec 5, 2019
@BenTheElder
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 5, 2019
@aojea
Copy link
Member

aojea commented Dec 5, 2019

/assign @thockin @khenidak
/priority important-soon

@k8s-ci-robot k8s-ci-robot added priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Dec 5, 2019
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 5, 2019
@aojea
Copy link
Member

aojea commented Dec 5, 2019

thanks
/lgtm

@justaugustus
Copy link
Member

@darshanime -- This needs a release note.

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. 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 Dec 5, 2019
@liggitt
Copy link
Member

liggitt commented Dec 5, 2019

Also needs a test

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 5, 2019
@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@k8s-ci-robot k8s-ci-robot added area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Dec 5, 2019
Signed-off-by: darshanime <deathbullet@gmail.com>
@darshanime
Copy link
Contributor Author

@liggitt, I have removed the default ServiceClusterIPRanges from the testServer used thruout the codebase since it is deprecated.
Everything passes still, is this enough? Or should I write a separate test for the app.Complete func?

@liggitt
Copy link
Member

liggitt commented Dec 5, 2019

Don't change the integration test setup.

It would be better to have the ServiceClusterIPRanges -> serviceIP, serviceIPRange, secondaryServiceIPRange, error logic in a standalone function that could be unit tested easily, and then used like this in Complete():

apiServerServiceIP, serviceIPRange, secondaryServiceIPRange, err := getServiceIPAndRanges(s.ServiceClusterIPRanges)
if err != nil {
  return options, err
}
s.PrimaryServiceClusterIPRange = serviceIPRange
s.SecondaryServiceClusterIPRange = secondaryServiceIPRange

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 5, 2019
Signed-off-by: darshanime <deathbullet@gmail.com>
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: darshanime
To complete the pull request process, please assign liggitt
You can assign the PR to them by writing /assign @liggitt in a comment when ready.

The full list of commands accepted by this bot can be found 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

@darshanime
Copy link
Contributor Author

@liggitt thanks for the review. Please take a look now.

@liggitt
Copy link
Member

liggitt commented Dec 5, 2019

need to run hack/update-bazel.sh to pick up the new test file:

diff --git a/cmd/kube-apiserver/app/BUILD b/cmd/kube-apiserver/app/BUILD
index 66570c567e5..95162cf8760 100644
--- a/cmd/kube-apiserver/app/BUILD
+++ b/cmd/kube-apiserver/app/BUILD
@@ -1,4 +1,4 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
 
 go_library(
     name = "go_default_library",
@@ -99,3 +99,9 @@ filegroup(
     tags = ["automanaged"],
     visibility = ["//visibility:public"],
 )
+
+go_test(
+    name = "go_default_test",
+    srcs = ["server_test.go"],
+    embed = [":go_default_library"],
+)

lgtm otherwise, much better tested, thanks!

@@ -0,0 +1,56 @@
/*
Copyright 2018 The Kubernetes Authors.
Copy link
Member

Choose a reason for hiding this comment

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

2019 in new files

@k8s-ci-robot
Copy link
Contributor

@darshanime: The following tests failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-kubernetes-e2e-gce 2c64a45 link /test pull-kubernetes-e2e-gce
pull-kubernetes-verify 2c64a45 link /test pull-kubernetes-verify

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

@liggitt
Copy link
Member

liggitt commented Dec 5, 2019

comments resolved in #85968

@liggitt
Copy link
Member

liggitt commented Dec 5, 2019

/close
in favor of #85968

@k8s-ci-robot
Copy link
Contributor

@liggitt: Closed this PR.

In response to this:

/close
in favor of #85968

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.

@darshanime
Copy link
Contributor Author

Hi @liggitt, sorry I was asleep, it was already 1am IST here 😴
Thanks for reviewing this 🙏

@darshanime darshanime deleted the fix_bug_in_str_split branch May 7, 2020 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/apiserver area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. 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/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

8 participants