From 3d5837d21b4790d378d8b0fe25206e58dd5d188d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Wed, 20 Sep 2023 12:48:35 +0200 Subject: [PATCH] fix: avoid deadlocks when Docker is not available (#1645) --- docker_client.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docker_client.go b/docker_client.go index 49d1abf9ac..bfe06be7bc 100644 --- a/docker_client.go +++ b/docker_client.go @@ -40,8 +40,6 @@ func (c *DockerClient) Info(ctx context.Context) (types.Info, error) { dockerInfoOnce.Do(func() { dockerInfo, err = c.Client.Info(ctx) if err != nil { - // reset the state of the sync.Once so that the next call to Info will try again - dockerInfoOnce = sync.Once{} return } @@ -66,6 +64,11 @@ func (c *DockerClient) Info(ctx context.Context) (types.Info, error) { ) }) + if err != nil { + // reset the state of the sync.Once so that the next call to Info will try again + dockerInfoOnce = sync.Once{} + } + return dockerInfo, err }