Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fill in HyperV runtime spec field if shim options asks for it #1388

Merged
merged 1 commit into from
May 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fill in HyperV field if sandbox option is set
As part of the work to get WCOW-Hypervisor working for the upstream
Containerd CRI plugin, parse our shims SandboxIsolation field here and
set HyperV if it hasn't been set. This avoids us needind one place
we need to parse our shim specific options in Containerd which is
always nice.

Signed-off-by: Daniel Canter <dcanter@microsoft.com>
  • Loading branch information
dcantah committed May 6, 2022
commit 9a8869fef5a0167921490a84e96b0d0181ee2644
25 changes: 14 additions & 11 deletions cmd/containerd-shim-runhcs-v1/service_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even for LCOW?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like old code did do that lol. i dont remember why

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We identify LCOW by the Linux section being filled in as well as hyperv. Which kinda makes sense in my head hahah

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I am dumb. yes I know why this works lol. I for some reason thought that spec.Windows.HyperV was outside of spec.Windows and you didnt need the Windows part to add the HyperV part. Just ignore me.

}
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
Expand Down Expand Up @@ -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{}
}
Expand Down