Bug 1401073

Summary: Deleted namespaces are not removed from clusterresourcequota status
Product: OpenShift Container Platform Reporter: Jordan Liggitt <jliggitt>
Component: MasterAssignee: Jordan Liggitt <jliggitt>
Status: CLOSED ERRATA QA Contact: Qixuan Wang <qixuan.wang>
Severity: medium Docs Contact:
Priority: medium    
Version: 3.3.1CC: aos-bugs, dma, jokerman, mmccomas, pweil, tdawson
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-01-18 12:56:49 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jordan Liggitt 2016-12-02 17:41:58 UTC
Description of problem:

Spawned from https://bugzilla.redhat.com/show_bug.cgi?id=1400200#c5

Once a clusterresourcequota (CRQ) selects a namespace, removing the namespace (or changing the labels/annotations on the namespace so that it no longer matches the CRQ's selector) does not remove the namespace from the CRQ's status.

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


How reproducible:


Steps to Reproduce:
oc delete clusterresourcequota --all
oc delete ns --all
oc create clusterresourcequota crq-1 --project-annotation-selector=openshift.io/requester=user --hard=secrets=50,pods=20
oc new-project p-1 --as=user
oc new-project p-2 --as=user
oc get clusterresourcequota -o yaml
oc delete ns/p-1
oc get clusterresourcequota -o yaml
# p-1 still appears in CRQ status, but with 0 usage
oc new-project p-1 --as=user2
# p-1 still appears in CRQ status, but with 0 usage
restart the api server
# p-1 still appears in CRQ status, but with 0 usage

Comment 1 Jordan Liggitt 2016-12-05 15:08:21 UTC
fixed in origin 1.4 in https://github.com/openshift/origin/pull/12125
fixed in origin master in https://github.com/openshift/origin/pull/12123

Comment 2 Jordan Liggitt 2016-12-05 15:09:45 UTC
fixed in ose 3.3 in https://github.com/openshift/ose/pull/492

Comment 4 Troy Dawson 2016-12-06 21:04:16 UTC
This has been merged into ocp and is in OCP v3.4.0.33 or newer.

Comment 6 Qixuan Wang 2016-12-07 06:07:31 UTC
Tested on OCP 3.4.0.33(openshift v3.4.0.33+71c05b2, kubernetes v1.4.0+776c994, etcd 3.1.0-rc.0),the problem has been solved, thanks.

Here are steps:

# oc create clusterresourcequota crq-1 --project-annotation-selector=openshift.io/requester=user --hard=secrets=50
clusterresourcequota "crq-1" created

# oc new-project p-1 --as=user
# oc new-project p-2 --as=user

# oc get clusterresourcequota crq-1 -o yaml
apiVersion: v1
kind: ClusterResourceQuota
metadata:
  creationTimestamp: 2016-12-07T05:48:08Z
  name: crq-1
  resourceVersion: "5256"
  selfLink: /oapi/v1/clusterresourcequotas/crq-1
  uid: bb65ba06-bc40-11e6-898f-0eda563642d4
spec:
  quota:
    hard:
      secrets: "50"
  selector:
    annotations:
      openshift.io/requester: user
    labels: null
status:
  namespaces:
  - namespace: p-1
    status:
      hard:
        secrets: "50"
      used:
        secrets: "9"
  - namespace: p-2
    status:
      hard:
        secrets: "50"
      used:
        secrets: "9"
  total:
    hard:
      secrets: "50"
    used:
      secrets: "18"

# oc delete project p-1
project "p-1" deleted

# oc get clusterresourcequota crq-1 -o yaml
apiVersion: v1
kind: ClusterResourceQuota
metadata:
  creationTimestamp: 2016-12-07T05:48:08Z
  name: crq-1
  resourceVersion: "5335"
  selfLink: /oapi/v1/clusterresourcequotas/crq-1
  uid: bb65ba06-bc40-11e6-898f-0eda563642d4
spec:
  quota:
    hard:
      secrets: "50"
  selector:
    annotations:
      openshift.io/requester: user
    labels: null
status:
  namespaces:
  - namespace: p-2
    status:
      hard:
        secrets: "50"
      used:
        secrets: "9"
  total:
    hard:
      secrets: "50"
    used:
      secrets: "9"

Comment 8 errata-xmlrpc 2017-01-18 12:56:49 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-2017:0066