99 "os"
1010 "path/filepath"
1111
12- "github.com/Microsoft/hcsshim/internal/controller/linuxcontainer"
13- "github.com/Microsoft/hcsshim/internal/controller/network"
12+ container "github.com/Microsoft/hcsshim/internal/controller/linuxcontainer"
1413 "github.com/Microsoft/hcsshim/internal/controller/pod"
1514 "github.com/Microsoft/hcsshim/internal/controller/process"
1615 "github.com/Microsoft/hcsshim/internal/hcs"
@@ -34,7 +33,7 @@ import (
3433)
3534
3635// getContainerController looks up the container controller for the given container ID.
37- func (s * Service ) getContainerController (containerID string ) (* linuxcontainer .Controller , error ) {
36+ func (s * Service ) getContainerController (containerID string ) (* container .Controller , error ) {
3837 s .mu .RLock ()
3938 defer s .mu .RUnlock ()
4039
@@ -118,7 +117,7 @@ func (s *Service) createInternal(ctx context.Context, request *task.CreateTaskRe
118117 s .mu .Lock ()
119118 defer s .mu .Unlock ()
120119
121- var ctrCtrl * linuxcontainer .Controller
120+ var ctrCtrl * container .Controller
122121
123122 switch ct {
124123 case oci .KubernetesContainerTypeSandbox :
@@ -138,13 +137,10 @@ func (s *Service) createInternal(ctx context.Context, request *task.CreateTaskRe
138137 }
139138
140139 // Create a new pod.
141- podCtrl := pod .New (sid , s .vmController )
140+ podCtrl := pod .New (sid , spec . Windows . Network . NetworkNamespace , s .vmController )
142141
143142 // Setup network for the pod based on the provided namespace.
144- err = podCtrl .SetupNetwork (ctx , & network.SetupOptions {
145- NetworkNamespace : spec .Windows .Network .NetworkNamespace ,
146- PolicyBasedRouting : s .sandboxOptions .PolicyBasedRouting ,
147- })
143+ err = podCtrl .SetupNetwork (ctx )
148144 if err != nil {
149145 // No cleanup on failure since containerd will send a Delete request.
150146 return nil , fmt .Errorf ("failed to setup network for pod %s: %w" , sid , err )
@@ -180,13 +176,20 @@ func (s *Service) createInternal(ctx context.Context, request *task.CreateTaskRe
180176 return nil , fmt .Errorf ("unsupported container type %q: %w" , ct , errdefs .ErrInvalidArgument )
181177 }
182178
179+ // Get EnableScratchEncryption option.
180+ var enableScratchEncryption bool
181+ sandboxOpts := s .vmController .SandboxOptions ()
182+ if sandboxOpts != nil {
183+ enableScratchEncryption = sandboxOpts .EnableScratchEncryption
184+ }
185+
183186 // Call Create on the container controller.
184187 if err := ctrCtrl .Create (
185188 ctx ,
186189 & spec ,
187190 request ,
188- & linuxcontainer .CreateOpts {
189- IsScratchEncryptionEnabled : s . sandboxOptions . EnableScratchEncryption ,
191+ & container .CreateOpts {
192+ IsScratchEncryptionEnabled : enableScratchEncryption ,
190193 },
191194 ); err != nil {
192195 return nil , fmt .Errorf ("failed to create container %s: %w" , request .ID , err )
@@ -411,7 +414,7 @@ func (s *Service) killInternal(ctx context.Context, request *task.KillRequest) (
411414
412415 // If "all" is set and this is a sandbox (pod) container, collect all
413416 // workload containers so we can fan out the kill to the entire pod.
414- var workloadContainers map [string ]* linuxcontainer .Controller
417+ var workloadContainers map [string ]* container .Controller
415418 if request .All {
416419 if podCtrl , ok := s .getPodController (request .ID ); ok {
417420 workloadContainers = podCtrl .ListContainers ()
0 commit comments