@@ -17,8 +17,6 @@ limitations under the License.
17
17
package capacityscheduling
18
18
19
19
import (
20
- "reflect"
21
-
22
20
"k8s.io/api/core/v1"
23
21
"k8s.io/apimachinery/pkg/util/sets"
24
22
"k8s.io/kubernetes/pkg/scheduler/framework"
@@ -90,30 +88,27 @@ func (e *ElasticQuotaInfo) unreserveResource(request framework.Resource) {
90
88
}
91
89
92
90
func (e * ElasticQuotaInfo ) usedOverMinWith (podRequest * framework.Resource ) bool {
93
- eqMin := reflect .ValueOf (e ).Elem ().FieldByName ("Min" )
94
- if eqMin .IsValid () && ! eqMin .IsZero () {
95
- return cmp2 (podRequest , e .Used , e .Min )
96
- }
97
91
// "ElasticQuotaInfo doesn't have Min" means used values exceeded min(0)
98
- return true
92
+ if e .Min == nil {
93
+ return true
94
+ }
95
+ return cmp2 (podRequest , e .Used , e .Min )
99
96
}
100
97
101
98
func (e * ElasticQuotaInfo ) usedOverMaxWith (podRequest * framework.Resource ) bool {
102
- eqMax := reflect .ValueOf (e ).Elem ().FieldByName ("Max" )
103
- if eqMax .IsValid () && ! eqMax .IsZero () {
104
- return cmp2 (podRequest , e .Used , e .Max )
105
- }
106
99
// "ElasticQuotaInfo doesn't have Max" means there are no limitations(infinite)
107
- return false
100
+ if e .Max == nil {
101
+ return false
102
+ }
103
+ return cmp2 (podRequest , e .Used , e .Max )
108
104
}
109
105
110
106
func (e * ElasticQuotaInfo ) usedOverMin () bool {
111
- eqMin := reflect .ValueOf (e ).Elem ().FieldByName ("Min" )
112
- if eqMin .IsValid () && ! eqMin .IsZero () {
113
- return cmp (e .Used , e .Min )
114
- }
115
107
// "ElasticQuotaInfo doesn't have Min" means used values exceeded min(0)
116
- return true
108
+ if e .Min == nil {
109
+ return true
110
+ }
111
+ return cmp (e .Used , e .Min )
117
112
}
118
113
119
114
func (e * ElasticQuotaInfo ) clone () * ElasticQuotaInfo {
0 commit comments