From fb0b8d6177538c0da2ddd81b90b8c5e6d96f8b0f Mon Sep 17 00:00:00 2001 From: ruiwen-zhao Date: Fri, 11 Feb 2022 04:21:58 +0000 Subject: [PATCH] Use fs.RootPath when mounting volumes Signed-off-by: Ruiwen Zhao --- pkg/cri/opts/container.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/cri/opts/container.go b/pkg/cri/opts/container.go index b3e358b2e..e3b838fda 100644 --- a/pkg/cri/opts/container.go +++ b/pkg/cri/opts/container.go @@ -112,7 +112,10 @@ func WithVolumes(volumeMounts map[string]string) containerd.NewContainerOpts { // The volume may have been defined with a C: prefix, which we can't use here. volume = strings.TrimPrefix(volume, "C:") for _, mountPath := range mountPaths { - src := filepath.Join(mountPath, volume) + src, err := fs.RootPath(mountPath, volume) + if err != nil { + return fmt.Errorf("rootpath on mountPath %s, volume %s: %w", mountPath, volume, err) + } if _, err := os.Stat(src); err != nil { if os.IsNotExist(err) { // Skip copying directory if it does not exist.