Bug 1377082 - Command "oc describe" doesn't list resources if clusterresourcequotas is created via API
Summary: Command "oc describe" doesn't list resources if clusterresourcequotas is crea...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Master
Version: 3.3.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: 3.3.1
Assignee: Jordan Liggitt
QA Contact: Qixuan Wang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-09-18 09:18 UTC by Qixuan Wang
Modified: 2016-10-27 15:41 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
undefined
Clone Of:
Environment:
Last Closed: 2016-10-27 15:41:56 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
describe-clusterquotaresource (11.25 KB, text/plain)
2016-09-18 09:20 UTC, Qixuan Wang
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:2084 0 normal SHIPPED_LIVE Red Hat OpenShift Container Platform 3.3.1.3 bug fix update 2016-10-27 19:41:25 UTC

Description Qixuan Wang 2016-09-18 09:18:00 UTC
Description of problem:
Create a ClusterResourceQuota with hard resources via CLI, we can get resources list from command "oc describe", but create from test file, while describer get value from status return, the status returns nothing, so we are not able to list resources by "oc describe". 

Here is part of log:
Response Body: {"kind":"ClusterResourceQuota","apiVersion":"v1","metadata":{"name":"crq-test-6","selfLink":"/oapi/v1/clusterresourcequotas/crq-test-6","uid":"cd21c135-7d6f-11e6-bbd2-fa163e145fe0","resourceVersion":"14448","creationTimestamp":"2016-09-18T07:16:21Z"},"spec":{"selector":{"labels":{"matchLabels":{"user":"qe"}},"annotations":{"openshift.io/requester":"qwang"}},"quota":{"hard":{"pods":"10","secrets":"12"}}},"status":{"total":{},"namespaces":null}}


Version-Release number of selected component (if applicable):
Origin:
openshift v1.3.0+342f49c
kubernetes v1.4.0-beta.3+d19513f
etcd 3.0.6

OCP:
openshift v3.3.0.31
kubernetes v1.3.0+52492b4
etcd 2.3.0+git

How reproducible:
Always

Steps to Reproduce:
1. Label and annotate project
# oc label namespace project-a user=qe
# oc annotate namespace/project-a openshift.io/requester="qwang"

2. Prepare a test file 
# cat test.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"
            }
        }
    }
}

3. Create a clusterresourcequota object
# oc create -f test.yaml 

4. Check by command "oc get xxx -o xxx" 
# oc get clusterresourcequotas crq-test-6 -o json

5. Check by command "oc describe" 
# oc describe clusterresourcequotas crq-test-6


Actual results:
4. [root@dhcp-141-95 qwang]# oc get clusterresourcequotas crq-test-6 -o json
{
    "kind": "ClusterResourceQuota",
    "apiVersion": "v1",
    "metadata": {
        "name": "crq-test-6",
        "selfLink": "/oapi/v1/clusterresourcequotas/crq-test-6",
        "uid": "cd21c135-7d6f-11e6-bbd2-fa163e145fe0",
        "resourceVersion": "14448",
        "creationTimestamp": "2016-09-18T07:16:21Z"
    },
    "spec": {
        "selector": {
            "labels": {
                "matchLabels": {
                    "user": "qe"
                }
            },
            "annotations": {
                "openshift.io/requester": "qwang"
            }
        },
        "quota": {
            "hard": {
                "pods": "10",
                "secrets": "12"
            }
        }
    },
    "status": {
        "total": {},
        "namespaces": null
    }
}

5. [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
--------	----	----


Expected results:
4. Should list resources(pods,secrets) defined on the test file
5. spec.status.total should have values

Additional info:
Attached logs

Compare with CLI
[root@dhcp-141-95 qwang]# oc create clusterresourcequota test-1 --hard=[pods=10] --project-label-selector=user=dev 
clusterresourcequota "test-1" created
[root@dhcp-141-95 qwang]# oc describe clusterresourcequotas test-1
Name:		test-1
Namespace:	<none>
Created:	9 seconds ago
Labels:		<none>
Annotations:	<none>
Label Selector: user=dev
AnnotationSelector: map[]
Resource	Used	Hard
--------	----	----
pods		0	10

Comment 1 Qixuan Wang 2016-09-18 09:20:06 UTC
Created attachment 1202129 [details]
describe-clusterquotaresource

Comment 2 Jordan Liggitt 2016-09-19 16:02:14 UTC
The two clusterquotas have different label selectors (user=qe and user=dev). Can ou include the yaml for the namespace you expected to be selected and verify the labels and annotations match the selector?

Comment 4 Qixuan Wang 2016-09-20 03:31:02 UTC
(In reply to Jordan Liggitt from comment #2)
> The two clusterquotas have different label selectors (user=qe and user=dev).
> Can ou include the yaml for the namespace you expected to be selected and
> verify the labels and annotations match the selector?

I tested the clusterquota label selectors matching and mismatching project label. The problem exists in these two cases.

Here is test step which I correct a typo in comparison(Additional Info):

1. Project description(label: user=qe, annotation: openshift.io/requester=qwang)  
# oc new-project project-1
# oc label namespace project-1 user=qe 
# oc describe project project-1
Name:			project-1
Namespace:		<none>
Created:		3 minutes ago
Labels:			user=qe
Annotations:		openshift.io/description=
			openshift.io/display-name=
			openshift.io/requester=qwang
			openshift.io/sa.scc.mcs=s0:c10,c0
			openshift.io/sa.scc.supplemental-groups=1000090000/10000
			openshift.io/sa.scc.uid-range=1000090000/10000
Display Name:		<none>
Description:		<none>
Status:			Active
Node Selector:		<none>
Quota:			<none>
Resource limits:	<none>

2. Test file (matched label: user=qe, annotation: openshift.io/requester=qwang) 
# cat test.json 
{
    "kind": "ClusterResourceQuota",
    "apiVersion": "v1",
    "metadata": {
        "name": "crq-test"
    },
    "spec": {
        "quota": {
            "hard": {
                "pods": "10",
                "secrets": "12"
            }
        },
        "selector": {
            "labels": {
                "matchLabels": {
                    "user": "qe"
                }
            },
            "annotations": {
                "openshift.io/requester": "qwang"
            }
        }
    }
}

# oc create -f test.json
clusterresourcequota "crq-test" created

# oc describe clusterresourcequota crq-test
Name:		crq-test
Namespace:	<none>
Created:	14 seconds ago
Labels:		<none>
Annotations:	<none>
Label Selector: user=qe
AnnotationSelector: map[openshift.io/requester:qwang]
Resource	Used	Hard
--------	----	----

# oc get clusterresourcequota crq-test -o json
{
    "kind": "ClusterResourceQuota",
    "apiVersion": "v1",
    "metadata": {
        "name": "crq-test",
        "selfLink": "/oapi/v1/clusterresourcequotas/crq-test",
        "uid": "e62ac41e-7edf-11e6-9ac2-0e09641fca19",
        "resourceVersion": "3234",
        "creationTimestamp": "2016-09-20T03:11:18Z"
    },
    "spec": {
        "selector": {
            "labels": {
                "matchLabels": {
                    "user": "qe"
                }
            },
            "annotations": {
                "openshift.io/requester": "qwang"
            }
        },
        "quota": {
            "hard": {
                "pods": "10",
                "secrets": "12"
            }
        }
    },
    "status": {
        "total": {},
        "namespaces": null
    }
}


Comparison:

[root@dhcp-141-95 qwang]# oc create clusterresourcequota test-1 --hard=[pods=10] --project-label-selector=user=qe
clusterresourcequota "test-1" created

[root@dhcp-141-95 qwang]# oc describe clusterresourcequota test-1
Name:		test-1
Namespace:	<none>
Created:	12 seconds ago
Labels:		<none>
Annotations:	<none>
Label Selector: user=qe
AnnotationSelector: map[]
Resource	Used	Hard
--------	----	----
pods		0	10

# oc get clusterresourcequota test-1 -o json
{
    "kind": "ClusterResourceQuota",
    "apiVersion": "v1",
    "metadata": {
        "name": "test-1",
        "selfLink": "/oapi/v1/clusterresourcequotas/test-1",
        "uid": "2e86c6d4-7ee0-11e6-9ac2-0e09641fca19",
        "resourceVersion": "3338",
        "creationTimestamp": "2016-09-20T03:13:19Z"
    },
    "spec": {
        "selector": {
            "labels": {
                "matchLabels": {
                    "user": "qe"
                }
            },
            "annotations": {}
        },
        "quota": {
            "hard": {
                "pods": "10"
            }
        }
    },
    "status": {
        "total": {
            "hard": {
                "pods": "10"
            },
            "used": {
                "pods": "0"
            }
        },
        "namespaces": [
            {
                "namespace": "project-1",
                "status": {
                    "hard": {
                        "pods": "10"
                    },
                    "used": {
                        "pods": "0"
                    }
                }
            }
        ]
    }
}

Comment 7 DeShuai Ma 2016-10-09 06:48:22 UTC
Verify on atomic-openshift-3.3.1.1-1.git.0.629a1d8.el7.x86_64

Steps:
[root@openshift-145 ~]# oc label namespace dma user=qe
namespace "dma" labeled
[root@openshift-145 ~]# oc annotate namespace/dma openshift.io/requester="dma" --overwrite
namespace "dma" annotated
[root@openshift-145 ~]# oc get project dma -o json
{
    "kind": "Project",
    "apiVersion": "v1",
    "metadata": {
        "name": "dma",
        "selfLink": "/oapi/v1/projects/dma",
        "uid": "4f6002b5-8de5-11e6-9cb6-fa163e4efe9f",
        "resourceVersion": "1706",
        "creationTimestamp": "2016-10-09T05:57:50Z",
        "labels": {
            "user": "qe"
        },
        "annotations": {
            "openshift.io/description": "",
            "openshift.io/display-name": "",
            "openshift.io/requester": "dma",
            "openshift.io/sa.scc.mcs": "s0:c6,c5",
            "openshift.io/sa.scc.supplemental-groups": "1000040000/10000",
            "openshift.io/sa.scc.uid-range": "1000040000/10000"
        }
    },
    "spec": {
        "finalizers": [
            "openshift.io/origin",
            "kubernetes"
        ]
    },
    "status": {
        "phase": "Active"
    }
}
[root@openshift-145 ~]# oc create -f clusterquota.json 
clusterresourcequota "crq-test-6" created
[root@openshift-145 ~]# oc get clusterresourcequotas
NAME         LABEL SELECTOR   ANNOTATION SELECTOR
crq-test-6   user=qe          map[openshift.io/requester:dma]
[root@openshift-145 ~]# oc get clusterresourcequotas crq-test-6 -o json
{
    "kind": "ClusterResourceQuota",
    "apiVersion": "v1",
    "metadata": {
        "name": "crq-test-6",
        "selfLink": "/oapi/v1/clusterresourcequotas/crq-test-6",
        "uid": "b3c11e5e-8deb-11e6-9cb6-fa163e4efe9f",
        "resourceVersion": "1724",
        "creationTimestamp": "2016-10-09T06:43:35Z"
    },
    "spec": {
        "selector": {
            "labels": {
                "matchLabels": {
                    "user": "qe"
                }
            },
            "annotations": {
                "openshift.io/requester": "dma"
            }
        },
        "quota": {
            "hard": {
                "pods": "10",
                "secrets": "12"
            }
        }
    },
    "status": {
        "total": {
            "hard": {
                "pods": "10",
                "secrets": "12"
            },
            "used": {
                "pods": "0",
                "secrets": "9"
            }
        },
        "namespaces": [
            {
                "namespace": "dma",
                "status": {
                    "hard": {
                        "pods": "10",
                        "secrets": "12"
                    },
                    "used": {
                        "pods": "0",
                        "secrets": "9"
                    }
                }
            }
        ]
    }
}
[root@openshift-145 ~]# oc describe clusterresourcequotas crq-test-6
Name:		crq-test-6
Namespace:	<none>
Created:	57 seconds ago
Labels:		<none>
Annotations:	<none>
Label Selector: user=qe
AnnotationSelector: map[openshift.io/requester:dma]
Resource	Used	Hard
--------	----	----
pods		0	10
secrets		9	12

Comment 9 errata-xmlrpc 2016-10-27 15:41:56 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2016:2084


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