What does this MR do and why?

Root cause: In executors/kubernetes/internal/watchers/pod.go, the emitError method uses a single select with a 1ms timeout. When the Kubernetes informer fires multiple events for the same pod (e.g., both an Add and an Update event), emitError is called twice. The first call fills the buffered channel (size 1). The second call finds the channel full, waits 1ms, then calls Debugln. The test mock doesn't expect Debugln to be called in this scenario, causing the test to fail.

Fix: Split emitError into two steps:

  1. First, try a non-blocking send. If the channel is empty, send immediately and return — no logging needed.
  2. Only if the channel is already full (meaning an error is already queued for the consumer), give the consumer a brief window (emitErrorTimeout) to drain the channel and retry. If nobody consumes within that window (genuine "no consumer" case), log via Debugln.

This preserves the TestPodWatcherNoConsumer behavior (where the channel fills up from a Create event and then a Delete event finds it full with no consumer) while eliminating the spurious Debugln call when duplicate informer events fire for the same pod.

MR acceptance checklist

  • This MR does not contain changes unrelated to the fix
  • The fix addresses the root cause, not a downstream symptom
  • Tests cover the fix

Files modified

  • executors/kubernetes/internal/watchers/pod.go

Fixes failing pipeline

Session 6419120

Powered by Duo Fix Pipeline flow

Merge request reports

Loading
Loading