From a0e6d68026eb39bdf0b8e1c6917136cbe3238f7b Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Wed, 9 Dec 2015 11:45:56 -0800 Subject: [PATCH] scheduler: fast check when there is no conflicts --- plugin/pkg/scheduler/algorithm/predicates/predicates.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugin/pkg/scheduler/algorithm/predicates/predicates.go b/plugin/pkg/scheduler/algorithm/predicates/predicates.go index a885637d23..4755a9d48c 100644 --- a/plugin/pkg/scheduler/algorithm/predicates/predicates.go +++ b/plugin/pkg/scheduler/algorithm/predicates/predicates.go @@ -73,9 +73,13 @@ func (c *CachedNodeInfo) GetNodeInfo(id string) (*api.Node, error) { } func isVolumeConflict(volume api.Volume, pod *api.Pod) bool { + // fast path if there is no conflict checking targets. + if volume.GCEPersistentDisk == nil && volume.AWSElasticBlockStore == nil && volume.RBD == nil { + return false + } + for _, existingVolume := range pod.Spec.Volumes { - // Same GCE Disk can be mounted as read-only by multiple pod simultaneously. - // Or they conflicts + // Same GCE disk mounted by multiple pods conflicts unless all pods mount it read-only. if volume.GCEPersistentDisk != nil && existingVolume.GCEPersistentDisk != nil { disk, existingDisk := volume.GCEPersistentDisk, existingVolume.GCEPersistentDisk if disk.PDName == existingDisk.PDName && !(disk.ReadOnly && existingDisk.ReadOnly) {