Bug 1311918

Summary: [online_private_546] It's better to show clearer input/calculation if Pod/Container resources exceed to LimitRange
Product: OpenShift Container Platform Reporter: Qixuan Wang <qixuan.wang>
Component: NodeAssignee: Derek Carr <decarr>
Status: CLOSED WONTFIX QA Contact: Qixuan Wang <qixuan.wang>
Severity: low Docs Contact:
Priority: medium    
Version: unspecifiedCC: aos-bugs, gblomqui, jokerman, lmeyer, mmccomas, wmeng
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-07-03 15:10:47 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-25 10:37:05 UTC
Description of problem:
Set limitrange and then create a pod without resources specified, it's better to show clearer input/calculation (e.g. provided ratio) and uniform measurements (binary vs decimal math) if Pod/Container resources exceed to LimitRange.

Version-Release number of selected component (if applicable):
devenv-rhel_3536
oc v1.1.3-274-g209837a
kubernetes v1.2.0-alpha.7-703-gbc4550d

How reproducible:
Always

Steps to Reproduce:
1. Set limit for a project
# cat limitrange.yaml
apiVersion: v1
kind: LimitRange
metadata:
  name: limitrange
spec:
  limits:
  - max:
      cpu: 500m
      memory: 750Mi
    min:
      cpu: 10m
      memory: 5Mi
    maxLimitRequestRatio:
      cpu: 1
      memory: 2
    type: Pod
  - default:
      cpu: 1
      memory: 4Gi
    defaultRequest:
      cpu: 110m
      memory: 100Mi
    maxLimitRequestRatio:
      cpu: 10
      memory: 8
    max:
      cpu: 1
      memory: 4Gi
    min:
      cpu: 10m
      memory: 5Mi
    type: Container


# oc create -f limitrange.yaml -n qwang1 --config=./admin.kubeconfig

2. Check limit resource 
# oc describe limits limitrange -n qwang1

3. Create a pod without resource specified
# cat pod-no-limit-request.yaml
apiVersion: v1
kind: Pod
metadata:
  name: pod-no-limit-request
  labels:
    name: pod-no-limit-request
spec:
  containers:
  - name: pod-no-limit-request
    image: openshift3/mysql-55-rhel7:latest
    env:
    - name: MYSQL_USER
      value: userSUM
      name: MYSQL_PASSWORD
      value: P5J6s8wf
      name: MYSQL_DATABASE
      value: root
      name: MYSQL_ROOT_PASSWORD
      value: W5J6s8wf
    resources: {}

# oc create -f pod-no-limit-request.yaml -n qwang

Actual results:
2. # oc describe limits limitrange -n qwang1
# oc describe limits limitrange -n qwang1
Name:		limitrange
Namespace:	qwang1
Type		Resource	Min	Max	Default Request	Default Limit	Max Limit/Request Ratio
----		--------	---	---	---------------	-------------	-----------------------
Pod		cpu		10m	500m	-		-		1
Pod		memory		5Mi	750Mi	-		-		2
Container	cpu		10m	1	110m		1		10
Container	memory		5Mi	4Gi	100Mi		4Gi		8


3. It seems that dropped Pod resources are calculate by Container. For example, limit is 4294967296=4*1024*1024*1024 (Default Limit of Container), provided ratio is 40.960000=4*1024/100, (default limit/default request of Container). Could the units of measurement used in them be uniform?

# oc create -f pod-no-limit-request.yaml -n qwang1
Error from server: error when creating "pod-no-limit-request.yaml": pods "pod-no-limit-request" is forbidden: [Maximum cpu usage per Pod is 500m, but limit is 1., Maximum memory usage per Pod is 750Mi, but limit is 4294967296., cpu max limit to request ratio per Pod is 1, but provided ratio is 9.090909., memory max limit to request ratio per Pod is 2, but provided ratio is 40.960000., memory max limit to request ratio per Container is 8, but provided ratio is 40.960000.]


Expected results:
It's helpful if show more explicit messages.

Additional info:

Comment 1 Luke Meyer 2016-03-03 15:22:05 UTC
Upstream k8s issue: https://github.com/kubernetes/kubernetes/issues/21996

Comment 2 Greg Blomquist 2019-07-03 15:10:47 UTC
Issue went stale upstream.  Closing as wontfix.  If any issues persist in 4.x, please open a new bug.