Skip to content

Commit 8ff72e9

Browse files
committed
work around moby/moby#42379 triggering race errors in Docker client under test
1 parent a9d732a commit 8ff72e9

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

engineclient/moby/moby.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const PrivilegedLabel = "github.com/thediveo/whalewatcher/moby/privileged"
4343
type MobyAPIClient interface {
4444
client.ContainerAPIClient
4545
client.SystemAPIClient
46+
NegotiateAPIVersion(ctx context.Context)
4647
DaemonHost() string
4748
Close() error
4849
}
@@ -131,6 +132,9 @@ func (mw *MobyWatcher) Close() {
131132
// List all the currently alive and kicking containers, but do not list any
132133
// containers without any processes.
133134
func (mw *MobyWatcher) List(ctx context.Context) ([]*whalewatcher.Container, error) {
135+
// https://github.com/moby/moby/pull/42379
136+
mw.moby.NegotiateAPIVersion(ctx)
137+
134138
// Scan the currently available containers and take only the alive into
135139
// further consideration. This is a potentially lengthy operation, as we
136140
// need to inspect each potential candidate individually due to the way the
@@ -188,6 +192,9 @@ func (mw *MobyWatcher) Inspect(ctx context.Context, nameorid string) (*whalewatc
188192
// in the lifecycle of containers getting born (=alive, as opposed to, say,
189193
// "conceived") and die.
190194
func (mw *MobyWatcher) LifecycleEvents(ctx context.Context) (<-chan engineclient.ContainerEvent, <-chan error) {
195+
// https://github.com/moby/moby/pull/42379
196+
mw.moby.NegotiateAPIVersion(ctx)
197+
191198
cntreventstream := make(chan engineclient.ContainerEvent)
192199
cntrerrstream := make(chan error, 1)
193200

test/mockingmoby/moby.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ func NewMockingMoby() *MockingMoby {
5454
}
5555
}
5656

57+
// NegotiateAPIVersion is a mock no-op.
58+
func (mm *MockingMoby) NegotiateAPIVersion(ctx context.Context) {}
59+
5760
// DaemonHost returns the host address used by the client
5861
func (mm *MockingMoby) DaemonHost() string { return "mock://mocked" }
5962

0 commit comments

Comments
 (0)