fix(chk): prevent nil pointer panic in poll when CR Get fails#1974
Merged
sunsingerus merged 1 commit intoAltinity:0.27.0from May 4, 2026
Merged
fix(chk): prevent nil pointer panic in poll when CR Get fails#1974sunsingerus merged 1 commit intoAltinity:0.27.0from
sunsingerus merged 1 commit intoAltinity:0.27.0from
Conversation
The poll function in the ClickHouseKeeperInstallation controller panics when c.kube.CR().Get() returns an error because cur is nil, and the code performs an unchecked type assertion cur.(*ClickHouseKeeperInstallation). This causes the operator to crashloop with: 'panic: interface conversion: v1.ICustomResource is nil, not *v1.ClickHouseKeeperInstallation' Fix by checking the type assertion result and nil before using cur. - If NotFound: return immediately (CR was deleted, no point polling) - If other error: log and continue polling with 15s backoff - Only call the callback f() when chk is valid This follows the same safe pattern used in statusUpdateProcess() in pkg/controller/chk/kube/cr.go. Fixes Altinity#1972 Signed-off-by: wucm667 <stevenwucongmin@gmail.com>
sunsingerus
approved these changes
May 4, 2026
Collaborator
sunsingerus
left a comment
There was a problem hiding this comment.
LGTM. Follows the existing safe-cast pattern from pkg/controller/chk/kube/cr.go (statusUpdateProcess at lines 98-122): type-assert with ok, treat apiErrors.IsNotFound as terminal, log+retry transient errors, honor context cancellation. Closes the panic in #1972.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1972
What this PR fixes
The
pollfunction in the ClickHouseKeeperInstallation controller panics whenc.kube.CR().Get()returns an error becausecuris nil, and the code performs an unchecked type assertion:This causes the operator to crashloop with:
Changes
pkg/controller/chk/controller.gopoll()functionf()whenchkis validThis follows the same safe pattern already used in
statusUpdateProcess()inpkg/controller/chk/kube/cr.go.