@@ -303,26 +303,7 @@ func (h *Host) CreateContainer(ctx context.Context, id string, settings *prot.VM
303303 networkNamespace = fmt .Sprintf ("virtual-pod-%s" , virtualPodID )
304304 }
305305
306- // Extract memory limit from sandbox container spec
307- var memoryLimit * int64
308- if settings .OCISpecification .Linux != nil &&
309- settings .OCISpecification .Linux .Resources != nil &&
310- settings .OCISpecification .Linux .Resources .Memory != nil &&
311- settings .OCISpecification .Linux .Resources .Memory .Limit != nil {
312- memoryLimit = settings .OCISpecification .Linux .Resources .Memory .Limit
313- logrus .WithFields (logrus.Fields {
314- "containerID" : id ,
315- "virtualPodID" : virtualPodID ,
316- "memoryLimit" : * memoryLimit ,
317- }).Info ("Extracted memory limit from sandbox container spec" )
318- } else {
319- logrus .WithFields (logrus.Fields {
320- "containerID" : id ,
321- "virtualPodID" : virtualPodID ,
322- }).Info ("No memory limit found in sandbox container spec" )
323- }
324-
325- if err := h .CreateVirtualPod (ctx , virtualPodID , virtualPodID , networkNamespace , memoryLimit ); err != nil {
306+ if err := h .CreateVirtualPod (ctx , virtualPodID , virtualPodID , networkNamespace , settings .OCISpecification ); err != nil {
326307 return nil , errors .Wrapf (err , "failed to create virtual pod %s" , virtualPodID )
327308 }
328309 }
@@ -1305,7 +1286,7 @@ func (h *Host) InitializeVirtualPodSupport(virtualPodsCgroup cgroups.Cgroup) {
13051286}
13061287
13071288// 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 {
1289+ func (h * Host ) CreateVirtualPod (ctx context.Context , virtualSandboxID , masterSandboxID , networkNamespace string , pSpec * specs. Spec ) error {
13091290 h .virtualPodsMutex .Lock ()
13101291 defer h .virtualPodsMutex .Unlock ()
13111292
@@ -1327,18 +1308,15 @@ func (h *Host) CreateVirtualPod(ctx context.Context, virtualSandboxID, masterSan
13271308 }
13281309 cgroupPath := path .Join (parentPath , virtualSandboxID )
13291310
1330- // Create the cgroup for this virtual pod with memory limit if provided
1311+ // Create the cgroup for this virtual pod with resource limits if provided
13311312 resources := & specs.LinuxResources {}
1332- if memoryLimit != nil {
1333- resources .Memory = & specs.LinuxMemory {
1334- Limit : memoryLimit ,
1335- }
1313+ if pSpec != nil && pSpec .Linux != nil && pSpec .Linux .Resources != nil {
1314+ resources = pSpec .Linux .Resources
13361315 logrus .WithFields (logrus.Fields {
13371316 "virtualSandboxID" : virtualSandboxID ,
1338- "memoryLimit" : * memoryLimit ,
1339- }).Info ("Creating virtual pod with memory limit" )
1317+ }).Info ("Creating virtual pod with specified resources" )
13401318 } else {
1341- logrus .WithField ("virtualSandboxID" , virtualSandboxID ).Info ("Creating virtual pod without memory limit " )
1319+ logrus .WithField ("virtualSandboxID" , virtualSandboxID ).Info ("Creating pod cgroup with default resources as none were specified " )
13421320 }
13431321
13441322 cgroupControl , err := cgroups .New (cgroups .StaticPath (cgroupPath ), resources )
0 commit comments