Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic in Logger.Stop #9159

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/skaffold/docker/logger/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func NewLogger(ctx context.Context, tracker *tracker.ContainerTracker, cfg docke
client: cli,
colorPicker: output.NewColorPicker(),
shouldInterruptLogs: shouldInterruptLogs,
threadLogsCancel: func() {},
}, nil
}

Expand Down
17 changes: 17 additions & 0 deletions pkg/skaffold/docker/logger/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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()
})
}