-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes docker driver that would panic when closed. (#3709)
This is happening because it can still received log, but the client might be already closed. Fixes #3705 Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
- Loading branch information
1 parent
74ee19c
commit 7a5fe3d
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
util_log "github.com/cortexproject/cortex/pkg/util/log" | ||
"github.com/docker/docker/daemon/logger" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_loki_LogWhenClosed(t *testing.T) { | ||
l, err := New(logger.Info{ | ||
Config: map[string]string{ | ||
"loki-url": "http://localhost:3000", | ||
}, | ||
}, util_log.Logger) | ||
require.Nil(t, err) | ||
msg := logger.NewMessage() | ||
msg.Line = []byte(`foo`) | ||
msg.Timestamp = time.Now() | ||
require.Nil(t, l.Log(msg)) | ||
require.Nil(t, l.Close()) | ||
require.NotNil(t, l.Log(msg)) | ||
} |