kubernetes / kubectl

Issue tracker and mirror of kubectl code
Apache License 2.0
2.89k stars 924 forks source link

Describe Node Pod Resource Sum Incorrect/Confusing #1385

Open fwiesel opened 1 year ago

fwiesel commented 1 year ago

What happened:

If you have a node with a pod which has limits unset (ergo is not limited) in some containers, the kubectl describe node <node-name> command will simply sum the limits of the containers and display them showing a potentially confusing summary, by counting unset values as zero.

That is incorrect / confusing in two ways

  1. The sum over the limits can be lower than the requests in total
  2. The pod is shown as limited in its total resource usage, while it isn't due to an unset limit in a container

What you expected to happen:

I would expect that if a container in pod does not have a limit set on a resource, that the pod in total is also not shown as limited in the usage of the resource, since the resource-usage of the pod as a whole is also not limited.

How to reproduce it (as minimally and precisely as possible):

Given the spec:

apiVersion: v1
kind: Pod
metadata:
  name: test-describe-node
spec:
  containers:
  - name: requests
    image: busybox:latest
    resources:
      requests:
        cpu: "1"
        memory: 1Gi
  - name: limits
    image: busybox:latest
    resources:
      limits:
        cpu: 250m
        memory: 256Mi

kubectl get pod test-describe-node -o=jsonpath='{.spec.nodeName}' | xargs kubectl describe node | grep -A1 -E 'Namespace|test-describe-node'

Shows (removed namespace to make it shorter)

 Name                      CPU Requests  CPU Limits   Memory Requests  Memory Limits  Age
 ----                      ------------  ----------   ---------------  -------------  ---
 test-describe-node        1250m (12%)   250m (2%)    1280Mi (2%)      256Mi (0%)     4m29s

To stay backward compatible, I would expect something this

 Name                      CPU Requests  CPU Limits   Memory Requests  Memory Limits  Age
 ----                      ------------  ----------   ---------------  -------------  ---
 test-describe-node        1250m (12%)   0m (0%)       1280Mi (2%)         0Mi (0%)   4m29s

But it raises the question, if treating unset and 0 the same is warranted also in the UI, and I was seeing somewhere in the code - used as denoting unset.

 Name                      CPU Requests  CPU Limits   Memory Requests  Memory Limits  Age
 ----                      ------------  ----------   ---------------  -------------  ---
 test-describe-node        1250m (12%)   -            1280Mi (2%)      -              4m29s

Anything else we need to know?:

Environment:

Client Version: v1.25.6
Server Version: v1.25.6

on Baremetal

mpuckett159 commented 1 year ago

Thank you for opening this issue, we will be discussing this more in depth on the biweekly meeting.

k8s-triage-robot commented 1 year ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot commented 10 months ago

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

mpuckett159 commented 6 months ago

/remove-lifecycle rotten /triage accepted

Apologies this got forgotten about. We are rehashing this discussion and will try to come to a decision soon.

saiaunghlyanhtet commented 2 weeks ago

/remove-lifecycle rotten /triage accepted

Apologies this got forgotten about. We are rehashing this discussion and will try to come to a decision soon.

I would like to confirm if you have come to a decision for this issue.