diff --git a/eventrouter.go b/eventrouter.go index 0b512ecd..68468f55 100644 --- a/eventrouter.go +++ b/eventrouter.go @@ -90,10 +90,13 @@ type EventRouter struct { // event sink // TODO: Determine if we want to support multiple sinks. eSink sinks.EventSinkInterface + + // skipEventUpdates will skip updating events in the sink + skipEventUpdates bool } // NewEventRouter will create a new event router using the input params -func NewEventRouter(kubeClient kubernetes.Interface, eventsInformer coreinformers.EventInformer) *EventRouter { +func NewEventRouter(kubeClient kubernetes.Interface, eventsInformer coreinformers.EventInformer, skipEventUpdates bool) *EventRouter { if viper.GetBool("enable-prometheus") { prometheus.MustRegister(kubernetesWarningEventCounterVec) prometheus.MustRegister(kubernetesNormalEventCounterVec) @@ -102,8 +105,9 @@ func NewEventRouter(kubeClient kubernetes.Interface, eventsInformer coreinformer } er := &EventRouter{ - kubeClient: kubeClient, - eSink: sinks.ManufactureSink(), + kubeClient: kubeClient, + eSink: sinks.ManufactureSink(), + skipEventUpdates: skipEventUpdates, } _, err := eventsInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ AddFunc: er.addEvent, @@ -145,7 +149,9 @@ func (er *EventRouter) updateEvent(objOld interface{}, objNew interface{}) { eOld := objOld.(*v1.Event) eNew := objNew.(*v1.Event) prometheusEvent(eNew) - er.eSink.UpdateEvents(eNew, eOld) + if !er.skipEventUpdates { + er.eSink.UpdateEvents(eNew, eOld) + } } // prometheusEvent is called when an event is added or updated diff --git a/main.go b/main.go index d631c980..961756a6 100644 --- a/main.go +++ b/main.go @@ -38,7 +38,7 @@ import ( // addr tells us what address to have the Prometheus metrics listen on. var addr = flag.String("listen-address", ":8080", "The address to listen on for HTTP requests.") -// setup a signal hander to gracefully exit +// setup a signal handler to gracefully exit func sigHandler() <-chan struct{} { stop := make(chan struct{}) go func() { @@ -74,6 +74,7 @@ func loadConfig() kubernetes.Interface { viper.SetDefault("sink", "glog") viper.SetDefault("resync-interval", time.Minute*30) viper.SetDefault("enable-prometheus", true) + viper.SetDefault("skip-event-updates", false) if err = viper.ReadInConfig(); err != nil { panic(err.Error()) } @@ -118,8 +119,9 @@ func main() { sharedInformers := informers.NewSharedInformerFactory(clientset, viper.GetDuration("resync-interval")) eventsInformer := sharedInformers.Core().V1().Events() + skipEventUpdates := viper.GetBool("skip-event-updates") // TODO: Support locking for HA https://github.com/kubernetes/kubernetes/pull/42666 - eventRouter := NewEventRouter(clientset, eventsInformer) + eventRouter := NewEventRouter(clientset, eventsInformer, skipEventUpdates) stop := sigHandler() // Startup the http listener for Prometheus Metrics endpoint. diff --git a/yaml/eventrouter.yaml b/yaml/eventrouter.yaml index 762e50be..8250fd7a 100644 --- a/yaml/eventrouter.yaml +++ b/yaml/eventrouter.yaml @@ -48,7 +48,8 @@ apiVersion: v1 data: config.json: |- { - "sink": "stdout" + "sink": "stdout", + "skip-event-updates": "true" } --- apiVersion: apps/v1