Skip to content

shim: skip SandboxPlatform validation when platform is not explicitly set#2620

Merged
helsaawy merged 1 commit intomicrosoft:mainfrom
rzlink:fix-sandbox-platform-inference
Mar 6, 2026
Merged

shim: skip SandboxPlatform validation when platform is not explicitly set#2620
helsaawy merged 1 commit intomicrosoft:mainfrom
rzlink:fix-sandbox-platform-inference

Conversation

@rzlink
Copy link
Contributor

@rzlink rzlink commented Mar 4, 2026

Summary

Fixes #2619

When containerd's default runhcs-wcow-hypervisor runtime config sets SandboxIsolation=1 without SandboxPlatform, the shim options are non-empty but SandboxPlatform is "". The platform validation added in PR #2473 unconditionally calls platforms.Parse("") which fails, breaking all Hyper-V isolated containers on stock containerd v2.2.1+.

Changes

In createInternal(), add a guard to skip platform validation when SandboxPlatform is empty:

-if !emptyShimOpts {
+if !emptyShimOpts && shimOpts.GetSandboxPlatform() != "" {

When SandboxPlatform is not explicitly configured, there is nothing meaningful to validate -- inferring the platform from the OCI spec and then validating the spec against the inference would be tautologically true (as noted by @helsaawy in review).

Root Cause

containerd's config_windows.go defaults:

"runhcs-wcow-hypervisor": {
    Options: map[string]interface{}{
        "SandboxIsolation": 1,         // set
        // SandboxPlatform is NOT set  // missing!
    },
},

This makes emptyShimOpts = false (options are non-empty due to SandboxIsolation), but SandboxPlatform is "", causing the validation to fail.

Testing

  • Tested on Windows Server 2022 and 2025 CAPZ clusters with containerd v2.2.1
  • Before fix: invalid runtime sandbox platform: "" error on every Hyper-V pod
  • After fix: Hyper-V pods create and run successfully
  • Full Kubernetes e2e [Feature:WindowsHyperVContainers] test suite passes with the patched shim

@rzlink rzlink requested a review from a team as a code owner March 4, 2026 21:32
@rzlink rzlink force-pushed the fix-sandbox-platform-inference branch from 25e49d5 to c53a9dc Compare March 4, 2026 21:40
@msscotb msscotb assigned helsaawy, anmaxvl and rawahars and unassigned anmaxvl Mar 5, 2026
@helsaawy helsaawy self-requested a review March 5, 2026 19:08
… set

When runtime options are non-empty (e.g., SandboxIsolation is set) but
SandboxPlatform is empty, skip the platform validation rather than
failing. The validation only needs to check that the spec and shim
options match when SandboxPlatform is explicitly configured.

containerd's default config (config_windows.go) sets SandboxIsolation=1
for the runhcs-wcow-hypervisor runtime handler but omits SandboxPlatform,
making options non-empty with an empty platform string. This causes
platforms.Parse("") to fail with 'invalid runtime sandbox platform'.

Signed-off-by: Dawei Wei <wei.dawei.cn@gmail.com>
@rzlink rzlink force-pushed the fix-sandbox-platform-inference branch from c53a9dc to 76b1208 Compare March 6, 2026 00:33
@rzlink rzlink changed the title shim: infer SandboxPlatform from OCI spec when not explicitly set shim: skip SandboxPlatform validation when platform is not explicitly set Mar 6, 2026
@rzlink rzlink requested a review from helsaawy March 6, 2026 00:38
@helsaawy helsaawy merged commit 88c818f into microsoft:main Mar 6, 2026
17 checks passed
@rzlink rzlink deleted the fix-sandbox-platform-inference branch March 6, 2026 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

shim: SandboxPlatform validation fails when containerd sets SandboxIsolation without SandboxPlatform

5 participants