From ec2bec6481d5ad53a2a21a7ad1a3c48efca3999f Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Thu, 6 Apr 2023 16:57:32 -0700 Subject: [PATCH] Fix non C volumes on Windows Images may be created with a VOLUME stanza pointed to drive letters that are not C:. Currently, an image that has such VOLUMEs defined, will cause containerd to error out when starting a container. This change skips copying existing contents to volumes that are not C:. as an image can only hold files that are destined for the C: drive of a container. Signed-off-by: Gabriel Adrian Samfira --- pkg/cri/opts/container.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/cri/opts/container.go b/pkg/cri/opts/container.go index c7f226b13..3995975ef 100644 --- a/pkg/cri/opts/container.go +++ b/pkg/cri/opts/container.go @@ -97,6 +97,12 @@ func WithVolumes(volumeMounts map[string]string) containerd.NewContainerOpts { }() for host, volume := range volumeMounts { + // On Windows, volumes may be defined as different drive letters than C:. For non-C: volumes + // we need to skip trying to copy existing contents, as an image can only hold files + // destined for volumes hosted on drive C:. + if len(volume) >= 2 && string(volume[1]) == ":" && !strings.EqualFold(string(volume[0]), "c") { + continue + } // The volume may have been defined with a C: prefix, which we can't use here. volume = strings.TrimPrefix(volume, "C:") src, err := fs.RootPath(root, volume)