@@ -96,7 +96,7 @@ const (
96
96
// DEPRECATED
97
97
// All cloudprovider specific predicates are deprecated in favour of MaxCSIVolumeCountPred.
98
98
MaxCinderVolumeCountPred = "MaxCinderVolumeCount"
99
- // MaxCSIVolumeCountPred defines the predicate that decides how many CSI volumes should be attached
99
+ // MaxCSIVolumeCountPred defines the predicate that decides how many CSI volumes should be attached.
100
100
MaxCSIVolumeCountPred = "MaxCSIVolumeCountPred"
101
101
// NoVolumeZoneConflictPred defines the name of predicate NoVolumeZoneConflict.
102
102
NoVolumeZoneConflictPred = "NoVolumeZoneConflict"
@@ -106,18 +106,18 @@ const (
106
106
CheckNodeDiskPressurePred = "CheckNodeDiskPressure"
107
107
// CheckNodePIDPressurePred defines the name of predicate CheckNodePIDPressure.
108
108
CheckNodePIDPressurePred = "CheckNodePIDPressure"
109
- // EvenPodsSpreadPred defines the name of predicate EvenPodsSpread
109
+ // EvenPodsSpreadPred defines the name of predicate EvenPodsSpread.
110
110
EvenPodsSpreadPred = "EvenPodsSpread"
111
111
112
- // DefaultMaxGCEPDVolumes defines the maximum number of PD Volumes for GCE
112
+ // DefaultMaxGCEPDVolumes defines the maximum number of PD Volumes for GCE.
113
113
// GCE instances can have up to 16 PD volumes attached.
114
114
DefaultMaxGCEPDVolumes = 16
115
- // DefaultMaxAzureDiskVolumes defines the maximum number of PD Volumes for Azure
115
+ // DefaultMaxAzureDiskVolumes defines the maximum number of PD Volumes for Azure.
116
116
// Larger Azure VMs can actually have much more disks attached.
117
117
// TODO We should determine the max based on VM size
118
118
DefaultMaxAzureDiskVolumes = 16
119
119
120
- // KubeMaxPDVols defines the maximum number of PD Volumes per kubelet
120
+ // KubeMaxPDVols defines the maximum number of PD Volumes per kubelet.
121
121
KubeMaxPDVols = "KUBE_MAX_PD_VOLS"
122
122
123
123
// EBSVolumeFilterType defines the filter name for EBSVolumeFilter.
@@ -153,16 +153,21 @@ var (
153
153
CheckNodeMemoryPressurePred , CheckNodePIDPressurePred , CheckNodeDiskPressurePred , EvenPodsSpreadPred , MatchInterPodAffinityPred }
154
154
)
155
155
156
+ // Ordering returns the ordering of predicates.
157
+ func Ordering () []string {
158
+ return predicatesOrdering
159
+ }
160
+
156
161
// FitPredicate is a function that indicates if a pod fits into an existing node.
157
162
// The failure information is given by the error.
158
163
type FitPredicate func (pod * v1.Pod , meta PredicateMetadata , nodeInfo * schedulernodeinfo.NodeInfo ) (bool , []PredicateFailureReason , error )
159
164
160
- // NodeInfo interface represents anything that can get node object from node ID .
165
+ // NodeInfo interface represents anything that can get node object from node name .
161
166
type NodeInfo interface {
162
- GetNodeInfo (nodeID string ) (* v1.Node , error )
167
+ GetNodeInfo (nodeName string ) (* v1.Node , error )
163
168
}
164
169
165
- // CSINodeInfo interface represents anything that can get CSINode object from node ID .
170
+ // CSINodeInfo interface represents anything that can get CSINode object from node name .
166
171
type CSINodeInfo interface {
167
172
GetCSINodeInfo (nodeName string ) (* storagev1beta1.CSINode , error )
168
173
}
@@ -172,16 +177,13 @@ type PersistentVolumeInfo interface {
172
177
GetPersistentVolumeInfo (pvID string ) (* v1.PersistentVolume , error )
173
178
}
174
179
180
+ var _ PersistentVolumeInfo = & CachedPersistentVolumeInfo {}
181
+
175
182
// CachedPersistentVolumeInfo implements PersistentVolumeInfo
176
183
type CachedPersistentVolumeInfo struct {
177
184
corelisters.PersistentVolumeLister
178
185
}
179
186
180
- // Ordering returns the ordering of predicates.
181
- func Ordering () []string {
182
- return predicatesOrdering
183
- }
184
-
185
187
// GetPersistentVolumeInfo returns a persistent volume object by PV ID.
186
188
func (c * CachedPersistentVolumeInfo ) GetPersistentVolumeInfo (pvID string ) (* v1.PersistentVolume , error ) {
187
189
return c .Get (pvID )
@@ -193,12 +195,14 @@ type PersistentVolumeClaimInfo interface {
193
195
GetPersistentVolumeClaimInfo (namespace string , name string ) (* v1.PersistentVolumeClaim , error )
194
196
}
195
197
198
+ var _ PersistentVolumeClaimInfo = & CachedPersistentVolumeClaimInfo {}
199
+
196
200
// CachedPersistentVolumeClaimInfo implements PersistentVolumeClaimInfo
197
201
type CachedPersistentVolumeClaimInfo struct {
198
202
corelisters.PersistentVolumeClaimLister
199
203
}
200
204
201
- // GetPersistentVolumeClaimInfo fetches the claim in specified namespace with specified name
205
+ // GetPersistentVolumeClaimInfo fetches the claim in specified namespace with specified name.
202
206
func (c * CachedPersistentVolumeClaimInfo ) GetPersistentVolumeClaimInfo (namespace string , name string ) (* v1.PersistentVolumeClaim , error ) {
203
207
return c .PersistentVolumeClaims (namespace ).Get (name )
204
208
}
@@ -208,6 +212,8 @@ type StorageClassInfo interface {
208
212
GetStorageClassInfo (className string ) (* storagev1.StorageClass , error )
209
213
}
210
214
215
+ var _ StorageClassInfo = & CachedStorageClassInfo {}
216
+
211
217
// CachedStorageClassInfo implements StorageClassInfo
212
218
type CachedStorageClassInfo struct {
213
219
storagelisters.StorageClassLister
@@ -301,7 +307,7 @@ type MaxPDVolumeCountChecker struct {
301
307
randomVolumeIDPrefix string
302
308
}
303
309
304
- // VolumeFilter contains information on how to filter PD Volumes when checking PD Volume caps
310
+ // VolumeFilter contains information on how to filter PD Volumes when checking PD Volume caps.
305
311
type VolumeFilter struct {
306
312
// Filter normal volumes
307
313
FilterVolume func (vol * v1.Volume ) (id string , relevant bool )
@@ -396,13 +402,13 @@ func getMaxEBSVolume(nodeInstanceType string) int {
396
402
return volumeutil .DefaultMaxEBSVolumes
397
403
}
398
404
399
- // getMaxVolLimitFromEnv checks the max PD volumes environment variable, otherwise returning a default value
405
+ // getMaxVolLimitFromEnv checks the max PD volumes environment variable, otherwise returning a default value.
400
406
func getMaxVolLimitFromEnv () int {
401
407
if rawMaxVols := os .Getenv (KubeMaxPDVols ); rawMaxVols != "" {
402
408
if parsedMaxVols , err := strconv .Atoi (rawMaxVols ); err != nil {
403
409
klog .Errorf ("Unable to parse maximum PD volumes value, using default: %v" , err )
404
410
} else if parsedMaxVols <= 0 {
405
- klog .Errorf ("Maximum PD volumes must be a positive value, using default " )
411
+ klog .Errorf ("Maximum PD volumes must be a positive value, using default" )
406
412
} else {
407
413
return parsedMaxVols
408
414
}
@@ -555,7 +561,7 @@ func (c *MaxPDVolumeCountChecker) predicate(pod *v1.Pod, meta PredicateMetadata,
555
561
return true , nil , nil
556
562
}
557
563
558
- // EBSVolumeFilter is a VolumeFilter for filtering AWS ElasticBlockStore Volumes
564
+ // EBSVolumeFilter is a VolumeFilter for filtering AWS ElasticBlockStore Volumes.
559
565
var EBSVolumeFilter = VolumeFilter {
560
566
FilterVolume : func (vol * v1.Volume ) (string , bool ) {
561
567
if vol .AWSElasticBlockStore != nil {
@@ -583,7 +589,7 @@ var EBSVolumeFilter = VolumeFilter{
583
589
},
584
590
}
585
591
586
- // GCEPDVolumeFilter is a VolumeFilter for filtering GCE PersistentDisk Volumes
592
+ // GCEPDVolumeFilter is a VolumeFilter for filtering GCE PersistentDisk Volumes.
587
593
var GCEPDVolumeFilter = VolumeFilter {
588
594
FilterVolume : func (vol * v1.Volume ) (string , bool ) {
589
595
if vol .GCEPersistentDisk != nil {
@@ -611,7 +617,7 @@ var GCEPDVolumeFilter = VolumeFilter{
611
617
},
612
618
}
613
619
614
- // AzureDiskVolumeFilter is a VolumeFilter for filtering Azure Disk Volumes
620
+ // AzureDiskVolumeFilter is a VolumeFilter for filtering Azure Disk Volumes.
615
621
var AzureDiskVolumeFilter = VolumeFilter {
616
622
FilterVolume : func (vol * v1.Volume ) (string , bool ) {
617
623
if vol .AzureDisk != nil {
@@ -639,7 +645,7 @@ var AzureDiskVolumeFilter = VolumeFilter{
639
645
},
640
646
}
641
647
642
- // CinderVolumeFilter is a VolumeFilter for filtering Cinder Volumes
648
+ // CinderVolumeFilter is a VolumeFilter for filtering Cinder Volumes.
643
649
// It will be deprecated once Openstack cloudprovider has been removed from in-tree.
644
650
var CinderVolumeFilter = VolumeFilter {
645
651
FilterVolume : func (vol * v1.Volume ) (string , bool ) {
@@ -1023,7 +1029,7 @@ func NewNodeLabelPredicate(labels []string, presence bool) FitPredicate {
1023
1029
//
1024
1030
// Alternately, eliminating nodes that have a certain label, regardless of value, is also useful
1025
1031
// A node may have a label with "retiring" as key and the date as the value
1026
- // and it may be desirable to avoid scheduling new pods on this node
1032
+ // and it may be desirable to avoid scheduling new pods on this node.
1027
1033
func (n * NodeLabelChecker ) CheckNodeLabelPresence (pod * v1.Pod , meta PredicateMetadata , nodeInfo * schedulernodeinfo.NodeInfo ) (bool , []PredicateFailureReason , error ) {
1028
1034
node := nodeInfo .Node ()
1029
1035
if node == nil {
@@ -1172,7 +1178,7 @@ func PodFitsHostPorts(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulerno
1172
1178
return true , nil , nil
1173
1179
}
1174
1180
1175
- // search two arrays and return true if they have at least one common element; return false otherwise
1181
+ // haveOverlap searches two arrays and returns true if they have at least one common element; returns false otherwise.
1176
1182
func haveOverlap (a1 , a2 []string ) bool {
1177
1183
if len (a1 ) > len (a2 ) {
1178
1184
a1 , a2 = a2 , a1
@@ -1192,7 +1198,7 @@ func haveOverlap(a1, a2 []string) bool {
1192
1198
}
1193
1199
1194
1200
// GeneralPredicates checks whether noncriticalPredicates and EssentialPredicates pass. noncriticalPredicates are the predicates
1195
- // that only non-critical pods need and EssentialPredicates are the predicates that all pods, including critical pods, need
1201
+ // that only non-critical pods need and EssentialPredicates are the predicates that all pods, including critical pods, need.
1196
1202
func GeneralPredicates (pod * v1.Pod , meta PredicateMetadata , nodeInfo * schedulernodeinfo.NodeInfo ) (bool , []PredicateFailureReason , error ) {
1197
1203
var predicateFails []PredicateFailureReason
1198
1204
for _ , predicate := range []FitPredicate {noncriticalPredicates , EssentialPredicates } {
@@ -1208,7 +1214,7 @@ func GeneralPredicates(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulern
1208
1214
return len (predicateFails ) == 0 , predicateFails , nil
1209
1215
}
1210
1216
1211
- // noncriticalPredicates are the predicates that only non-critical pods need
1217
+ // noncriticalPredicates are the predicates that only non-critical pods need.
1212
1218
func noncriticalPredicates (pod * v1.Pod , meta PredicateMetadata , nodeInfo * schedulernodeinfo.NodeInfo ) (bool , []PredicateFailureReason , error ) {
1213
1219
var predicateFails []PredicateFailureReason
1214
1220
fit , reasons , err := PodFitsResources (pod , meta , nodeInfo )
@@ -1222,7 +1228,7 @@ func noncriticalPredicates(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedu
1222
1228
return len (predicateFails ) == 0 , predicateFails , nil
1223
1229
}
1224
1230
1225
- // EssentialPredicates are the predicates that all pods, including critical pods, need
1231
+ // EssentialPredicates are the predicates that all pods, including critical pods, need.
1226
1232
func EssentialPredicates (pod * v1.Pod , meta PredicateMetadata , nodeInfo * schedulernodeinfo.NodeInfo ) (bool , []PredicateFailureReason , error ) {
1227
1233
var predicateFails []PredicateFailureReason
1228
1234
// TODO: PodFitsHostPorts is essential for now, but kubelet should ideally
@@ -1400,7 +1406,7 @@ func (c *PodAffinityChecker) getMatchingAntiAffinityTopologyPairsOfPods(pod *v1.
1400
1406
func (c * PodAffinityChecker ) satisfiesExistingPodsAntiAffinity (pod * v1.Pod , meta PredicateMetadata , nodeInfo * schedulernodeinfo.NodeInfo ) (PredicateFailureReason , error ) {
1401
1407
node := nodeInfo .Node ()
1402
1408
if node == nil {
1403
- return ErrExistingPodsAntiAffinityRulesNotMatch , fmt .Errorf ("Node is nil " )
1409
+ return ErrExistingPodsAntiAffinityRulesNotMatch , fmt .Errorf ("node not found " )
1404
1410
}
1405
1411
var topologyMaps * topologyPairsMaps
1406
1412
if predicateMeta , ok := meta .(* predicateMetadata ); ok {
@@ -1470,13 +1476,13 @@ func (c *PodAffinityChecker) nodeMatchesAnyTopologyTerm(pod *v1.Pod, topologyPai
1470
1476
return false
1471
1477
}
1472
1478
1473
- // Checks if scheduling the pod onto this node would break any term of this pod.
1479
+ // satisfiesPodsAffinityAntiAffinity checks if scheduling the pod onto this node would break any term of this pod.
1474
1480
func (c * PodAffinityChecker ) satisfiesPodsAffinityAntiAffinity (pod * v1.Pod ,
1475
1481
meta PredicateMetadata , nodeInfo * schedulernodeinfo.NodeInfo ,
1476
1482
affinity * v1.Affinity ) (PredicateFailureReason , error ) {
1477
1483
node := nodeInfo .Node ()
1478
1484
if node == nil {
1479
- return ErrPodAffinityRulesNotMatch , fmt .Errorf ("Node is nil " )
1485
+ return ErrPodAffinityRulesNotMatch , fmt .Errorf ("node not found " )
1480
1486
}
1481
1487
if predicateMeta , ok := meta .(* predicateMetadata ); ok {
1482
1488
// Check all affinity terms.
@@ -1592,7 +1598,7 @@ func CheckNodeUnschedulablePredicate(pod *v1.Pod, meta PredicateMetadata, nodeIn
1592
1598
return true , nil , nil
1593
1599
}
1594
1600
1595
- // PodToleratesNodeTaints checks if a pod tolerations can tolerate the node taints
1601
+ // PodToleratesNodeTaints checks if a pod tolerations can tolerate the node taints.
1596
1602
func PodToleratesNodeTaints (pod * v1.Pod , meta PredicateMetadata , nodeInfo * schedulernodeinfo.NodeInfo ) (bool , []PredicateFailureReason , error ) {
1597
1603
if nodeInfo == nil || nodeInfo .Node () == nil {
1598
1604
return false , []PredicateFailureReason {ErrNodeUnknownCondition }, nil
@@ -1604,7 +1610,7 @@ func PodToleratesNodeTaints(pod *v1.Pod, meta PredicateMetadata, nodeInfo *sched
1604
1610
})
1605
1611
}
1606
1612
1607
- // PodToleratesNodeNoExecuteTaints checks if a pod tolerations can tolerate the node's NoExecute taints
1613
+ // PodToleratesNodeNoExecuteTaints checks if a pod tolerations can tolerate the node's NoExecute taints.
1608
1614
func PodToleratesNodeNoExecuteTaints (pod * v1.Pod , meta PredicateMetadata , nodeInfo * schedulernodeinfo.NodeInfo ) (bool , []PredicateFailureReason , error ) {
1609
1615
return podToleratesNodeTaints (pod , nodeInfo , func (t * v1.Taint ) bool {
1610
1616
return t .Effect == v1 .TaintEffectNoExecute
@@ -1623,7 +1629,7 @@ func podToleratesNodeTaints(pod *v1.Pod, nodeInfo *schedulernodeinfo.NodeInfo, f
1623
1629
return false , []PredicateFailureReason {ErrTaintsTolerationsNotMatch }, nil
1624
1630
}
1625
1631
1626
- // isPodBestEffort checks if pod is scheduled with best-effort QoS
1632
+ // isPodBestEffort checks if pod is scheduled with best-effort QoS.
1627
1633
func isPodBestEffort (pod * v1.Pod ) bool {
1628
1634
return v1qos .GetPodQOS (pod ) == v1 .PodQOSBestEffort
1629
1635
}
0 commit comments