Skip to content

fix(cn-controller): guard dereference while trying to clear resources - #522

Merged
yiguolei merged 2 commits into
apache:masterfrom
qube-rt:fix/cn-clearresources-nil-cnspec
Oct 20, 2026
Merged

yiguolei merged 2 commits into
apache:masterfrom
qube-rt:fix/cn-clearresources-nil-cnspec

Conversation

@Owen-CH-Leung

@Owen-CH-Leung Owen-CH-Leung commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Bug: Removing cnSpec from a running DorisCluster panics the CN controller. Sync calls ClearResources only when spec.cnSpec is nil, but ClearResources then reads dcr.Spec.CnSpec.AutoScalingPolicy. The operator recovers the panic

Steps to reproduce:

  1. Apply a DorisCluster with feSpec, beSpec and cnSpec, and wait until status.cnStatus is populated.
  2. Delete the cnSpec block from the CR
  3. On every requeue, the operator log shows invalid memory address or nil pointer dereference

BE's ClearResources checks Spec.BeSpec == nil before it touches the spec, and broker does the same with BrokerSpec. FE's. CN was the only controller that read its spec without a nil check, on a code path that runs only when that spec is nil.

@Owen-CH-Leung
Owen-CH-Leung marked this pull request as ready for review October 17, 2026 02:45
@Al-assad

Copy link
Copy Markdown
Member

Thanks for the fix!
The nil guard looks good. Could we use a fake client for these regression tests instead of starting envtest in init()? This would avoid adding an API server dependency to all tests in the CN package and keep the tests simpler. There are existing examples using fake.NewClientBuilder() in the repository.

@Al-assad

Copy link
Copy Markdown
Member

LGTM

@yiguolei
yiguolei merged commit 274c3fb into apache:master Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants