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

endpoints and endpointslices should not publish IPs for terminal pods #110115

Closed
wants to merge 5 commits into from

Conversation

aojea
Copy link
Member

@aojea aojea commented May 18, 2022

Since 1.22 the pod phase lifecycle guarantees that terminal pods, those whose states are Unready or Succeeded , can not regress and will have all container stopped. Hence, terminal PodIPs will never been able to be reachable and should not be published on the endpoints or endpoints slices, independently of the TolerateUnready option

/kind bug

The pod phase lifecycle guarantees that terminal Pods, those whose states are Unready or Succeeded, can not regress and will have all container stopped. Hence, terminal Pods will never be reachable and should not publish their IP addresses on the Endpoints or EndpointSlices, independently of the Service TolerateUnready option.

Fixes: #109414, #109718

@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. 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. kind/bug Categorizes issue or PR as related to a bug. 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. labels May 18, 2022
@k8s-ci-robot
Copy link
Contributor

@aojea: This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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 needs-priority Indicates a PR lacks a `priority/foo` label and requires one. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/network Categorizes an issue or PR as relevant to SIG Network. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels May 18, 2022
@aojea
Copy link
Member Author

aojea commented May 18, 2022

/assign @thockin @robscott @smarterclayton

WIP to add e2e test that covers regressions, since is a considerable change in behavior,

@aojea aojea changed the title [WIP] endpoints and endpointslices doesn't publish IPs for terminal pods [WIP] endpoints and endpointslices don't publish IPs for terminal pods May 21, 2022
@aojea aojea force-pushed the pods_ips_eviction branch 2 times, most recently from 559d5e2 to d4f3cdd Compare May 22, 2022 10:40
@aojea aojea marked this pull request as draft May 22, 2022 11:58
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 22, 2022
@aojea aojea marked this pull request as ready for review May 22, 2022 14:07
@aojea aojea changed the title [WIP] endpoints and endpointslices don't publish IPs for terminal pods endpoints and endpointslices don't publish IPs for terminal pods May 22, 2022
@k8s-ci-robot k8s-ci-robot added area/test and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels May 22, 2022
@aojea
Copy link
Member Author

aojea commented May 26, 2022

addressed comments, please review

Copy link
Member

@robscott robscott 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 good to me other than a few nits, thanks @aojea!

pkg/api/v1/pod/util.go Outdated Show resolved Hide resolved
Comment on lines 419 to 421
// tolerateUnreadyEndpoints is equal to service.Spec.PublishNotReadyAddresses only, the
// the difference with the endpointSlices controller, is that the later may consider terminating
// endpoints too. Ref: features.EndpointSliceTerminatingCondition
Copy link
Member

Choose a reason for hiding this comment

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

Instead of this comment, we could just use service.Spec.PublishNotReadyAddresses directly.

pkg/controller/util/endpoint/controller_utils_test.go Outdated Show resolved Hide resolved
pkg/api/v1/pod/util.go Outdated Show resolved Hide resolved
aojea added 5 commits May 27, 2022 06:42
pods on phase succeeded or failed are guaranteed to have all containers
stopped and to not ever regress
Terminal pods, whose phase its Failed or Succeeded, are guaranteed
to never regress and to be stopped, so their IPs never should
be published on the Endpoints.
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: aojea
To complete the pull request process, please ask for approval from smarterclayton after the PR has been reviewed.

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

Copy link
Member

@robscott robscott left a comment

Choose a reason for hiding this comment

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

I think this is the final round of review for me, other than these last two nits, I think this is good to go. Want @thockin to take a look though to be sure.

/assign @thockin

pkg/api/v1/pod/util.go Show resolved Hide resolved
@@ -135,9 +135,15 @@ func DeepHashObjectToString(objectToWrite interface{}) string {
return hex.EncodeToString(hasher.Sum(nil)[0:])
}

// ShouldPodBeInEndpointSlice returns true if a specified pod should be in an EndpointSlice object.
// ShouldPodBeInEndpointSlice returns true if a specified pod should be in an Endpoint or EndpointSlice object.
// Terminating pods are only included if includeTerminating is true
func ShouldPodBeInEndpointSlice(pod *v1.Pod, includeTerminating bool) bool {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe Endpoints is a better term here due to being shorter and more clearly applying to both Endpoints and EndpointSlices (EndpointSlices contain an "Endpoints" list)

Suggested change
func ShouldPodBeInEndpointSlice(pod *v1.Pod, includeTerminating bool) bool {
func ShouldPodBeInEndpoints(pod *v1.Pod, includeTerminating bool) bool {

Copy link
Member

Choose a reason for hiding this comment

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

Agree, but it's minor

@robscott
Copy link
Member

I can't approve anything more than @aojea already has here, but the bits in the Endpoint(Slice) controllers look right to me. Will defer to @smarterclayton and/or @thockin for the rest.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 27, 2022
Copy link
Member

@thockin thockin left a comment

Choose a reason for hiding this comment

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

Overall I am good with this, just small things

pkg/api/v1/pod/util.go Show resolved Hide resolved
pkg/api/v1/pod/util.go Show resolved Hide resolved
@@ -135,9 +135,15 @@ func DeepHashObjectToString(objectToWrite interface{}) string {
return hex.EncodeToString(hasher.Sum(nil)[0:])
}

// ShouldPodBeInEndpointSlice returns true if a specified pod should be in an EndpointSlice object.
// ShouldPodBeInEndpointSlice returns true if a specified pod should be in an Endpoint or EndpointSlice object.
// Terminating pods are only included if includeTerminating is true
func ShouldPodBeInEndpointSlice(pod *v1.Pod, includeTerminating bool) bool {
Copy link
Member

Choose a reason for hiding this comment

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

Agree, but it's minor

@@ -146,14 +149,6 @@ func ShouldPodBeInEndpointSlice(pod *v1.Pod, includeTerminating bool) bool {
return false
}

if pod.Spec.RestartPolicy == v1.RestartPolicyNever {
Copy link
Member

Choose a reason for hiding this comment

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

We've always tried to avoid describing overly-rigid state-machines because they make terrible APIs, but it seems reasonable that we clearly document SOMETHING here. There are non-terminal and terminal phases (states) and we should be clear about it.

cmd := fmt.Sprintf("/agnhost connect --timeout=3s %s", serviceAddress)

ginkgo.By(fmt.Sprintf("hitting service %v from pod %v on node %v expected to be refused", serviceAddress, podName, nodeName))
expectedErr := "REFUSED"
Copy link
Member

Choose a reason for hiding this comment

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

Is it better to probe the service and get refused, or just to look at the Endpoints & EPSlice resources?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe both? What if we start by looking at Endpoints/EPS resources and if those both look right, continue on to the probe?

Copy link
Member Author

Choose a reason for hiding this comment

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

for e2e I always try to test the whole system and all the elements involved, we may have a bug in kube-proxy ... we can add an integration test for testing endpoints only

Copy link
Member

Choose a reason for hiding this comment

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

Since we already have an e2e test, can we just use that for both? I think it would be really helpful to know why the e2e test failed if it did. Just seeing the lack of a "REFUSED" response would require further debugging to understand why that happened.

Copy link
Member Author

Choose a reason for hiding this comment

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

ahh, got it , you mean in addition and I understood "instea of", you are right

@aojea
Copy link
Member Author

aojea commented May 27, 2022

superseded by #110255

Thanks Rob for bringing it to the finish line

/close

@k8s-ci-robot
Copy link
Contributor

@aojea: Closed this PR.

In response to this:

superseded by #110255

Thanks Rob for bringing it to the finish line

/close

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.

SIG Node CI/Test Board automation moved this from PRs - Needs Approver to Done May 27, 2022
SIG Node PR Triage automation moved this from Needs Approver to Done May 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubelet 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. 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. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/network Categorizes an issue or PR as relevant to SIG Network. sig/node Categorizes an issue or PR as relevant to SIG Node. 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.
Development

Successfully merging this pull request may close these issues.

Pods with failed status IP address reused on new pods, but traffic still going to old pods across namespaces.
7 participants