From e2d8dc5e71f2eb3b817de2c95cbcd6df7f0178ba Mon Sep 17 00:00:00 2001 From: Samuel K Date: Tue, 21 Apr 2026 00:16:09 -0500 Subject: [PATCH] fix: prevent stdout corruption in kubernetes e2e tests ThrottledLogger in wait.go was using oldlog.GetInstance() which returns a StreamLogger that writes Info-level messages to stdout. In the agent process, stdout is the gRPC/tunnel protocol channel, so these log messages corrupted the binary protocol causing "did not receive a result back from agent" errors. Migrated ThrottledLogger to use pkg/log (which writes to stderr) instead of the old log library, matching the pattern established in PR #20. --- .../throttledlogger/throttled_logger.go | 20 +++++++++---------- pkg/driver/kubernetes/wait.go | 3 +-- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/pkg/driver/kubernetes/throttledlogger/throttled_logger.go b/pkg/driver/kubernetes/throttledlogger/throttled_logger.go index 4096b27d9..7a12e8cb1 100644 --- a/pkg/driver/kubernetes/throttledlogger/throttled_logger.go +++ b/pkg/driver/kubernetes/throttledlogger/throttled_logger.go @@ -3,37 +3,35 @@ package throttledlogger import ( "time" - "github.com/devsy-org/log" + "github.com/devsy-org/devsy/pkg/log" ) // ThrottledLogger is a logger that throttles the output, // i.e. it only logs a message if a certain amount of time has passed since the last log message. type ThrottledLogger struct { - logger log.Logger - timer *Timer + timer *Timer } -func NewThrottledLogger(logger log.Logger, throttlingInterval time.Duration) *ThrottledLogger { +func NewThrottledLogger(throttlingInterval time.Duration) *ThrottledLogger { return &ThrottledLogger{ - logger: logger, - timer: NewTimer(throttlingInterval), + timer: NewTimer(throttlingInterval), } } func (t *ThrottledLogger) Infof(format string, args ...any) { - t.log(t.logger.Infof, format, args...) + t.logf(log.Infof, format, args...) } func (t *ThrottledLogger) Debugf(format string, args ...any) { - t.log(t.logger.Debugf, format, args...) + t.logf(log.Debugf, format, args...) } -type LoggingFunc func(string, ...any) +type loggingFunc func(string, ...any) -func (t *ThrottledLogger) log(loggingFunc LoggingFunc, format string, args ...any) { +func (t *ThrottledLogger) logf(fn loggingFunc, format string, args ...any) { now := time.Now() if t.timer.IntervalPassed(now) { - loggingFunc(format, args...) + fn(format, args...) t.timer.Tick(now) } } diff --git a/pkg/driver/kubernetes/wait.go b/pkg/driver/kubernetes/wait.go index 325cfabc1..d5927642c 100644 --- a/pkg/driver/kubernetes/wait.go +++ b/pkg/driver/kubernetes/wait.go @@ -9,7 +9,6 @@ import ( "github.com/devsy-org/devsy/pkg/driver/kubernetes/throttledlogger" "github.com/devsy-org/devsy/pkg/log" - oldlog "github.com/devsy-org/log" corev1 "k8s.io/api/core/v1" kerrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -17,7 +16,7 @@ import ( ) func (k *KubernetesDriver) waitPodRunning(ctx context.Context, id string) (*corev1.Pod, error) { - throttledLogger := throttledlogger.NewThrottledLogger(oldlog.GetInstance(), time.Second*5) + throttledLogger := throttledlogger.NewThrottledLogger(time.Second * 5) timeoutDuration, err := time.ParseDuration(k.options.PodTimeout) if err != nil {