Skip to content

Commit 5a9f02a

Browse files
committed
reflect review comment
1 parent 7549cb8 commit 5a9f02a

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

pkg/capacityscheduling/elasticquota.go

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ limitations under the License.
1717
package capacityscheduling
1818

1919
import (
20-
"reflect"
21-
2220
"k8s.io/api/core/v1"
2321
"k8s.io/apimachinery/pkg/util/sets"
2422
"k8s.io/kubernetes/pkg/scheduler/framework"
@@ -90,30 +88,27 @@ func (e *ElasticQuotaInfo) unreserveResource(request framework.Resource) {
9088
}
9189

9290
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-
}
9791
// "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)
9996
}
10097

10198
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-
}
10699
// "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)
108104
}
109105

110106
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-
}
115107
// "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)
117112
}
118113

119114
func (e *ElasticQuotaInfo) clone() *ElasticQuotaInfo {

0 commit comments

Comments
 (0)