Skip to content

Commit

Permalink
Short circuit volume checker if the pod is not requesting any volumes
Browse files Browse the repository at this point in the history
  • Loading branch information
bsalamat committed Feb 2, 2019
1 parent 30566b9 commit eb59bc6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/scheduler/algorithm/predicates/predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -1642,7 +1642,21 @@ func NewVolumeBindingPredicate(binder *volumebinder.VolumeBinder) FitPredicate {
return c.predicate
}

func podHasPVCs(pod *v1.Pod) bool {
for _, vol := range pod.Spec.Volumes {
if vol.PersistentVolumeClaim != nil {
return true
}
}
return false
}

func (c *VolumeBindingChecker) predicate(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error) {
// If pod does not request any PVC, we don't need to do anything.
if !podHasPVCs(pod) {
return true, nil, nil
}

node := nodeInfo.Node()
if node == nil {
return false, nil, fmt.Errorf("node not found")
Expand Down

0 comments on commit eb59bc6

Please sign in to comment.