From 18f47614a2a08233b53edc47d27a7c68d4802c9f Mon Sep 17 00:00:00 2001 From: Danny Canter <36526702+dcantah@users.noreply.github.com> Date: Fri, 6 May 2022 11:05:49 -0700 Subject: [PATCH] Fill in HyperV field if sandbox option is set (#1388) As part of the work to get WCOW-Hypervisor working for the upstream Containerd CRI plugin, parse our shims SandboxIsolation field here and set the HyperV runtime spec field if it's set to the HYPERVISOR option. This avoids us needing to parse our shim specific options in upstream Containerd which is always a plus. Signed-off-by: Daniel Canter --- .../service_internal.go | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/cmd/containerd-shim-runhcs-v1/service_internal.go b/cmd/containerd-shim-runhcs-v1/service_internal.go index 3c64932e80..d216bb626c 100644 --- a/cmd/containerd-shim-runhcs-v1/service_internal.go +++ b/cmd/containerd-shim-runhcs-v1/service_internal.go @@ -104,6 +104,18 @@ func (s *service) createInternal(ctx context.Context, req *task.CreateTaskReques return nil, errors.Wrap(err, "unable to process OCI Spec annotations") } + // If sandbox isolation is set to hypervisor, make sure the HyperV option + // is filled in. This lessens the burden on Containerd to parse our shims + // options if we can set this ourselves. + if shimOpts.SandboxIsolation == runhcsopts.Options_HYPERVISOR { + if spec.Windows == nil { + spec.Windows = &specs.Windows{} + } + if spec.Windows.HyperV == nil { + spec.Windows.HyperV = &specs.WindowsHyperV{} + } + } + if len(req.Rootfs) == 0 { // If no mounts are passed via the snapshotter its the callers full // responsibility to manage the storage. Just move on without affecting @@ -133,17 +145,8 @@ func (s *service) createInternal(ctx context.Context, req *task.CreateTaskReques } } - if m.Type == "lcow-layer" { - // If we are creating LCOW make sure that spec.Windows is filled out before - // appending layer folders. - if spec.Windows == nil { - spec.Windows = &specs.Windows{} - } - if spec.Windows.HyperV == nil { - spec.Windows.HyperV = &specs.WindowsHyperV{} - } - } else if spec.Windows.HyperV == nil { - // This is a Windows Argon make sure that we have a Root filled in. + // This is a Windows Argon make sure that we have a Root filled in. + if spec.Windows.HyperV == nil { if spec.Root == nil { spec.Root = &specs.Root{} }