diff --git a/plugin/pkg/scheduler/algorithm/predicates/predicates.go b/plugin/pkg/scheduler/algorithm/predicates/predicates.go index c8710d495a8..8eb607845a8 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 }