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
CPU limit in play kube doesn't work #15726
Labels
kind/bug
Categorizes issue or PR as related to a bug.
locked - please file new issue/PR
Assist humans wanting to comment on an old issue or PR with locked comments.
Comments
This feature works well with v3.4.7. SA #11803 |
thanks for the report, I might have messed things up with #11803. Would you mind testing the current patch? diff --git a/libpod/kube.go b/libpod/kube.go
index 1f4831006..b3ba5d405 100644
--- a/libpod/kube.go
+++ b/libpod/kube.go
@@ -720,7 +720,7 @@ func containerToV1Container(ctx context.Context, c *Container) (v1.Container, []
period := *c.config.Spec.Linux.Resources.CPU.Period
if quota > 0 && period > 0 {
- cpuLimitMilli := int64(1000 * util.PeriodAndQuotaToCores(period, quota))
+ cpuLimitMilli := 1000 * int64(util.PeriodAndQuotaToCores(period, quota))
// Kubernetes: precision finer than 1m is not allowed
if cpuLimitMilli >= 1 {
diff --git a/pkg/specgen/generate/kube/kube.go b/pkg/specgen/generate/kube/kube.go
index 9fd0adecf..904467527 100644
--- a/pkg/specgen/generate/kube/kube.go
+++ b/pkg/specgen/generate/kube/kube.go
@@ -212,7 +212,7 @@ func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGener
return nil, fmt.Errorf("failed to set CPU quota: %w", err)
}
if milliCPU > 0 {
- period, quota := util.CoresToPeriodAndQuota(float64(milliCPU))
+ period, quota := util.CoresToPeriodAndQuota(float64(milliCPU) / 1000)
s.ResourceLimits.CPU = &spec.LinuxCPU{
Quota: "a,
Period: &period, |
Opened PR with fix #15728 (changes like yours, but a little slightly different). |
tyler92
added a commit
to tyler92/podman
that referenced
this issue
Sep 10, 2022
[NO NEW TESTS NEEDED] Fixes: containers#15726 Signed-off-by: Mikhail Khachayants <tyler92@inbox.ru>
github-actions
bot
added
the
locked - please file new issue/PR
Assist humans wanting to comment on an old issue or PR with locked comments.
label
Sep 16, 2023
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
kind/bug
Categorizes issue or PR as related to a bug.
locked - please file new issue/PR
Assist humans wanting to comment on an old issue or PR with locked comments.
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
Limitation of CPU consumption doesn't work if it's used in play kube yaml.
Steps to reproduce the issue:
Launch podman play kube with this yaml.
Observe CPU load for container.
Describe the results you received:
CPU load is about 100%.
Describe the results you expected:
CPU load is about 30%.
Additional information you deem important (e.g. issue happens only occasionally):
Output of
podman version
:Output of
podman info
:Package info (e.g. output of
rpm -q podman
orapt list podman
):Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)
Yes
The text was updated successfully, but these errors were encountered: