Bug 1311456
Summary: | Should give proper message when create a limit resource with defaultLimit and Pod type specified | ||
---|---|---|---|
Product: | OKD | Reporter: | Qixuan Wang <qixuan.wang> |
Component: | Pod | Assignee: | Derek Carr <decarr> |
Status: | CLOSED NOTABUG | QA Contact: | DeShuai Ma <dma> |
Severity: | low | Docs Contact: | |
Priority: | medium | ||
Version: | 3.x | CC: | aos-bugs, mmccomas |
Target Milestone: | --- | Keywords: | Reopened |
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2016-04-07 14:49:09 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Qixuan Wang
2016-02-24 09:56:58 UTC
The field name that defaults limits is called "default" and not "defaultLimit" for historical reasons because it actually pre-dates the presence of request and limit in the API. As a result, the converter was just dropping fields it did not understand. $ cat limitrange-1.yaml apiVersion: v1 kind: LimitRange metadata: name: limitrange-1 spec: limits: - max: cpu: 500m memory: 750Mi min: cpu: 10m memory: 5Mi default: cpu: 200m memory: 400Mi maxLimitRequestRatio: cpu: 2 memory: 5 type: Pod - default: cpu: 130m memory: 120Mi defaultRequest: cpu: 110m memory: 100Mi maxLimitRequestRatio: cpu: 10 memory: 8 max: cpu: 400m memory: 750Mi min: cpu: 10m memory: 5Mi type: Container $ cluster/kubectl.sh create -f limitrange-1.yaml The LimitRange "limitrange-1" is invalid. spec.limits[0].default: Forbidden: may not be specified when `type` is 'Pod' If you drop the field from limitType=pod, you get the following: $ cat limitrange-1.yaml apiVersion: v1 kind: LimitRange metadata: name: limitrange-1 spec: limits: - max: cpu: 500m memory: 750Mi min: cpu: 10m memory: 5Mi maxLimitRequestRatio: cpu: 2 memory: 5 type: Pod - default: cpu: 130m memory: 120Mi defaultRequest: cpu: 110m memory: 100Mi maxLimitRequestRatio: cpu: 10 memory: 8 max: cpu: 400m memory: 750Mi min: cpu: 10m memory: 5Mi type: Container $ cluster/kubectl.sh create -f limitrange-1.yaml limitrange "limitrange-1" created $ cluster/kubectl.sh describe limits/limitrange-1 Name: limitrange-1 Namespace: default Type Resource Min Max Default Request Default Limit Max Limit/Request Ratio ---- -------- --- --- --------------- ------------- ----------------------- Pod cpu 10m 500m - - 2 Pod memory 5Mi 750Mi - - 5 Container cpu 10m 400m 110m 130m 10 Container memory 5Mi 750Mi 100Mi 120Mi 8 Thanks for your detailed explanation. If limitType=Container and set DefaultLimit, the value of course is ignored, but the new value is the same with value of Max. Why does it get from Max(Default request and limit are all from Max if didn't set them, probably it's by design)? Should it has a clear message indicates that DefaultLimit is incorrect? # cat limitrange-2.yaml apiVersion: v1 kind: LimitRange metadata: name: limitrange-2 spec: limits: - defaultLimit: cpu: 130m memory: 120Mi defaultRequest: cpu: 110m memory: 100Mi maxLimitRequestRatio: cpu: 10 memory: 8 max: cpu: 400m memory: 750Mi min: cpu: 10m memory: 5Mi type: Container # oc describe limits limitrange-2 Name: limitrange-2 Namespace: qwang3 Type Resource Min Max Default Request Default Limit Max Limit/Request Ratio ---- -------- --- --- --------------- ------------- ----------------------- Container memory 5Mi 750Mi 100Mi 750Mi 8 Container cpu 10m 400m 110m 400m 10 # oc get limits limitrange-2 -o yaml apiVersion: v1 kind: LimitRange metadata: creationTimestamp: 2016-02-25T03:14:00Z name: limitrange-2 namespace: qwang3 resourceVersion: "62696" selfLink: /api/v1/namespaces/qwang3/limitranges/limitrange-2 uid: d0ef10f3-db6d-11e5-80ba-fa163e76dd6a spec: limits: - default: cpu: 400m memory: 750Mi defaultRequest: cpu: 110m memory: 100Mi max: cpu: 400m memory: 750Mi maxLimitRequestRatio: cpu: "10" memory: "8" min: cpu: 10m memory: 5Mi type: Container This is working as designed: see https://github.com/kubernetes/kubernetes/blob/master/docs/design/admission_control_limit_range.md#default-value-behavior Let me explain the rationale behind the current behavior. If you specify a MAX[memory] for a container of 500Mi, then every container must make an explicit resources.limit[memory] <= 500Mi. To make that convenient for users, we will default the default LIMIT[memory] for a container to match the MAX if not specified. |