Fix subscriber crash on Workflow ADD events (nil pointer dereference)#5406
Fix subscriber crash on Workflow ADD events (nil pointer dereference)#5406WHOIM1205 wants to merge 2 commits intolitmuschaos:masterfrom
Conversation
|
Hi @ispeakc0de I’d appreciate a review when you have time. Thanks! |
|
@WHOIM1205, Changes looks good. Can you fix the PR checks? |
Signed-off-by: WHOIM1205 <rathourprateek8@gmail.com>
d782c8e to
58c6c2e
Compare
Thanks for the review The failing CI was due to a goimports ordering issue in a test file. Please let me know if anything else is needed. Thanks! |
|
Hi @Ispeakcode, thanks for the review! All PR checks are passing now. Could you please take another look and let me know if this can be merged, or if anything else is needed from my side? Thanks! |
|
hey @ispeakc0de is there anything which i can change |
What this PR does
Fixes a nil pointer dereference in the ChaosCenter subscriber that caused the subscriber to crash during informer re-list on startup or restart when existing Workflow CRs were present.
Why this change is needed
Kubernetes informers deliver ADD events for all existing resources during initial List or after a restart.
WorkflowEventHandlerwas assumingoldObjwas always non-nil and accessedoldObj.Status.Nodes, which is invalid for ADD events and resulted in a panic.This caused the subscriber to enter a crash loop in clusters with active or completed chaos workflows.
What changed
oldObjusing:eventType == "UPDATE"oldObj != nilPending → Runningtransition logic for UPDATE eventsImpact
Risk
Low. The fix is a minimal defensive guard and does not alter business logic for valid update paths.
Test case:
WorkflowEventHandler(nil, workflowObj, "ADD", startTime)RunningphaseChaosDatais present (cd != nil)Assertions:
cd.ExperimentStatusThis test validates correct handling of informer re-list behavior and prevents regression.