Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore cpu realtime options on cgroups V2 systems #15713

Merged
merged 1 commit into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
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
16 changes: 15 additions & 1 deletion pkg/specgen/generate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func verifyContainerResourcesCgroupV1(s *specgen.SpecGenerator) ([]string, error
}
}

// CPU Checks
// CPU checks
if s.ResourceLimits.CPU != nil {
cpu := s.ResourceLimits.CPU
if cpu.Shares != nil && !sysInfo.CPUShares {
Expand Down Expand Up @@ -169,6 +169,7 @@ func verifyContainerResourcesCgroupV2(s *specgen.SpecGenerator) ([]string, error
return warnings, nil
}

// Memory checks
if s.ResourceLimits.Memory != nil && s.ResourceLimits.Memory.Swap != nil {
own, err := utils.GetOwnCgroup()
if err != nil {
Expand Down Expand Up @@ -198,6 +199,19 @@ func verifyContainerResourcesCgroupV2(s *specgen.SpecGenerator) ([]string, error
s.ResourceLimits.Memory.Swap = nil
}
}

// CPU checks
if s.ResourceLimits.CPU != nil {
cpu := s.ResourceLimits.CPU
if cpu.RealtimePeriod != nil {
warnings = append(warnings, "Realtime period not supported on cgroups V2 systems")
cpu.RealtimePeriod = nil
}
if cpu.RealtimeRuntime != nil {
warnings = append(warnings, "Realtime runtime not supported on cgroups V2 systems")
cpu.RealtimeRuntime = nil
}
}
return warnings, nil
}

Expand Down
16 changes: 16 additions & 0 deletions test/e2e/run_cpu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,20 @@ var _ = Describe("Podman run cpu", func() {
result.WaitWithDefaultTimeout()
Expect(result).To(ExitWithError())
})

It("podman run invalid cpu-rt-period with cgroupsv2", func() {
SkipIfCgroupV1("testing options that only work in cgroup v2")
result := podmanTest.Podman([]string{"run", "--rm", "--cpu-rt-period=5000", ALPINE, "ls"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result.ErrorToString()).To(ContainSubstring("Realtime period not supported on cgroups V2 systems"))
})

It("podman run invalid cpu-rt-runtime with cgroupsv2", func() {
SkipIfCgroupV1("testing options that only work in cgroup v2")
result := podmanTest.Podman([]string{"run", "--rm", "--cpu-rt-runtime=5000", ALPINE, "ls"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result.ErrorToString()).To(ContainSubstring("Realtime runtime not supported on cgroups V2 systems"))
})
})