fix: fix nil map panic in CompareConfigmapAndTriggerRestart when dcr.Annotations is nil#493
Conversation
|
Thanks for the fix. The nil map guard looks right to me, and the log arg correction also makes sense. I had one question about the restart annotation update path. In the current reconcile flow, the object passed into CompareConfigmapAndTriggerRestart seems to be a DeepCopy of the fetched CR: https://github.com/apache/doris-operator/blob/master/pkg/controller/doriscluster_controller.go#L131 Then CompareConfigmapAndTriggerRestart updates the annotation on that copied object: https://github.com/apache/doris-operator/blob/master/pkg/controller/sub_controller/sub_controller.go#L758 After Sync, I only see ApplyDorisCluster being called from revertDorisClusterSomeFields when FE replicas differ, while the normal path only updates status: https://github.com/apache/doris-operator/blob/master/pkg/controller/doriscluster_controller.go#L177-L180 So I may be missing something, but could you help confirm where this annotation change gets persisted back to the apiserver? If there isn't an existing path, maybe it would be helpful to add a small test covering the configmap-change restart flow. |
What problem does this PR solve?
Problem Summary:
When
CompareConfigmapAndTriggerRestartdetects a configmap change and triggersa rolling restart, it assigns directly to
dcr.Annotationswithout checkingwhether the map is initialized. If a
DorisClusterCR is created without anyannotations,
dcr.Annotationsis nil, causing a panic that crashes the reconcileloop.
Additionally, a copy-paste bug caused the log line to print
dcr.Namespacetwiceinstead of
dcr.Namefor the CRD name field.Observed error:
Fix:
dcr.Annotationsbefore assignment when it is nil.dcr.Nameinstead ofdcr.Namespacefor the CRD name field.Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)