Bug 1257845 - Memory used in quota should be more readable.
Memory used in quota should be more readable.
Status: CLOSED CURRENTRELEASE
Product: OpenShift Origin
Classification: Red Hat
Component: Command Line Interface (Show other bugs)
3.x
Unspecified Unspecified
medium Severity low
: ---
: ---
Assigned To: Fabiano Franz
Yan Du
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-08-28 04:37 EDT by Liang Xia
Modified: 2017-05-30 08:50 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2017-05-30 08:50:05 EDT
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-08-28 04:37:26 EDT
Description of problem:
Memory used in quota are listed in Bytes, which is hard to read.
Should be more readalbe, e.g, 
if less than 1Mi, show them in Ki;
if larger than 1Mi, but less than 1Gi, show them in Mi;
if larger than 1Gi, show them in Gi.

Version-Release number of selected component (if applicable):
oc v1.0.4-502-g96963b6
kubernetes v1.1.0-alpha.0-1605-g44c91b1

How reproducible:
Always

Steps to Reproduce:
1.Create a project.
oc new-project demo

2.Set quota for above project.
oc create -f quota.json -n demo

3.Set default limit in above project.
oc create -f limits.json -n demo

4.Create a pod with quota
oc create -f pod.json -n demo

5.Check the quota detail.
oc describe quota test-quota -n demo


Actual results:
# oc describe quota test-quota -n demo
Name:            test-quota
Namespace:        demo
Resource        Used        Hard
--------        ----        ----
cpu            200m        200m
memory            209715200    512Mi
                  ^^^^^^^^^Here it is
pods            2        3
replicationcontrollers    0        3
resourcequotas        1        1
services        0        3


Expected results:
The memory used should be more readable.

Additional info:
$ cat quota.json
{
  "apiVersion": "v1",
  "kind": "ResourceQuota",
  "metadata": {
    "name": "test-quota"
  },
  "spec": {
    "hard": {
      "memory": "512Mi",
      "cpu": "200m",
      "pods": "3",
      "services": "3",
      "replicationcontrollers": "3",
      "resourcequotas": "1"
    }
  }
}

$ cat limits.json
{
    "kind": "LimitRange",
    "apiVersion": "v1",
    "metadata": {
        "name": "limits",
        "creationTimestamp": null
    },
    "spec": {
        "limits": [
            {
                "type": "Pod",
                "max": {
                    "cpu": "500m",
                    "memory": "750Mi"
                },
                "min": {
                    "cpu": "10m",
                    "memory": "5Mi"
                }
            },
            {
                "type": "Container",
                "max": {
                    "cpu": "500m",
                    "memory": "750Mi"
                },
                "min": {
                    "cpu": "10m",
                    "memory": "5Mi"
                },
                "default": {
                    "cpu": "100m",
                    "memory": "100Mi"
                }
            }
        ]
    }
}

$ cat pod.json
{
  "kind": "Pod",
  "apiVersion": "v1",
  "metadata": {
    "name": "hello-openshift",
    "creationTimestamp": null,
    "labels": {
      "name": "hello-openshift"
    }
  },
  "spec": {
    "containers": [
      {
        "name": "hello-openshift",
        "image": "openshift/hello-openshift",
        "ports": [
          {
            "hostPort": 36061,
            "containerPort": 8080,
            "protocol": "TCP"
          }
        ],
        "resources": {
        },
        "terminationMessagePath": "/dev/termination-log",
        "imagePullPolicy": "IfNotPresent",
        "capabilities": {},
        "securityContext": {
          "capabilities": {},
          "privileged": false
        }
      }
    ],
    "restartPolicy": "Always",
    "dnsPolicy": "ClusterFirst",
    "serviceAccount": ""
  },
  "status": {}
}
Comment 1 Fabiano Franz 2016-03-09 11:07:12 EST
Fixed in master.
Comment 2 zhou ying 2016-03-09 22:22:29 EST
Confirmed with ami devenv_rhel7_3664, the memory is readable, but other fields like openshift.io/projectimagessize is still unreadable.

please see:

[root@ip-172-18-4-110 amd64]# oc describe quota
Name:				test-quota
Namespace:			zhouy
Resource			Used		Hard
--------			----		----
cpu				100m		200m
memory				100Mi		512Mi
openshift.io/imagesize		0		214748364800m
openshift.io/imagestreamsize	0		214748364800m
openshift.io/projectimagessize	160102255	214748364800m
pods				1		3
replicationcontrollers		0		3
resourcequotas			1		1
services			0		3


Use json:
[root@ip-172-18-4-110 amd64]# more quota.json 
{
  "apiVersion": "v1",
  "kind": "ResourceQuota",
  "metadata": {
    "name": "test-quota"
  },
  "spec": {
    "hard": {
      "memory": "512Mi",
      "cpu": "200m",
      "openshift.io/imagesize": "0.2Gi",
      "openshift.io/imagestreamsize": "0.2Gi",
      "openshift.io/projectimagessize": "0.2Gi",
      "pods": "3",
      "services": "3",
      "replicationcontrollers": "3",
      "resourcequotas": "1"
    }
  }
}

Step to create the IS:
`docker pull docker.io/zhouying7780/singlelayer`
`docker tag docker.io/zhouying7780/singlelayer 172.30.188.203:5000/zhouy/hellotest:latest`
`docker push 172.30.188.203:5000/zhouy/hellotest:latest`
Comment 3 zhou ying 2016-03-09 22:39:19 EST
When use the json format like this :

[root@ip-172-18-4-110 amd64]# more quota.json 
{
  "apiVersion": "v1",
  "kind": "ResourceQuota",
  "metadata": {
    "name": "test-quota"
  },
  "spec": {
    "hard": {
      "memory": "512Mi",
      "cpu": "200m",
      "openshift.io/imagesize": "200Mi",
      "openshift.io/imagestreamsize": "200Mi",
      "openshift.io/projectimagessize": "200Mi",
      "pods": "3",
      "services": "3",
      "replicationcontrollers": "3",
      "resourcequotas": "1"
    }
  }
}


The result is still unreadable:
[root@ip-172-18-4-110 amd64]# oc describe quota
Name:				test-quota
Namespace:			zhouy
Resource			Used		Hard
--------			----		----
cpu				100m		200m
memory				100Mi		512Mi
openshift.io/imagesize		0		200Mi
openshift.io/imagestreamsize	0		200Mi
openshift.io/projectimagessize	160102255	200Mi
pods				1		3
replicationcontrollers		0		3
resourcequotas			1		1
services			0		3
Comment 4 Paul Weil 2017-02-16 17:02:50 EST
the image items here have since been replaced.  This can be retested with openshift.io/Image (which should be the only size related one, there are other count-based items)
Comment 5 Liang Xia 2017-02-20 22:04:25 EST
# oc describe quota
Name:				test-quota
Namespace:			default
Resource			Used	Hard
--------			----	----
cpu				200m	200m
memory				512Mi	512Mi
openshift.io/Image		0	200Mi
openshift.io/imagesize		0	200Mi
openshift.io/imagestreamsize	0	200Mi
openshift.io/projectimagessize	0	200Mi
pods				2	3
replicationcontrollers		10	3
resourcequotas			1	1
services			4	3

# oc version
oc v3.5.0.31-1+d55d08f
kubernetes v1.5.2+43a9be4
features: Basic-Auth GSSAPI Kerberos SPNEGO

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