@@ -322,7 +322,7 @@ func (h *Host) CreateContainer(ctx context.Context, id string, settings *prot.VM
322322 }).Info ("No memory limit found in sandbox container spec" )
323323 }
324324
325- if err := h .CreateVirtualPod (ctx , virtualPodID , virtualPodID , networkNamespace , memoryLimit ); err != nil {
325+ if err := h .CreateVirtualPod (ctx , virtualPodID , virtualPodID , networkNamespace , settings . OCISpecification ); err != nil {
326326 return nil , errors .Wrapf (err , "failed to create virtual pod %s" , virtualPodID )
327327 }
328328 }
@@ -1305,7 +1305,7 @@ func (h *Host) InitializeVirtualPodSupport(virtualPodsCgroup cgroups.Cgroup) {
13051305}
13061306
13071307// CreateVirtualPod creates a new virtual pod with its own cgroup and network namespace
1308- func (h * Host ) CreateVirtualPod (ctx context.Context , virtualSandboxID , masterSandboxID , networkNamespace string , memoryLimit * int64 ) error {
1308+ func (h * Host ) CreateVirtualPod (ctx context.Context , virtualSandboxID , masterSandboxID , networkNamespace string , pSpec * specs. Spec ) error {
13091309 h .virtualPodsMutex .Lock ()
13101310 defer h .virtualPodsMutex .Unlock ()
13111311
@@ -1327,18 +1327,15 @@ func (h *Host) CreateVirtualPod(ctx context.Context, virtualSandboxID, masterSan
13271327 }
13281328 cgroupPath := path .Join (parentPath , virtualSandboxID )
13291329
1330- // Create the cgroup for this virtual pod with memory limit if provided
1330+ // Create the cgroup for this virtual pod with resource limits if provided
13311331 resources := & specs.LinuxResources {}
1332- if memoryLimit != nil {
1333- resources .Memory = & specs.LinuxMemory {
1334- Limit : memoryLimit ,
1335- }
1332+ if pSpec != nil && pSpec .Linux != nil && pSpec .Linux .Resources != nil {
1333+ resources = pSpec .Linux .Resources
13361334 logrus .WithFields (logrus.Fields {
13371335 "virtualSandboxID" : virtualSandboxID ,
1338- "memoryLimit" : * memoryLimit ,
1339- }).Info ("Creating virtual pod with memory limit" )
1336+ }).Info ("Creating virtual pod with specified resources" )
13401337 } else {
1341- logrus .WithField ("virtualSandboxID" , virtualSandboxID ).Info ("Creating virtual pod without memory limit " )
1338+ logrus .WithField ("virtualSandboxID" , virtualSandboxID ).Info ("Creating pod cgroup with default resources as none were specified " )
13421339 }
13431340
13441341 cgroupControl , err := cgroups .New (cgroups .StaticPath (cgroupPath ), resources )
0 commit comments