Use v1helper.GetPersistentVolumeClass for compatibility

This commit is contained in:
Shintaro Murakami
2020-08-06 09:26:21 +09:00
parent 382107e6c8
commit b7792711f5

View File

@@ -26,6 +26,7 @@ import (
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/client-go/tools/cache"
v1helper "k8s.io/kubernetes/pkg/apis/core/v1/helper"
)
// AssumeCache is a cache on top of the informer that allows for updating
@@ -357,7 +358,7 @@ type pvAssumeCache struct {
func pvStorageClassIndexFunc(obj interface{}) ([]string, error) {
if pv, ok := obj.(*v1.PersistentVolume); ok {
return []string{pv.Spec.StorageClassName}, nil
return []string{v1helper.GetPersistentVolumeClass(pv)}, nil
}
return []string{""}, fmt.Errorf("object is not a v1.PersistentVolume: %v", obj)
}