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

trigger endpoint update on pod deletion #54828

Merged

Conversation

freehan
Copy link
Contributor

@freehan freehan commented Oct 31, 2017

Fixes #54723

cc: @joelsmith

Fix a bug where pod address is not removed from endpoints object while pod is in graceful termination.

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 31, 2017
@joelsmith
Copy link
Contributor

Good catch!

/assign
/retest

@joelsmith
Copy link
Contributor

joelsmith commented Oct 31, 2017

This is a good change. I'd like to see a unit test so that we protect against future regressions. Something like this, perhaps:

diff --git a/pkg/controller/endpoint/endpoints_controller_test.go b/pkg/controller/endpoint/endpoints_controller_test.go
--- a/pkg/controller/endpoint/endpoints_controller_test.go
+++ b/pkg/controller/endpoint/endpoints_controller_test.go
@@ -1039,6 +1039,13 @@ func TestPodChanged(t *testing.T) {
 		t.Errorf("Expected pod to be changed with pod readiness change")
 	}
 	oldPod.Status.Conditions = saveConditions
+
+	now := metav1.NewTime(time.Now().UTC())
+	newPod.ObjectMeta.DeletionTimestamp = &now
+	if !podChanged(oldPod, newPod) {
+		t.Errorf("Expected pod to be changed with DeletionTimestamp change")
+	}
+	newPod.ObjectMeta.DeletionTimestamp = oldPod.ObjectMeta.DeletionTimestamp.DeepCopy()
 }
 
 func TestDetermineNeededServiceUpdates(t *testing.T) {

@yujuhong
Copy link
Contributor

Should this be cherry-picked to 1.8?

@joelsmith
Copy link
Contributor

@yujuhong yes, it should. @derekwaynecarr or anybody else with rights to do so who happens across this PR, could you please add the cherry-pick-candidate label and the 1.8 milestone?

@freehan freehan added this to the v1.8 milestone Oct 31, 2017
@freehan freehan force-pushed the endpoint-controller-fix branch from 544eab5 to 5f4145f Compare October 31, 2017 17:59
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 31, 2017
@freehan
Copy link
Contributor Author

freehan commented Oct 31, 2017

Added unit test

@joelsmith
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 31, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: freehan, joelsmith
We suggest the following additional approver: deads2k

Assign the PR to them by writing /assign @deads2k in a comment when ready.

Associated issue: 54723

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@yujuhong
Copy link
Contributor

@freehan need to add release note for cherrypicks.

@k8s-ci-robot
Copy link
Contributor

@freehan: Adding do-not-merge/release-note-label-needed because the release note process has not been followed.

One of the following labels is required "release-note", "release-note-action-required", or "release-note-none".
Please see: https://github.com/kubernetes/community/blob/master/contributors/devel/pull-requests.md#write-release-notes-if-needed.

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 do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Oct 31, 2017
@jpbetz jpbetz added cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed cherrypick-candidate labels Oct 31, 2017
@jpbetz
Copy link
Contributor

jpbetz commented Oct 31, 2017

@freehan please add release note or release-note-none label as appropriate.

@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 Oct 31, 2017
@joelsmith
Copy link
Contributor

Why have the tests still not run? Was the bot asleep when the code was updated?
/retest

@joelsmith
Copy link
Contributor

/test pull-kubernetes-unit

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

@freehan
Copy link
Contributor Author

freehan commented Nov 1, 2017

/test pull-kubernetes-e2e-kops-aws

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

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 54894, 54630, 54828, 54926, 54865). If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit 27448b4 into kubernetes:master Nov 2, 2017
openshift-merge-robot added a commit to openshift/origin that referenced this pull request Nov 2, 2017
Automatic merge from submit-queue (batch tested with PRs 17089, 17120).

UPSTREAM: 54828: trigger endpoint update on pod deletion

xref kubernetes/kubernetes#54828
k8s-github-robot pushed a commit that referenced this pull request Nov 4, 2017
…8-upstream-release-1.8

Automatic merge from submit-queue.

Automated cherry pick of #54828

Cherry pick of #54828 on release-1.8.

#54828: trigger endpoint update on pod deletion
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. cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. 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/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants