Skip to content

Commit

Permalink
Set event TimeStamp if K8s event Series is not nil #591
Browse files Browse the repository at this point in the history
##### ISSUE TYPE
 - Bug fix Pull Request

##### SUMMARY

This PR fixes the bug where BotKube is crashing while building events.
Add a condition to check the event.Series object is nil before accessing its field.
  • Loading branch information
PrasadG193 committed May 24, 2022
1 parent aa138d5 commit 21ea3b0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func New(object interface{}, eventType config.EventType, resource, clusterName s
event.Action = eventObj.Action
event.TimeStamp = eventObj.LastTimestamp.Time
// Compatible with events.k8s.io/v1
if eventObj.LastTimestamp.IsZero() {
if eventObj.LastTimestamp.IsZero() && eventObj.Series != nil {
event.TimeStamp = eventObj.Series.LastObservedTime.Time
event.Count = eventObj.Series.Count
}
Expand Down

0 comments on commit 21ea3b0

Please sign in to comment.