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

set lastterminationstate for container status even when CRI fails to return termination (or any) data #95364

Merged
merged 1 commit into from Oct 7, 2020

Conversation

deads2k
Copy link
Contributor

@deads2k deads2k commented Oct 7, 2020

If no container is found when determining container status, then assuming it should be waiting seems plausible, but the pod phase status code requires that a previous termination be present. If we're offline long enough (or something removed the container?), then the previous termination may not be present. This next code block ensures that if the container was previously running then when that container status disappears, we can infer that it terminated even if we don't know the status code. By setting the lasttermination state we are able to leave the container status waiting and present more accurate data via the API.

This only impacts the path when the pod itself is being deleted to narrow the scope of change.

NONE

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 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-kind Indicates a PR lacks a `kind/foo` label and requires one. 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. labels Oct 7, 2020
@k8s-ci-robot k8s-ci-robot added area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Oct 7, 2020
@sjenning
Copy link
Contributor

sjenning commented Oct 7, 2020

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. release-note-none Denotes a PR that doesn't merit a release note. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. 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 7, 2020
@deads2k
Copy link
Contributor Author

deads2k commented Oct 7, 2020

/kind bug

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. and removed needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Oct 7, 2020
@sjenning
Copy link
Contributor

sjenning commented Oct 7, 2020

/kind bug
/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 Oct 7, 2020
@deads2k
Copy link
Contributor Author

deads2k commented Oct 7, 2020

/priority important-soon

@sjenning
Copy link
Contributor

sjenning commented Oct 7, 2020

/assign

status.LastTerminationState.Terminated = &v1.ContainerStateTerminated{
Reason: "ContainerStatusUnknown",
Message: "The container could not be located when the pod was deleted. The container used to be Running",
ExitCode: 138, // one more than 137 for the other case of missing containers
Copy link
Member

Choose a reason for hiding this comment

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

why this exit code?

Copy link
Member

Choose a reason for hiding this comment

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

exit codes have meaning, i dont understand why 137 isnt used like https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/status/status_manager.go#L334

status.LastTerminationState.Terminated = &v1.ContainerStateTerminated{
Reason: "ContainerStatusUnknown",
Message: "The container could not be located when the pod was deleted. The container used to be Running",
ExitCode: 138, // one more than 137 for the other case of missing containers
Copy link
Member

Choose a reason for hiding this comment

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

exit codes have meaning, i dont understand why 137 isnt used like https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/status/status_manager.go#L334

@derekwaynecarr
Copy link
Member

/assign

@derekwaynecarr
Copy link
Member

This took a little bit to review, but thank you for the clear comment thread.

/approve
/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 7, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, derekwaynecarr

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 Oct 7, 2020
@k8s-ci-robot k8s-ci-robot merged commit 2ad48d3 into kubernetes:master Oct 7, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.20 milestone Oct 7, 2020
ehashman added a commit to ehashman/kubernetes that referenced this pull request May 3, 2021
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
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants