Skip to content

Commit 18f4761

Browse files
authored
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 <[email protected]>
1 parent d12d411 commit 18f4761

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

cmd/containerd-shim-runhcs-v1/service_internal.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,18 @@ func (s *service) createInternal(ctx context.Context, req *task.CreateTaskReques
104104
return nil, errors.Wrap(err, "unable to process OCI Spec annotations")
105105
}
106106

107+
// If sandbox isolation is set to hypervisor, make sure the HyperV option
108+
// is filled in. This lessens the burden on Containerd to parse our shims
109+
// options if we can set this ourselves.
110+
if shimOpts.SandboxIsolation == runhcsopts.Options_HYPERVISOR {
111+
if spec.Windows == nil {
112+
spec.Windows = &specs.Windows{}
113+
}
114+
if spec.Windows.HyperV == nil {
115+
spec.Windows.HyperV = &specs.WindowsHyperV{}
116+
}
117+
}
118+
107119
if len(req.Rootfs) == 0 {
108120
// If no mounts are passed via the snapshotter its the callers full
109121
// responsibility to manage the storage. Just move on without affecting
@@ -133,17 +145,8 @@ func (s *service) createInternal(ctx context.Context, req *task.CreateTaskReques
133145
}
134146
}
135147

136-
if m.Type == "lcow-layer" {
137-
// If we are creating LCOW make sure that spec.Windows is filled out before
138-
// appending layer folders.
139-
if spec.Windows == nil {
140-
spec.Windows = &specs.Windows{}
141-
}
142-
if spec.Windows.HyperV == nil {
143-
spec.Windows.HyperV = &specs.WindowsHyperV{}
144-
}
145-
} else if spec.Windows.HyperV == nil {
146-
// This is a Windows Argon make sure that we have a Root filled in.
148+
// This is a Windows Argon make sure that we have a Root filled in.
149+
if spec.Windows.HyperV == nil {
147150
if spec.Root == nil {
148151
spec.Root = &specs.Root{}
149152
}

0 commit comments

Comments
 (0)