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 node lifecycle controller panic when conditionType ready is nil #122874

Merged
merged 1 commit into from
Feb 27, 2024

Conversation

fusida
Copy link
Contributor

@fusida fusida commented Jan 19, 2024

What type of PR is this?

/kind bug

What this PR does / why we need it:

there are some network plugins and operators that will patch the node conditions, if they use merge-patch by mistake may cause the node conditions to be replaced unexpectedly.
when node .status.conditions[].ready is not exist, the node lifecycle controller may panic.
the kube controller manager error:

E0119 17:48:21.362092       1 runtime.go:78] Observed a panic: "invalid memory address or nil pointer dereference" (runtime error: invalid memory address or nil pointer dereference)
goroutine 8148 [running]:
k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/runtime.logPanic(0x41ed3c0, 0x74f3f20)
  /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:74 +0x95
k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/runtime.HandleCrash(0x0, 0x0, 0x0)
  /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:48 +0x86
panic(0x41ed3c0, 0x74f3f20)
  /usr/local/go/src/runtime/panic.go:965 +0x1b9
k8s.io/kubernetes/pkg/controller/nodelifecycle.(*Controller).doNoExecuteTaintingPass.func1(0xc0ae9a9920, 0x19, 0x3eac400, 0xc0c17d2140, 0xc162af370d35209e, 0x11fa57b3b4c, 0x75333e0, 0xc162af370d35209e, 0x11fa57b3b4c,0x75333e0, ...)
  /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/controller/nodelifecycle/node_lifecycle_controller.go:685 +0x2e3
k8s.io/kubernetes/pkg/controller/nodelifecycle/scheduler.(*RateLimitedTimedQueue).Try(0xc06c39b3c0, 0xc038623dd8)
  /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/controller/nodelifecycle/scheduler/rate_limited_queue.go:249 +0x255
k8s.io/kubernetes/pkg/controller/nodelifecycle.(*Controller).doNoExecuteTaintingPass(0xc00162c900)
  /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/controller/nodelifecycle/node_lifecycle_controller.go:671 +0x13a
k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1(0xc0c4f7e250)

Which issue(s) this PR fixes:

Fixes #
condition may be nil and condition.Status will panic:

 _, condition := controllerutil.GetNodeCondition(&node.Status, v1.NodeReady)
// Because we want to mimic NodeStatus.Condition["Ready"] we make "unreachable" and "not ready" taints mutually exclusive.
taintToAdd := v1.Taint{}
oppositeTaint := v1.Taint{}
switch condition.Status { 

Special notes for your reviewer:

Does this PR introduce a user-facing change?

fix node lifecycle controller panic when conditionType ready is been patch nil by mistake

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

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. size/XS Denotes a PR that changes 0-9 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. 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-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 19, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @fusida. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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/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 19, 2024
@kannon92
Copy link
Contributor

/ok-to-test

Can you add a unit test or integration test that covers this bug? I expect it to not have any issues now.

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 19, 2024
@kannon92
Copy link
Contributor

Sounds like a bug.

/triage accepted
/priority important-longterm

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed 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 Jan 19, 2024
@kannon92
Copy link
Contributor

/priority important-soon

@k8s-ci-robot k8s-ci-robot added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Jan 19, 2024
@kannon92
Copy link
Contributor

Can you share which k8s version you got this in? And does this look to be an regression?

@fusida
Copy link
Contributor Author

fusida commented Jan 19, 2024

Can you share which k8s version you got this in? And does this look to be an regression?

it happened 1.22.15, but he code still unchange in 1.28

patch node conditions ready nil, and stop kubelet report lease, then the kcm set node notready will meet this problem

@bart0sh bart0sh added this to Triage in SIG Node PR Triage Jan 19, 2024
@bart0sh bart0sh moved this from Triage to Needs Reviewer in SIG Node PR Triage Jan 21, 2024
@fusida
Copy link
Contributor Author

fusida commented Feb 26, 2024

/remove-area apiserver
/remove-area cloudprovider
/remove-area code-generation
/remove-area dependency
/remove-area kube-proxy
/remove-area kubeadm
/remove-area kubectl

@k8s-ci-robot
Copy link
Contributor

@fusida: Those labels are not set on the issue: area/codegeneration

In response to this:

/remove-area apiserver
/remove-area cloudprovider
/remove-area codegeneration
/remove-area dependency
/remove-area kube-proxy
/remove-area kubeadm
/remove-area kubectl

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.

@fusida
Copy link
Contributor Author

fusida commented Feb 26, 2024

/remove-area code-generation

@fusida
Copy link
Contributor Author

fusida commented Feb 26, 2024

/retest

@fusida
Copy link
Contributor Author

fusida commented Feb 26, 2024

@fusida please remove the second commit, is unrelated and the same function is used with the same signature in staging/src/k8s.io/component-helpers/node/util/conditions.go

You can do a follow up and try to consolidate these functions, but that will require other reviewers I prefer to not mix things here, changing function signatures

I have removed the second commit.

@aojea
Copy link
Member

aojea commented Feb 26, 2024

/lgtm
/approve
@fusida you need to fix the release note, it seems you have added it to the other existing block

/assign @liggitt

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

LGTM label has been added.

Git tree hash: 9869f19b0ec8fa8f8a52dec0b39f066aa8a8864e

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. 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 Feb 26, 2024
@fusida
Copy link
Contributor Author

fusida commented Feb 26, 2024

@aojea done

@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 Feb 26, 2024
@@ -623,6 +623,11 @@ func (nc *Controller) doNoExecuteTaintingPass(ctx context.Context) {
return false, 50 * time.Millisecond
}
_, condition := controllerutil.GetNodeCondition(&node.Status, v1.NodeReady)
if condition == nil {
Copy link
Member

Choose a reason for hiding this comment

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

it's definitely good not to panic, but is retrying correct, or should the absence of the Ready condition be treated as presence with Unknown status?

Copy link
Member

@aojea aojea Feb 26, 2024

Choose a reason for hiding this comment

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

My understanding is that it should never be nil and it happens because an external force action, then other controller in the kubelet should reconcile it, so retrying waiting for the kubelet (IIRC) seems a good option

@liggitt
Copy link
Member

liggitt commented Feb 27, 2024

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aojea, fusida, liggitt

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 27, 2024
@k8s-ci-robot k8s-ci-robot merged commit 1853de7 into kubernetes:master Feb 27, 2024
14 checks passed
SIG Node PR Triage automation moved this from Needs Reviewer to Done Feb 27, 2024
@k8s-ci-robot k8s-ci-robot added this to the v1.30 milestone Feb 27, 2024
@sftim
Copy link
Contributor

sftim commented Mar 12, 2024

Changelog suggestion

-fix node lifecycle controller panic when conditionType ready is been patch nil by mistake
+Fixed a panic in the node lifecycle controller when a `Ready` condition was incorrectly patched to be null.

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. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. 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/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. 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
Archived in project
Archived in project
Archived in project
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

7 participants