Merge pull request #26774 from xiangpengzhao/fix_predicatesnil

Automatic merge from submit-queue

Check nil pointer in predicates.go

Should check if the pointer is nil in func filterVolumes as is done in [func predicate](https://github.com/kubernetes/kubernetes/blob/master/plugin/pkg/scheduler/algorithm/predicates/predicates.go#L279).
pull/6/head
k8s-merge-robot 2016-06-30 01:45:26 -07:00 committed by GitHub
commit 61a9358dbd
1 changed files with 8 additions and 0 deletions

View File

@ -169,6 +169,10 @@ func (c *MaxPDVolumeCountChecker) filterVolumes(volumes []api.Volume, namespace
return nil
}
if pvc == nil {
return fmt.Errorf("PersistentVolumeClaim not found: %q", pvcName)
}
pvName := pvc.Spec.VolumeName
if pvName == "" {
return fmt.Errorf("PersistentVolumeClaim is not bound: %q", pvcName)
@ -186,6 +190,10 @@ func (c *MaxPDVolumeCountChecker) filterVolumes(volumes []api.Volume, namespace
return nil
}
if pv == nil {
return fmt.Errorf("PersistentVolume not found: %q", pvName)
}
if id, ok := c.filter.FilterPersistentVolume(pv); ok {
filteredVolumes[id] = true
}