fix: add nil check for storage class name

Signed-off-by: stoneshi-yunify <70880165+stoneshi-yunify@users.noreply.github.com>
This commit is contained in:
stoneshi-yunify
2020-09-14 18:40:07 +08:00
parent 6f12f72d3a
commit 81fe75fae2

View File

@@ -107,7 +107,7 @@ func (s *storageClassesSearcher) countPersistentVolumeClaims(name string) int {
var count int
for _, pvc := range pvcs {
if *pvc.Spec.StorageClassName == name || (pvc.Annotations != nil && pvc.Annotations[corev1.BetaStorageClassAnnotation] == name) {
if (pvc.Spec.StorageClassName != nil && *pvc.Spec.StorageClassName == name) || (pvc.Annotations != nil && pvc.Annotations[corev1.BetaStorageClassAnnotation] == name) {
count++
}
}