Bug 1260384 - Resource requirement request for cpu can exceed the limit
Resource requirement request for cpu can exceed the limit
Status: CLOSED CURRENTRELEASE
Product: OpenShift Origin
Classification: Red Hat
Component: Pod (Show other bugs)
3.x
Unspecified Unspecified
medium Severity medium
: ---
: ---
Assigned To: Derek Carr
Jianwei Hou
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-09-06 06:27 EDT by Liang Xia
Modified: 2015-11-23 16:15 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-11-23 16:15:16 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Liang Xia 2015-09-06 06:27:51 EDT
Description of problem:
Resource requirement request for cpu can exceed the limit, while
resource requirement request for memory can not.


Version-Release number of selected component (if applicable):
Client Version: version.Info{Major:"1", Minor:"1+", GitVersion:"v1.1.0-alpha.1.362+2e2def36a904fe-dirty", GitCommit:"2e2def36a904fe9a197da5fc70e433e2e884442f", GitTreeState:"dirty"}
Server Version: version.Info{Major:"1", Minor:"1+", GitVersion:"v1.1.0-alpha.1.362+2e2def36a904fe-dirty", GitCommit:"2e2def36a904fe9a197da5fc70e433e2e884442f", GitTreeState:"dirty"}


How reproducible:
Always


Steps to Reproduce:
1.Create a project.
$ kubectl create -f project.yaml

2.Set resource limit for the project.
$ kubectl create -f limits.yaml -n <project-name>

3.Check the detail of the project
$ kubectl describe project <project-name>

Actual results:
When defaultRequest memory exceed the limit, creation of resource limit will fail with following error:
spec.limits[0].defaultRequest[memory]: invalid value '134217728', Details: default request value 128Mi is greater than default limit value 100Mi

But when defaultRequest cpu exceed the limit, no such kind of error and the resource limit created successfully.
# kubectl describe namespace namespace-demo
Name:    namespace-demo
Labels:    name=namespace-demo
Status:    Active
Resource Limits
 Type        Resource    Min    Max    Request    Limit    Limit/Request
 ----        --------    ---    ---    -------    -----    -------------
 Pod        cpu        10m    500m    60m    100m    -
 Pod        memory        5Mi    750Mi    64Mi    100Mi    -
 Container    cpu        10m    500m    120m    100m    -
 Container    memory        5Mi    750Mi    64Mi    100Mi    -
 Project    cpu        10m    500m    120m    100m    -
 Project    memory        5Mi    750Mi    64Mi    100Mi    -


Expected results:
The creation of resource limit should fail if either cpu or memory's request exceed the limit.


Additional info:
$ cat limits.yaml
apiVersion: v1
kind: LimitRange
metadata:
  name: limits
spec:
  limits:
  - type: Pod
    default:
      cpu: 100m
      memory: 100Mi
    max:
      cpu: 500m
      memory: 750Mi
    min:
      cpu: 10m
      memory: 5Mi
    defaultRequest:
      cpu: 60m
      memory: 64Mi
  - type: Container
    default:
      cpu: 100m
      memory: 100Mi
    max:
      cpu: 500m
      memory: 750Mi
    min:
      cpu: 10m
      memory: 5Mi
    defaultRequest:
      cpu: 120m
      memory: 64Mi
  - type: Project
    default:
      cpu: 100m
      memory: 100Mi
    max:
      cpu: 500m
      memory: 750Mi
    min:
      cpu: 10m
      memory: 5Mi
    defaultRequest:
      cpu: 120m
      memory: 64Mi
Comment 1 Derek Carr 2015-09-08 14:55:54 EDT
Upstream PR opened to fix issue here:
https://github.com/kubernetes/kubernetes/pull/13688

We were improperly handling precision of value.
Comment 2 Liang Xia 2015-09-10 00:56:29 EDT
Tried the same steps with in #comment 0, got the expected errors as below:
The LimitRange "limits" is invalid.
* spec.limits[0].defaultRequest[cpu]: invalid value '240m', Details: default request value 240m is greater than default limit value 100m
* spec.limits[1].defaultRequest[cpu]: invalid value '120m', Details: default request value 120m is greater than default limit value 100m
* spec.limits[2].defaultRequest[cpu]: invalid value '120m', Details: default request value 120m is greater than default limit value 100m


The fix works on version:
Client Version: version.Info{Major:"1", Minor:"1+", GitVersion:"v1.1.0-alpha.1.492+1c420bb33f785b-dirty", GitCommit:"1c420bb33f785b2b383f79814aa9e42dcb191f34", GitTreeState:"dirty"}
Server Version: version.Info{Major:"1", Minor:"1+", GitVersion:"v1.1.0-alpha.1.492+1c420bb33f785b-dirty", GitCommit:"1c420bb33f785b2b383f79814aa9e42dcb191f34", GitTreeState:"dirty"}


Move bug to verified.

Note You need to log in before you can comment on or make changes to this bug.