From 5b69688b4bd3e0563ee3a99254111112ebd95c95 Mon Sep 17 00:00:00 2001 From: xiangpengzhao Date: Fri, 3 Jun 2016 01:02:26 -0400 Subject: [PATCH] Check nil for pointer --- plugin/pkg/scheduler/algorithm/predicates/predicates.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugin/pkg/scheduler/algorithm/predicates/predicates.go b/plugin/pkg/scheduler/algorithm/predicates/predicates.go index 3be33839a30..18381d6eb7d 100644 --- a/plugin/pkg/scheduler/algorithm/predicates/predicates.go +++ b/plugin/pkg/scheduler/algorithm/predicates/predicates.go @@ -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 }