Skip to content

Commit 0f7fa45

Browse files
committed
cmd/oc: disable docker's use of pigz earlier
Due to a race condition in Docker[1], we need to disable extraction using unpigz. Currently this is done in the image extraction code, however this code is multi-threaded. Setenv is not thread safe in C[2], so even thought it is safe in go[3], there's a small risk if there's any C threads running. It's safer to just set this env variable once when `oc` starts, rather every time the layerByEntry function is called. [1] moby/moby#39859 [2] rust-lang/rust#24741 [3] https://github.com/golang/go/blob/a38a917aee626a9b9d5ce2b93964f586bf759ea0/src/syscall/env_unix.go#L18
1 parent 6a5ac77 commit 0f7fa45

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

cmd/oc/oc.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ func main() {
6262
runtime.GOMAXPROCS(runtime.NumCPU())
6363
}
6464

65+
// Prevents race condition present in vendored version of Docker.
66+
// See: https://github.com/moby/moby/issues/39859
67+
os.Setenv("MOBY_DISABLE_PIGZ", "true")
68+
6569
pflag.CommandLine.SetNormalizeFunc(utilflag.WordSepNormalizeFunc)
6670
pflag.CommandLine.AddGoFlagSet(goflag.CommandLine)
6771
injectLoglevelFlag(pflag.CommandLine)

pkg/cli/image/extract/extract.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,6 @@ func (o *Options) Run() error {
483483
}
484484

485485
func layerByEntry(r io.Reader, options *archive.TarOptions, layerInfo LayerInfo, fn TarEntryFunc, allLayers bool, alreadySeen map[string]struct{}) (bool, error) {
486-
// Prevents race condition present in vendored version of docker
487-
// https://github.com/moby/moby/issues/39859
488-
os.Setenv("MOBY_DISABLE_PIGZ", "true")
489-
490486
rc, err := dockerarchive.DecompressStream(r)
491487
if err != nil {
492488
return false, err

0 commit comments

Comments
 (0)