kubernetes: Giving the wrong unit under resource limits is not erroring, instead the pod creation fails.

Is this a BUG REPORT or FEATURE REQUEST?: /kind bug

What happened: I specified resource limits with wrong unit. Like below

resources:
      requests:
        memory: "64m"
        cpu: "250m"
      limits:
        memory: "128m"
        cpu: "500m"

Instead of Mi I gave m under memory limits in the pod definition. It didn’t show any error while trying to create the deployment. But the container never came up. It was continuously in the ContainerCreating mode.

Checking the pod description didn’t give anything that is useful.

Events:
  FirstSeen     LastSeen        Count   From                                            SubObjectPath   Type            Reason                  Message
  ---------     --------        -----   ----                                            -------------   --------        ------                  -------
  22s           22s             1       default-scheduler                                               Normal          Scheduled               Successfully assigned xxxxxx-56b4864dd9-9x5gs to gke-xxxxxxx-default-pool-53b7e787-580g
  22s           22s             1       kubelet, gke-xxxxxxx-default-pool-53b7e787-580g                 Normal          SuccessfulMountVolume   MountVolume.SetUp succeeded for volume "default-token-cwtq0"
  21s           1s              21      kubelet, gke-xxxxxxx-default-pool-53b7e787-580g                 Warning         FailedSync              Error syncing
pod
  20s           0s              21      kubelet, gke-xxxxxxx-default-pool-53b7e787-580g                 Normal          SandboxChanged          Pod sandbox changed, it will be killed and re-created.

What you expected to happen: The kubectl should check for the syntax error and should display the error while trying to create the deployment.

How to reproduce it (as minimally and precisely as possible): Create a yml file with resource limits unit m for memory. Example 200m. Try to create the deployment using kubectl create -f file.yml

Anything else we need to know?:

Environment:

  • Kubernetes version (use kubectl version): v1.8.1-gke.0
  • Cloud provider or hardware configuration**: GKE
  • OS (e.g. from /etc/os-release): Mac OS, High Sierra
  • Kernel (e.g. uname -a): Darwin MacBookPro 17.0.0 Darwin Kernel Version 17.0.0: Thu Aug 24 21:48:19 PDT 2017; root:xnu-4570.1.46~2/RELEASE_X86_64 x86_64 i386 MacBookPro11,4 Darwin
  • Install tools:
  • Others:

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 17 (3 by maintainers)

Most upvoted comments

Hi, we’re operating a multi-tenant cluster and I suspect one of our users has done the same as @MansoorMajeed . I noticed because kubectl describe shows me an overall memory request for the node of 31268536322048m (15%), which is odd , since it uses “m” as the unit. Here’s the full output:

(...)
Capacity:
 cpu:                40
 ephemeral-storage:  1921802500Ki
 hugepages-1Gi:      0
 hugepages-2Mi:      0
 memory:             196736540Ki
 pods:               110
Allocatable:
 cpu:                40
 ephemeral-storage:  1771133181068
 hugepages-1Gi:      0
 hugepages-2Mi:      0
 memory:             196634140Ki
 pods:               110
(...)
Allocated resources:
  (Total limits may be over 100 percent, i.e., overcommitted.)
  CPU Requests  CPU Limits     Memory Requests        Memory Limits
  ------------  ----------     ---------------        -------------
  17770m (44%)  48530m (121%)  31268536322048m (15%)  92796Mi (48%)

Running K8s 1.10.1 here.

Not sure if this is really related, but it seems that when I specify memory requests like so:

(...)
resources:
  requests:
    cpu: 1700m
    memory: 4.70Gi

the kubectl describe command outputs the requests with m as unit also.

(...)
Requests:
  cpu:      1700m
  memory:   5046586572800m
(...)

Running Kubernetes v1.10.2.