Bug 1293836 - Wrong RegEx when create quota with minus
Wrong RegEx when create quota with minus
Status: NEW
Product: OpenShift Origin
Classification: Red Hat
Component: Command Line Interface (Show other bugs)
3.x
Unspecified Unspecified
medium Severity low
: ---
: ---
Assigned To: Derek Carr
Qingyu Wang
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-12-23 04:10 EST by Qixuan Wang
Modified: 2016-08-03 02:59 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
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 Qixuan Wang 2015-12-23 04:10:37 EST
Description of problem:
Create quota with negative number, the regular expression '^([+-]?[0-9.]+)([eEimkKMGTP]*[-+]?[0-9]*)$' " which includes negative number.

Version-Release number of selected component (if applicable):
openshift v1.1-428-ged29520
kubernetes v1.1.0-origin-1107-g4c8e6f4
etcd 2.1.2

How reproducible:
Always

Steps to Reproduce:
1.Create quota with minus
$ cat negquota.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
  name: negquota
spec:
  hard:
    cpu: "-20"
    memory: “-1Gi“
    persistentvolumeclaims: "-10"
    pods: "-10"
    replicationcontrollers: "-20"
    resourcequotas: "-2"
    secrets: "-10"
    services: "-5"

$ oc create -f negquota.yaml -n qwangp --config=/home/fedora/openshift.local.config/master/admin.kubeconfig


Actual results:
1. [root@ip-172-18-14-187 fedora]# oc create -f negquota.yaml -n qwangp --config=/home/fedora/openshift.local.config/master/admin.kubeconfig 
unable to load "negquota.yaml": quantities must match the regular expression '^([+-]?[0-9.]+)([eEimkKMGTP]*[-+]?[0-9]*)$' 


Expected results:
1. The message should like "xxx must be non-negative"

Additional info:
Comment 1 Derek Carr 2016-01-04 14:51:07 EST
The server is correctly validating that the incoming value conforms to the Kube syntax for compute resources.  Since the regex is used to validate the incoming object before it's actually parsed, I am not sure I see a huge value in updating the code to special case the check for negative values versus just stating the value does not match the regex.

Moving to low priority.
Comment 2 Qixuan Wang 2016-08-03 02:32:59 EDT
Tested on OSE3.3(openshift v3.3.0.13, kubernetes v1.3.0+57fb9ac, etcd2.3.0+git), the problem has gone.

[root@dhcp-141-95 testv3]# oc create -f negquota.yaml -n qwang1 --config=/home/qwang/admin.kubeconfig 
The ResourceQuota "negquota" is invalid.

* spec.hard[pods]: Invalid value: "-10": must be greater than or equal to 0
* spec.hard[replicationcontrollers]: Invalid value: "-20": must be greater than or equal to 0
* spec.hard[resourcequotas]: Invalid value: "-2": must be greater than or equal to 0
* spec.hard[secrets]: Invalid value: "-10": must be greater than or equal to 0
* spec.hard[services]: Invalid value: "-5": must be greater than or equal to 0
* spec.hard[cpu]: Invalid value: "-20": must be greater than or equal to 0
* spec.hard[memory]: Invalid value: "-1Gi": must be greater than or equal to 0
* spec.hard[persistentvolumeclaims]: Invalid value: "-10": must be greater than or equal to 0
Comment 3 Qixuan Wang 2016-08-03 02:59:54 EDT
Fractional numbers, decimals, negative numbers can match the RegEx '^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$'

[root@dhcp-141-95 testv3]# cat quota-2.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
  name: quota-2
spec:
  hard:
    cpu: "2/10"
    memory: "1/5Gi"
    persistentvolumeclaims: "1/10"
    pods: "1/10"
    replicationcontrollers: "2/10"
    resourcequotas: "3/10"
    secrets: "5/10"
    services: "5/10"

[root@dhcp-141-95 testv3]# oc create -f quota-3.yaml -n qwang1 --config=/home/qwang/admin.kubeconfig 
unable to decode "quota-3.yaml": quantities must match the regular expression '^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$'

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