loggie-io / loggie

A lightweight, cloud-native data transfer agent and aggregator
https://loggie-io.github.io/docs-en/
Apache License 2.0
1.26k stars 165 forks source link

kubeEvent with watchLatestEvents will lead process panic #458

Closed fatpa closed 1 year ago

fatpa commented 1 year ago

What version of Loggie?

1.4.0-rc

Expected Behavior

running as usual

Actual Behavior

panic

Steps to Reproduce the Problem

  1. set up clusterlogconfig with kubeEvent type
  2. set watchLatestEvents as true

Ref to #385 , I think ev.LastTimestamp.Time and ev.Series.LastObservedTime.Time may be empty sometime, and we should check if it is empty or not.

fatpa commented 1 year ago

And below is the error log:

E0129 18:01:04.492729       1 runtime.go:79] Observed a panic: "invalid memory address or nil pointer dereference" (runtime error: invalid memory address or nil pointer dereference)
goroutine 214 [running]:
k8s.io/apimachinery/pkg/util/runtime.logPanic({0x243e500?, 0x3eb6200})
    /vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:75 +0x99
k8s.io/apimachinery/pkg/util/runtime.HandleCrash({0x0, 0x0, 0x203000?})
    /vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:49 +0x75
panic({0x243e500, 0x3eb6200})
    /usr/local/go/src/runtime/panic.go:838 +0x207
github.com/loggie-io/loggie/pkg/source/kubernetes_event.(*KubeEvent).filter(0xc000886180, 0xc00091fc20)
    /pkg/source/kubernetes_event/eventer.go:260 +0xa0
github.com/loggie-io/loggie/pkg/source/kubernetes_event.(*KubeEvent).run.func1({0x2789980?, 0xc00091fc20})
    /pkg/source/kubernetes_event/eventer.go:189 +0x50
k8s.io/client-go/tools/cache.ResourceEventHandlerFuncs.OnAdd(...)
    /vendor/k8s.io/client-go/tools/cache/controller.go:232
k8s.io/client-go/tools/cache.(*processorListener).run.func1()
    /vendor/k8s.io/client-go/tools/cache/shared_informer.go:818 +0xaf
k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1(0x0?)
    /vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:157 +0x3e
k8s.io/apimachinery/pkg/util/wait.BackoffUntil(0x46dac7?, {0x2bff720, 0xc000aa53b0}, 0x1, 0xc000ad6900)
    /vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:158 +0xb6
k8s.io/apimachinery/pkg/util/wait.JitterUntil(0x0?, 0x3b9aca00, 0x0, 0x0?, 0xc000a03f88?)
    /vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:135 +0x89
k8s.io/apimachinery/pkg/util/wait.Until(...)
    /vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:92
k8s.io/client-go/tools/cache.(*processorListener).run(0xc000809400?)
    /vendor/k8s.io/client-go/tools/cache/shared_informer.go:812 +0x6b
k8s.io/apimachinery/pkg/util/wait.(*Group).Start.func1()
    /vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:75 +0x5a
created by k8s.io/apimachinery/pkg/util/wait.(*Group).Start
    /vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:73 +0x85
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
    panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x1f133a0]