diff --git a/pkg/unikontainers/unikontainers.go b/pkg/unikontainers/unikontainers.go index 85dc1e2a..44cc1360 100644 --- a/pkg/unikontainers/unikontainers.go +++ b/pkg/unikontainers/unikontainers.go @@ -71,6 +71,10 @@ func New(bundlePath string, containerID string, rootDir string, cfg *UruncConfig return nil, err } + if spec.Linux == nil { + return nil, fmt.Errorf("Linux platform is required for urunc containers") + } + containerName := spec.Annotations["io.kubernetes.cri.container-name"] if containerName == "queue-proxy" { uniklog.Warn("This is a queue-proxy container. Adding IP env.") @@ -260,7 +264,7 @@ func (u *Unikontainer) Exec(metrics m.Writer) error { // ExecArgs // If memory limit is set in spec, use it instead of the config default value - if u.Spec.Linux.Resources.Memory != nil { + if u.Spec.Linux.Resources != nil && u.Spec.Linux.Resources.Memory != nil { if u.Spec.Linux.Resources.Memory.Limit != nil { if *u.Spec.Linux.Resources.Memory.Limit > 0 { vmmArgs.MemSizeB = uint64(*u.Spec.Linux.Resources.Memory.Limit) // nolint:gosec @@ -454,10 +458,10 @@ func (u *Unikontainer) Exec(metrics m.Writer) error { vmmArgs.Command = unikernelCmd // pivot - _, err = findNS(u.Spec.Linux.Namespaces, specs.MountNamespace) - // We just want to check if a mount namespace was define din the list + // We just want to check if a mount namespace was defined in the list. // Therefore, if there was no error and the mount namespace was found // we can pivot. + _, err = findNS(u.Spec.Linux.Namespaces, specs.MountNamespace) withPivot := err != nil err = changeRoot(rootfsParams.MonRootfs, withPivot) if err != nil {