From 2862d98443ccdb1162963ee979639fd973ddc37b Mon Sep 17 00:00:00 2001 From: Krisztian Litkey Date: Thu, 4 May 2023 18:14:16 +0300 Subject: [PATCH] api: initialize OCI LinuxMemory resources to empty. When converting to OCI LinuxResources, always use an empty &LinuxMemory{} instead of a nil one. Some runtimes try to dereference it unconditionally. Leaving it unset panics on these. Signed-off-by: Krisztian Litkey --- pkg/api/resources.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/api/resources.go b/pkg/api/resources.go index 1aa9cb0d..41acddd0 100644 --- a/pkg/api/resources.go +++ b/pkg/api/resources.go @@ -100,7 +100,10 @@ func (r *LinuxResources) ToOCI() *rspec.LinuxResources { if r == nil { return nil } - o := &rspec.LinuxResources{} + o := &rspec.LinuxResources{ + CPU: &rspec.LinuxCPU{}, + Memory: &rspec.LinuxMemory{}, + } if r.Memory != nil { o.Memory = &rspec.LinuxMemory{ Limit: r.Memory.Limit.Get(),