Commit 5b69688b authored by xiangpengzhao's avatar xiangpengzhao

Check nil for pointer

parent 812b87c8
...@@ -169,6 +169,10 @@ func (c *MaxPDVolumeCountChecker) filterVolumes(volumes []api.Volume, namespace ...@@ -169,6 +169,10 @@ func (c *MaxPDVolumeCountChecker) filterVolumes(volumes []api.Volume, namespace
return nil return nil
} }
if pvc == nil {
return fmt.Errorf("PersistentVolumeClaim not found: %q", pvcName)
}
pvName := pvc.Spec.VolumeName pvName := pvc.Spec.VolumeName
if pvName == "" { if pvName == "" {
return fmt.Errorf("PersistentVolumeClaim is not bound: %q", pvcName) return fmt.Errorf("PersistentVolumeClaim is not bound: %q", pvcName)
...@@ -186,6 +190,10 @@ func (c *MaxPDVolumeCountChecker) filterVolumes(volumes []api.Volume, namespace ...@@ -186,6 +190,10 @@ func (c *MaxPDVolumeCountChecker) filterVolumes(volumes []api.Volume, namespace
return nil return nil
} }
if pv == nil {
return fmt.Errorf("PersistentVolume not found: %q", pvName)
}
if id, ok := c.filter.FilterPersistentVolume(pv); ok { if id, ok := c.filter.FilterPersistentVolume(pv); ok {
filteredVolumes[id] = true filteredVolumes[id] = true
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment