Bug 1376052 - ClusterResourceQuota annotation selector encounters errors matching special characters
Summary: ClusterResourceQuota annotation selector encounters errors matching special c...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OKD
Classification: Red Hat
Component: Master
Version: 3.x
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: ---
Assignee: Jordan Liggitt
QA Contact: Qixuan Wang
URL:
Whiteboard:
Depends On:
Blocks: 1380837
TreeView+ depends on / blocked
 
Reported: 2016-09-14 14:22 UTC by Jordan Liggitt
Modified: 2016-12-09 21:52 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1380837 (view as bug list)
Environment:
Last Closed: 2016-12-09 21:52:08 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Jordan Liggitt 2016-09-14 14:22:39 UTC
cloned from https://github.com/openshift/origin/issues/10877 for QE

Description of problem:

ClusterResourceQuota annotation selector encounters errors if the keys or values contain characters that do not validate as label keys or values


Version-Release number of selected component (if applicable):


How reproducible:

Always

Steps to Reproduce:
1. Create a clusterresourcequota object with an annotations selector like this:
   "annotations":{"special key 1": "special value", "email":"user"}

2. Create a project, and annotate it with matching annotations

3. Observe errors in the server log, the clusterresourcequota status does not indicate the namespace was matched, and no clusterresourcequota is enforced in the project.


Additional info:

Comment 1 Jordan Liggitt 2016-09-14 14:23:01 UTC
fixed in https://github.com/openshift/origin/pull/10896

Comment 2 Qixuan Wang 2016-09-18 09:27:30 UTC
Tested on OCP3.3(openshift v3.3.0.31, kubernetes v1.3.0+52492b4, etcd 2.3.0+git)

There are some questions associated with testing:

1. Is there a separated bug for CLI fix https://github.com/openshift/origin/pull/10912 ?

2. Should ClusterResourceQuota label selector support keys/values contain characters like this bug fixed? For example:
spec.selector.labels.matchLabels: Invalid value: "qwang": must match the regex (([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])? (e.g. 'MyValue' or 'my_value' or '12345')

3. If lable selector supports special characters, should command "oc label namespace/project" support these?

Here is Server-side test result:

[root@dhcp-141-95 qwang]# cat bugs.yaml 
{
    "kind": "ClusterResourceQuota",
    "apiVersion": "v1",
    "metadata": {
        "name": "crq-test-6"
    },
    "spec": {
        "quota": {
            "hard": {
                "pods": "10",
                "secrets": "12"
            }
        },
        "selector": {
            "labels": {
                "matchLabels": {
                    "user": "qe"
                }
            },
            "annotations": {
                "openshift.io/requester": "qwang"
            }
        }
    }
}

[root@dhcp-141-95 qwang]# oc create -f bug.yaml 
clusterresourcequota "crq-test-6" created

[root@dhcp-141-95 qwang]# oc describe clusterresourcequotas crq-test-6
Name:		crq-test-6
Namespace:	<none>
Created:	8 seconds ago
Labels:		<none>
Annotations:	<none>
Label Selector: user=qe
AnnotationSelector: map[openshift.io/requester:qwang]
Resource	Used	Hard
--------	----	----

Comment 3 Jordan Liggitt 2016-09-18 11:59:46 UTC
1. There should be a separate bug. Fabiano, can you open one?

2. No, label selectors are working correctly now. They do not include special characters

3. No, only annotations support special characters like that

Comment 4 Fabiano Franz 2016-09-21 21:58:24 UTC
Separate bug for the CLI part: https://bugzilla.redhat.com/show_bug.cgi?id=1378243

Comment 5 DeShuai Ma 2016-09-22 12:21:39 UTC
Test on openshift v1.4.0-alpha.0+aa08313, verify this bug.

Steps:
1. Create a clusterresourcequota with special annotations
[root@ip-172-18-5-251 ~]# oc create clusterresourcequota limit-bob --project-annotation-selector=openshift.io/requester=usertest --hard=pods=10
clusterresourcequota "limit-bob" created

2. Create a project match annotations
[root@ip-172-18-5-251 ~]# oadm new-project dma
Created project dma
[root@ip-172-18-5-251 ~]# oc annotate namespaces/dma openshift.io/requester=usertest

3. Check the clusterresourcequota status
oc get clusterresourcequota limit-bob -o json
{
    "kind": "ClusterResourceQuota",
    "apiVersion": "v1",
    "metadata": {
        "name": "limit-bob",
        "selfLink": "/oapi/v1/clusterresourcequotas/limit-bob",
        "uid": "c3086a15-80bb-11e6-93d0-0e6e19152557",
        "resourceVersion": "2067",
        "creationTimestamp": "2016-09-22T11:57:40Z"
    },
    "spec": {
        "selector": {
            "labels": null,
            "annotations": {
                "openshift.io/requester": "usertest"
            }
        },
        "quota": {
            "hard": {
                "pods": "10"
            }
        }
    },
    "status": {
        "total": {
            "hard": {
                "pods": "10"
            },
            "used": {
                "pods": "0"
            }
        },
        "namespaces": [
            {
                "namespace": "dma",
                "status": {
                    "hard": {
                        "pods": "10"
                    },
                    "used": {
                        "pods": "0"
                    }
                }
            }
        ]
    }
}

4. Create a pod in project and confirm clusterresourcequota is consumed by project
[root@ip-172-18-5-251 ~]# oc create -f https://raw.githubusercontent.com/openshift/origin/master/examples/hello-openshift/hello-pod.json -n dma
pod "hello-openshift" created
[root@ip-172-18-5-251 ~]# oc describe clusterresourcequotas limit-bob
Name:		limit-bob
Namespace:	<none>
Created:	14 minutes ago
Labels:		<none>
Annotations:	<none>
Label Selector: <null>
AnnotationSelector: map[openshift.io/requester:usertest]
Resource	Used	Hard
--------	----	----
pods		1	10


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