Skip to content

Commit

Permalink
Synchronize docker config loading
Browse files Browse the repository at this point in the history
This prevents data races during testing. The root cause
are unsecured globals in the docker cli lib.

Signed-off-by: Jan Boehm <6552713+jeloba@users.noreply.github.com>
  • Loading branch information
jeloba committed Jan 12, 2022
1 parent cd70295 commit 4ec9cdb
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/image/containerdregistry/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/x509"
"net"
"net/http"
"sync"
"time"

"github.com/containerd/containerd/remotes"
Expand Down Expand Up @@ -85,7 +86,13 @@ func credential(cfg *configfile.ConfigFile) func(string) (string, string, error)
}
}

// protects against a data race inside the docker CLI
var configMutex sync.Mutex

func loadConfig(dir string) (*configfile.ConfigFile, error) {
configMutex.Lock()
defer configMutex.Unlock()

if dir == "" {
dir = config.Dir()
}
Expand Down

0 comments on commit 4ec9cdb

Please sign in to comment.