diff --git a/pkg/skaffold/docker/logger/log.go b/pkg/skaffold/docker/logger/log.go index 7591a999b0a..de42098b943 100644 --- a/pkg/skaffold/docker/logger/log.go +++ b/pkg/skaffold/docker/logger/log.go @@ -71,6 +71,7 @@ func NewLogger(ctx context.Context, tracker *tracker.ContainerTracker, cfg docke client: cli, colorPicker: output.NewColorPicker(), shouldInterruptLogs: shouldInterruptLogs, + threadLogsCancel: func() {}, }, nil } diff --git a/pkg/skaffold/docker/logger/log_test.go b/pkg/skaffold/docker/logger/log_test.go index 413c7f1e071..c540a2db040 100644 --- a/pkg/skaffold/docker/logger/log_test.go +++ b/pkg/skaffold/docker/logger/log_test.go @@ -20,6 +20,10 @@ import ( "context" "io" "testing" + + "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/docker" + "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/docker/tracker" + "github.com/GoogleContainerTools/skaffold/v2/testutil" ) func TestDockerLoggerZeroValue(t *testing.T) { @@ -31,3 +35,16 @@ func TestDockerLoggerZeroValue(t *testing.T) { m.Unmute() m.Stop() } + +func TestLoggerStopNoPanic(t *testing.T) { + testutil.Run(t, "stopping logger should not panic", func(t *testutil.T) { + t.Override(&docker.NewAPIClient, func(context.Context, docker.Config) (docker.LocalDaemon, error) { + return nil, nil + }) + + logger, err := NewLogger(context.Background(), &tracker.ContainerTracker{}, nil, true) + testutil.CheckError(t.T, false, err) + + logger.Stop() + }) +}