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:
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.
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
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]*)$'