turbonomic / kubeturbo

140 stars 75 forks source link

[TRB-46978]:Ignore the namespace resourcequotas with a Terminating scope #941

Closed kevinwangcn closed 1 year ago

kevinwangcn commented 1 year ago

Intent

When dealing with multiple resourcequotas in the same namespace, we decide to skip the ones which have Scope defined and the scope contains Terminating.

Background

https://jsw.ibm.com/browse/TRB-46978

Testing

1.Define 2 resourcequotas in a namespace, one of them has the Terminating scope

[root@api.ocp410kev.cp.fyre.ibm.com ~]# k get resourcequotas 
NAME                          AGE    REQUEST   LIMIT
quotatest-single-container2   269d             limits.cpu: 30m/330m, limits.memory: 300Mi/330Mi
quotatest-small               16m              limits.cpu: 0/10m, limits.memory: 0/10Mi
[root@api.ocp410kev.cp.fyre.ibm.com ~]# k describe resourcequotas quotatest-small 
Name:       quotatest-small
Namespace:  quotatest-single-container2
Scopes:     NotBestEffort, Terminating  <--------------here
 * Matches all pods that have at least one resource requirement set. These pods have a burstable or guaranteed quality of service.
 * Matches all pods that have an active deadline. These pods have a limited lifespan on a node before being actively terminated by the system.
Resource       Used  Hard
--------       ----  ----
limits.cpu     0     10m
limits.memory  0     10Mi

2.Create a deployment and rediscover+broadcast, and check the Kubeturbo log

k logs -f kubeturbo-kw-114-869856f484-tjs7r |grep resourcequota
I0908 20:02:30.654860       1 kube_cluster.go:539] Found a resourcequota quotatest-small in the namespace quotatest-single-container2 with the scopes([Terminating NotBestEffort]) or scopeSelector(nil)
I0908 20:02:30.654870       1 kube_cluster.go:548] Ignore the resourcequota quotatest-small in the namespace quotatest-single-container2 as it has a Terminating scope

3.Check the Capacity and Usage on the UI for that namespace The capacity doesn't pick up the smaller one defined in the quotatest-small resourcequota image

Checklist

These are the items that must be done by the developer and by reviewers before the change is ready to merge. Please strikeout any items that are not applicable, but don't delete them

Audience

(@ mention any review/... groups or people that should be aware of this merge request)