Skip to content

fix: prevent nil pointer panic when spec.clusterConfig is omitted - #107

Merged
whg517 merged 1 commit into
zncdatadev:mainfrom
whg517:fix/clusterconfig-nil-panic
Jul 14, 2026
Merged

whg517 merged 1 commit into
zncdatadev:mainfrom
whg517:fix/clusterconfig-nil-panic

Conversation

@whg517

@whg517 whg517 commented Jul 14, 2026

Copy link
Copy Markdown
Member

Problem

spec.clusterConfig is optional in the DorisCluster CRD, but NewFEConfigMapReconciler dereferences dorisCluster.Spec.ClusterConfig.Authentication unconditionally (internal/controller/fe/configmap.go). Any minimal CR that defines only frontend/backend/broker crashes the operator with a nil pointer dereference on every reconcile, putting it in a crash loop. Reproduced live in a kind cluster (stack: fe.NewFEConfigMapReconciler → fe/role.go → common/role.go).

Fix

  • Guard the ClusterConfig dereference in NewFEConfigMapReconciler: when clusterConfig is nil the authentication spec stays empty and LDAP is treated as disabled, which IsLDAPAuth already handles.
  • Guard the same latent pattern in generateVectorYAML (internal/controller/common/vector.go).
  • Audited all remaining Spec.ClusterConfig dereferences under internal/controller — doriscluster_controller.go, scale/replicas.go, and common/configmap.go already nil-check, and the BE/broker ConfigMap builders only access it through the nil-safe GetVectorConfigMapName.

Verification

  • Added a regression test (internal/controller/fe/configmap_test.go) that builds the FE ConfigMap from a DorisCluster without clusterConfig (and with clusterConfig but no authentication). It panics on the unfixed code and passes with the fix.
  • make lint (0 issues) and make test (full unit suite) pass.

🤖 Generated with Claude Code

spec.clusterConfig is optional in the CRD, but the FE ConfigMap
reconciler dereferenced it unconditionally for the authentication
spec, crashing the reconcile loop for any minimal DorisCluster CR.
Guard the dereference in NewFEConfigMapReconciler and the latent
one in generateVectorYAML, and add a regression test building the
FE ConfigMap from a CR without clusterConfig.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@whg517
whg517 merged commit eda774c into zncdatadev:main Jul 14, 2026
8 checks passed
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.

1 participant