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 printPod panic with spurious container statuses #124906

Merged
merged 1 commit into from
May 16, 2024

Conversation

liggitt
Copy link
Member

@liggitt liggitt commented May 16, 2024

What type of PR is this?

/kind bug

What this PR does / why we need it:

Avoids panic when printing pods with spurious initContainer status

Does this PR introduce a user-facing change?

kube-apiserver: fixes a 1.28 regression printing pods with invalid initContainer status

/sig node
/cc @SergeyKanzhelev

@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. sig/node Categorizes an issue or PR as relevant to SIG Node. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels May 16, 2024
@k8s-ci-robot
Copy link
Contributor

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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-priority Indicates a PR lacks a `priority/foo` label and requires one. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels May 16, 2024
Copy link
Contributor

@iholder101 iholder101 left a comment

Choose a reason for hiding this comment

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

Thanks @liggitt!
/lgtm

Since you've CCed @SergeyKanzhelev I'm holding just to let him a chance to review. Feel entirely free to remove the hold!
/hold

@@ -1718,6 +1720,32 @@ func TestPrintPodWithRestartableInitContainer(t *testing.T) {
},
},
},
{
// Test pod has container statuses for non-existent initContainers and containers
Copy link
Contributor

Choose a reason for hiding this comment

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

For my education: in which scenarios can this ever happen?

Copy link
Member Author

Choose a reason for hiding this comment

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

non-kubelet clients that mirror back pod status from other systems (like https://github.com/admiraltyio/admiralty) can incorrectly report back status for injected containers which don't exist in the API :-/

it's not guarded against in API validation, unfortunately (I'll open an issue for that separately)

Copy link
Contributor

Choose a reason for hiding this comment

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

Very interesting. Thanks for the explanation!

Comment on lines +3210 to 3215
if initContainer == nil {
return false
}
if initContainer.RestartPolicy == nil {
return false
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
if initContainer == nil {
return false
}
if initContainer.RestartPolicy == nil {
return false
}
if initContainer == nil || initContainer.RestartPolicy == nil {
return false
}

Copy link
Member Author

@liggitt liggitt May 16, 2024

Choose a reason for hiding this comment

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

if it's ok, I'd like to leave the nil case standalone since it's a weird exception (I also want to backport this since the nil panic was introduced in 1.28, and I want to make the diff as clean as possible)

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense 👍 thanks!

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 16, 2024
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 16, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 7a4a39229aadd4ea82117dbd077fff701138a0ca

@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 release-note-none Denotes a PR that doesn't merit a release note. labels May 16, 2024
@liggitt liggitt added release-note-none Denotes a PR that doesn't merit a release note. kind/regression Categorizes issue or PR as related to a regression from a prior release. and removed release-note Denotes a PR that will be considered when it comes time to generate release notes. labels May 16, 2024
@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 release-note-none Denotes a PR that doesn't merit a release note. labels May 16, 2024
@liggitt
Copy link
Member Author

liggitt commented May 16, 2024

/retest

Copy link
Member

@SergeyKanzhelev SergeyKanzhelev left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

Thank you! this is great for backport preserving whatever behavior we have today. I was looking into what else will be printed wrong if such status exists and I think fully ignoring the status like this will be a better fix in 1.31. So I suggest we merge this one and then in 1.31, fully ignore this type of status when printing. WDYT?

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: liggitt, SergeyKanzhelev

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

@liggitt
Copy link
Member Author

liggitt commented May 16, 2024

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 16, 2024
@liggitt
Copy link
Member Author

liggitt commented May 16, 2024

I was looking into what else will be printed wrong if such status exists and I think fully ignoring the status like this will be a better fix in 1.31. So I suggest we merge this one and then in 1.31, fully ignore this type of status when printing. WDYT?

that seems ok

opened cherry-picks

@SergeyKanzhelev
Copy link
Member

/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 May 16, 2024
@liggitt
Copy link
Member Author

liggitt commented May 16, 2024

/retest

@k8s-ci-robot k8s-ci-robot merged commit 0aa01be into kubernetes:master May 16, 2024
14 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.31 milestone May 16, 2024
k8s-ci-robot added a commit that referenced this pull request May 17, 2024
…906-upstream-release-1.30

Automated cherry pick of #124906: Fix printPod panic with spurious container statuses
k8s-ci-robot added a commit that referenced this pull request May 19, 2024
…906-upstream-release-1.28

Automated cherry pick of #124906: Fix printPod panic with spurious container statuses
k8s-ci-robot added a commit that referenced this pull request May 19, 2024
…906-upstream-release-1.29

Automated cherry pick of #124906: Fix printPod panic with spurious container statuses
@liggitt liggitt deleted the pod-list-panic branch August 1, 2024 13:22
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. kind/regression Categorizes issue or PR as related to a regression from a prior release. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants