mirror of
https://github.com/containerd/containerd.git
synced 2026-08-09 09:33:06 +00:00
Since Go 1.21, os.MkdirTemp/os.TempDir resolve the temp directory via Windows' GetTempPath2W. For processes running as SYSTEM (as containerd does when running under the SCM), that API reads the temp location from the SystemTemp environment variable rather than TMP/TEMP. As a result, the existing TMP/TEMP overrides no longer steer the layer-extraction tempdir for the containerd service, so it falls back to the default C:\\Windows\\SystemTemp and unpacks on the SystemDrive, reintroducing the cross-volume copy the 'temp' config option was meant to avoid. Set SystemTemp to config.TempDir alongside TEMP/TMP so the override keeps working on Go 1.21+. Factor the env-var setting out of CreateTopLevelDirectories into a small setTempDirEnv helper and add a focused unit test (TestSetTempDirEnv) that verifies the expected variables are set: TEMP/TMP/SystemTemp on Windows, TMPDIR on other platforms. Ref: https://cs.opensource.google/go/go/+/refs/tags/go1.21.0:src/os/file_windows.go Signed-off-by: Maksim An <maksiman@microsoft.com>