From 410276db5a720c30ef610e1ceae01825a69cc167 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Fri, 16 Aug 2024 21:14:24 +0000 Subject: [PATCH] pr comments --- .../ciliumeventobserver/ciliumeventobserver_linux.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/plugin/ciliumeventobserver/ciliumeventobserver_linux.go b/pkg/plugin/ciliumeventobserver/ciliumeventobserver_linux.go index ecb88d2365..0ec01cc357 100644 --- a/pkg/plugin/ciliumeventobserver/ciliumeventobserver_linux.go +++ b/pkg/plugin/ciliumeventobserver/ciliumeventobserver_linux.go @@ -28,6 +28,7 @@ const ( defaultRetryDelay = 12 * time.Second workers = 2 buffer = 10000 + parserMetric = "parser" ) var ( @@ -79,8 +80,9 @@ func (c *ciliumeventobserver) Start(ctx context.Context) error { c.enricher = enricher.Instance() } else { c.l.Warn("retina enricher is not initialized") - return errPodLevelDisabled } + } else { + return errPodLevelDisabled } for i := 0; i < workers; i++ { @@ -134,6 +136,7 @@ func (c *ciliumeventobserver) connect(ctx context.Context) error { conn, err := c.d.Dial("unix", c.sockPath) if err != nil { c.l.Error("Connection attempt failed", zap.Error(err)) + curAttempt++ if curAttempt > c.maxAttempts { c.connection = nil return errFailedConnection @@ -162,9 +165,14 @@ func (c *ciliumeventobserver) monitorLoop(ctx context.Context) error { return err //nolint:wrapcheck // Error is handled by the caller } c.l.Warn("Failed to decode payload from cilium", zap.Error(err)) + metrics.LostEventsCounter.WithLabelValues(parserMetric, string(Name)).Inc() continue } - c.payloadEvents <- &pl + select { + case c.payloadEvents <- &pl: + default: + metrics.LostEventsCounter.WithLabelValues(utils.BufferedChannel, string(Name)).Inc() + } } } }