scheduler: fast check when there is no conflicts

pull/6/head
Xiang Li 2015-12-09 11:45:56 -08:00
parent d2dfb4906f
commit a0e6d68026
1 changed files with 6 additions and 2 deletions

View File

@ -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) {