Skip to content

Commit

Permalink
Merge pull request containerd#8897 from kinvolk/rata/userns-use-platform
Browse files Browse the repository at this point in the history
cri/sbserver: Use platform instead of GOOS for userns detection
  • Loading branch information
estesp authored Aug 2, 2023
2 parents e12128c + c80a3ec commit 40c85d6
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions pkg/cri/sbserver/sandbox_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"fmt"
"math"
"path/filepath"
goruntime "runtime"
"strings"
"time"

Expand Down Expand Up @@ -144,8 +143,17 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
}
}()

controller, err := c.getSandboxController(sandbox.Config, sandbox.RuntimeHandler)
if err != nil {
return nil, fmt.Errorf("failed to get sandbox controller: %w", err)
}
platform, err := controller.Platform(ctx, sandbox.ID)
if err != nil {
return nil, fmt.Errorf("failed to query sandbox platform: %w", err)
}

userNsEnabled := false
if goruntime.GOOS != "windows" {
if platform.OS == "linux" {
usernsOpts := config.GetLinux().GetSecurityContext().GetNamespaceOptions().GetUsernsOptions()
if usernsOpts != nil && usernsOpts.GetMode() == runtime.NamespaceMode_POD {
userNsEnabled = true
Expand Down Expand Up @@ -233,11 +241,6 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
return nil, fmt.Errorf("unable to save sandbox %q to store: %w", id, err)
}

controller, err := c.getSandboxController(config, r.GetRuntimeHandler())
if err != nil {
return nil, fmt.Errorf("failed to get sandbox controller: %w", err)
}

// Save sandbox metadata to store
if sandboxInfo, err = c.client.SandboxStore().Update(ctx, sandboxInfo, "extensions"); err != nil {
return nil, fmt.Errorf("unable to update extensions for sandbox %q: %w", id, err)
Expand Down

0 comments on commit 40c85d6

Please sign in to comment.