Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions cmd/ocitools/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,11 @@ func checkLinux(spec rspec.Spec, rootfs string, hostCheck bool) (msgs []string)
}
}

if spec.Linux.Resources != nil {
ms := checkLinuxResources(*spec.Linux.Resources, hostCheck)
msgs = append(msgs, ms...)
}

if spec.Linux.Seccomp != nil {
ms := checkSeccomp(*spec.Linux.Seccomp)
msgs = append(msgs, ms...)
Expand All @@ -381,6 +386,21 @@ func checkLinux(spec rspec.Spec, rootfs string, hostCheck bool) (msgs []string)
return
}

func checkLinuxResources(r rspec.Resources, hostCheck bool) (msgs []string) {
logrus.Debugf("check linux resources")

if r.Memory != nil {
if r.Memory.Limit != nil && r.Memory.Swap != nil && uint64(*r.Memory.Limit) > uint64(*r.Memory.Swap) {
msgs = append(msgs, fmt.Sprintf("Minimum memoryswap should be larger than memory limit"))
}
if r.Memory.Limit != nil && r.Memory.Reservation != nil && uint64(*r.Memory.Reservation) > uint64(*r.Memory.Limit) {
msgs = append(msgs, fmt.Sprintf("Minimum memory limit should be larger than memory reservation"))
}
}

return
}

func checkSeccomp(s rspec.Seccomp) (msgs []string) {
logrus.Debugf("check seccomp")

Expand Down