Skip to content

Conversation

@ChrsMark
Copy link
Member

@ChrsMark ChrsMark commented Feb 7, 2020

Cherry-pick of PR #16128 to 7.x branch. Original message:

What does this PR do?

This PR improves kubernetes.pod.cpu.usage.limit.pct field description to make clear how the pct is calculated when at least one container of a Pod has no limits.

Why is it important?

When at least one container of a Pod has no limits, the situation can be tricky since in such case the limit.pct will fall-back to node.pct.

Example:

apiVersion: v1
kind: Pod
metadata:
  name: cpu-demo3
  namespace: beats
spec:
  containers:
  - name: cpu-demo-ctr
    image: vish/stress
    resources:
      limits:
        cpu: "1"
      requests:
        cpu: "0.5"
    args:
    - -cpus
    - "2"
  - name: cpu-demo-ctr2
    image: vish/stress
    args:
    - -cpus
    - "1"

In this case the sum of CoresLimit calculated at

coresLimit += perfMetrics.ContainerCoresLimit.GetWithDefault(cuid, nodeCores)

will be greater than nodeCores, cause cpu-demo-ctr2 has no limit and hence it will add nodeCores to the sum.
Given this fact, later on at

if coresLimit > nodeCores {
the coresLimit will become equal to nodeCores making cpu.usage.node.pct and cpu.usage.limit.pct to be equal as well.

Related issues

cc @jsoriano @exekias

@ChrsMark ChrsMark requested a review from a team as a code owner February 7, 2020 12:42
Copy link
Contributor

@mtojek mtojek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ship it if CI goes green.

@ChrsMark ChrsMark merged commit aa47e5d into elastic:7.x Feb 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants