kubernetes / kubernetes/kubectl
Describe Node Pod Resource Sum Incorrect/Confusing
- Dominant language
- Go
- Stars
- 3.3k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
**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 ` 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
Contributor guide
Research direction
Start with the `kubectl describe node ` output using the reproduction Pod spec in this issue, and trace how requests and limits are summarized. Check the existing handling of unset versus zero values, then verify that a Pod with an unset container limit is not reported as limited while preserving the displayed request totals.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100