Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

matthyx
Copy link
Contributor

@matthyx matthyx commented Jan 29, 2021

What type of PR is this?
/kind bug

What this PR does / why we need it:
If a pod takes longer to delete than it's its health/readiness probe allow a user can get errors that the pods check is erroring even though the pod is being deleted. This can update the pods status field to be inaccurate.

Which issue(s) this PR fixes:

Fixes #52817

Special notes for your reviewer:
This PR reopens the work initiated by @ashleyschuett in #92385 which was abandoned partly because of my comments there. We still need to fix this situation.

I propose basically the same approach which is altering kubelet's worker working when DeletionTimestamp is set (indicating graceful shutdown initiated) to allow a quiet shutdown by setting safe probe results (depending on the type) before disabling probing.

Does this PR introduce a user-facing change?:

none

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. 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. 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/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jan 29, 2021
@matthyx
Copy link
Contributor Author

matthyx commented Jan 29, 2021

/cc @SergeyKanzhelev

@ehashman
Copy link
Member

/priority important-soon
/triage accept

@k8s-ci-robot
Copy link
Contributor

@ehashman: The label(s) triage/accept cannot be applied, because the repository doesn't have them

In response to this:

/priority important-soon
/triage accept

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 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 Jan 29, 2021
@ehashman
Copy link
Member

/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 Jan 29, 2021
Comment on lines 225 to 226
Copy link
Member

Choose a reason for hiding this comment

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

We don't need to do any container checking after we see the pod deletion timestamp is set so, in this case, should we not run this logic before we do any container checking? (i.e. move this addition above L191)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well I need to have a valid w.containerID to set the probe results, don't I?

Copy link
Member

Choose a reason for hiding this comment

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

Ahh yes sure. so maybe before the onHold check?

Copy link
Member

Choose a reason for hiding this comment

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

(I guess it doesn't really matter as much, this is nonblocking)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, in fact we probably have more often c.State.Running == nil than w.pod.ObjectMeta.DeletionTimestamp != nil.

Copy link
Member

Choose a reason for hiding this comment

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

I don't know if we actually need to set onHold. It's only used here:

But we're returning false so the worker for this probe will never run again anyways.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, I forgot the container won't probably restart if we asked for the pod to be deleted... removing it.

Copy link
Member

@ehashman ehashman left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 29, 2021
@ehashman
Copy link
Member

/retest

@SergeyKanzhelev
Copy link
Member

I propose basically the same approach which is altering kubelet's worker working when DeletionTimestamp is set (indicating graceful shutdown initiated) to allow a quiet shutdown by setting safe probe results (depending on the type) before disabling probing.

My question stays the same as for the initial PR. What is the safe defaults for the probes that work universally? Would one want to mark readiness probe as Failure for the duration of a termination if the termination is not suppose to accept any new requests? Or keep it as Success if pod is critical and the extended termination prestop hooks is used to delay the termination so other pods will shut down first.

@matthyx
Copy link
Contributor Author

matthyx commented Feb 2, 2021

What is the safe defaults for the probes that work universally?

Yeah, probably it is safer to let the application owner decide what to do with the readiness aspect.
I'm gonna override only liveness and startup then...

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

@ehashman ehashman left a comment

Choose a reason for hiding this comment

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

/lgtm

@matthyx
Copy link
Contributor Author

matthyx commented Feb 4, 2021

/assign @yujuhong

@mrunalp
Copy link
Contributor

mrunalp commented Feb 25, 2021

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: matthyx, mrunalp

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 Feb 25, 2021
@mrunalp
Copy link
Contributor

mrunalp commented Feb 25, 2021

/test pull-kubernetes-e2e-kind

@k8s-ci-robot k8s-ci-robot merged commit 27c89b9 into kubernetes:master Feb 25, 2021
k8s-ci-robot added a commit that referenced this pull request Apr 9, 2021
…71-upstream-release-1.18

Automated cherry pick of #98571: Stop probing a pod during graceful shutdown
k8s-ci-robot added a commit that referenced this pull request Apr 9, 2021
…71-upstream-release-1.19

Automated cherry pick of #98571: Stop probing a pod during graceful shutdown
k8s-ci-robot added a commit that referenced this pull request Apr 9, 2021
…71-upstream-release-1.20

Automated cherry pick of #98571: Stop probing a pod during graceful shutdown
// Stop probing for startup once container has started.
if w.probeType == startup {
return true
return false
Copy link
Member

Choose a reason for hiding this comment

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

startupProbe behaviour changed
After the container restarts, startupProbe will no longer be executed
#101093

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/kubelet 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. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note-none Denotes a PR that doesn't merit a release note. sig/node Categorizes an issue or PR as relevant to SIG Node. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Development

Successfully merging this pull request may close these issues.

liveness/readiness probe is executed and failed while pod is terminated
9 participants