Skip to content

Conversation

@jianzhangbjz
Copy link
Member

Description of the change:

Add SafeEventRecorder wrapper that validates objects before recording
events to prevent panics when objects have nil or empty metadata.

  • Add safeSpamKeyFunc with nil checks for event fields
  • Add SafeEventRecorder wrapper implementing record.EventRecorder
  • Add isValidObject helper to validate object metadata
  • Skip event recording for invalid objects with debug logging
  • Add comprehensive unit tests for new functionality

This fixes a panic that occurs when recording events for objects
that have been deleted or have incomplete metadata during rapid
reconciliation cycles."

Motivation for the change:
To fix https://issues.redhat.com/browse/OCPBUGS-69688

Undiagnosed panic detected in pod
{  pods/openshift-operator-lifecycle-manager_olm-operator-566b7b56b4-njjp6_olm-operator_previous.log.gz:E1217 02:12:17.881155       1 panic.go:262] "Observed a panic" panic="runtime error: invalid memory address or nil pointer dereference" panicGoValue="\"invalid memory address or nil pointer dereference\"" stacktrace=<}

Architectural changes:

Testing remarks:

Reviewer Checklist

  • Implementation matches the proposed design, or proposal is updated to match implementation
  • Sufficient unit test coverage
  • Sufficient end-to-end test coverage
  • Bug fixes are accompanied by regression test(s)
  • e2e tests and flake fixes are accompanied evidence of flake testing, e.g. executing the test 100(0) times
  • tech debt/todo is accompanied by issue link(s) in comments in the surrounding code
  • Tests are comprehensible, e.g. Ginkgo DSL is being used appropriately
  • Docs updated or added to /doc
  • Commit messages sensible and descriptive
  • Tests marked as [FLAKE] are truly flaky and have an issue
  • Code is properly formatted

Assisted-by: Claude Code

@jianzhangbjz jianzhangbjz changed the title Fix nil pointer dereference panic in event recorder 🐛 Fix nil pointer dereference panic in event recorder Dec 18, 2025
@openshift-ci
Copy link

openshift-ci bot commented Dec 18, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign oceanc80 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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