mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Use v1helper.GetPersistentVolumeClaimClass for compatibility
This commit is contained in:
		@@ -665,11 +665,7 @@ func (b *volumeBinder) findMatchingVolumes(pod *v1.Pod, claimsToBind []*v1.Persi
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	for _, pvc := range claimsToBind {
 | 
						for _, pvc := range claimsToBind {
 | 
				
			||||||
		// Get storage class name from each PVC
 | 
							// Get storage class name from each PVC
 | 
				
			||||||
		storageClassName := ""
 | 
							storageClassName := v1helper.GetPersistentVolumeClaimClass(pvc)
 | 
				
			||||||
		storageClass := pvc.Spec.StorageClassName
 | 
					 | 
				
			||||||
		if storageClass != nil {
 | 
					 | 
				
			||||||
			storageClassName = *storageClass
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		allPVs := b.pvCache.ListPVs(storageClassName)
 | 
							allPVs := b.pvCache.ListPVs(storageClassName)
 | 
				
			||||||
		pvcName := getPVCName(pvc)
 | 
							pvcName := getPVCName(pvc)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,6 +25,7 @@ import (
 | 
				
			|||||||
	utilfeature "k8s.io/apiserver/pkg/util/feature"
 | 
						utilfeature "k8s.io/apiserver/pkg/util/feature"
 | 
				
			||||||
	csilib "k8s.io/csi-translation-lib"
 | 
						csilib "k8s.io/csi-translation-lib"
 | 
				
			||||||
	"k8s.io/klog"
 | 
						"k8s.io/klog"
 | 
				
			||||||
 | 
						v1helper "k8s.io/kubernetes/pkg/apis/core/v1/helper"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/features"
 | 
						"k8s.io/kubernetes/pkg/features"
 | 
				
			||||||
	schedulernodeinfo "k8s.io/kubernetes/pkg/scheduler/nodeinfo"
 | 
						schedulernodeinfo "k8s.io/kubernetes/pkg/scheduler/nodeinfo"
 | 
				
			||||||
	volumeutil "k8s.io/kubernetes/pkg/volume/util"
 | 
						volumeutil "k8s.io/kubernetes/pkg/volume/util"
 | 
				
			||||||
@@ -208,16 +209,16 @@ func (c *CSIMaxVolumeLimitChecker) getCSIDriverInfo(csiNode *storagev1beta1.CSIN
 | 
				
			|||||||
func (c *CSIMaxVolumeLimitChecker) getCSIDriverInfoFromSC(csiNode *storagev1beta1.CSINode, pvc *v1.PersistentVolumeClaim) (string, string) {
 | 
					func (c *CSIMaxVolumeLimitChecker) getCSIDriverInfoFromSC(csiNode *storagev1beta1.CSINode, pvc *v1.PersistentVolumeClaim) (string, string) {
 | 
				
			||||||
	namespace := pvc.Namespace
 | 
						namespace := pvc.Namespace
 | 
				
			||||||
	pvcName := pvc.Name
 | 
						pvcName := pvc.Name
 | 
				
			||||||
	scName := pvc.Spec.StorageClassName
 | 
						scName := v1helper.GetPersistentVolumeClaimClass(pvc)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// If StorageClass is not set or not found, then PVC must be using immediate binding mode
 | 
						// If StorageClass is not set or not found, then PVC must be using immediate binding mode
 | 
				
			||||||
	// and hence it must be bound before scheduling. So it is safe to not count it.
 | 
						// and hence it must be bound before scheduling. So it is safe to not count it.
 | 
				
			||||||
	if scName == nil {
 | 
						if scName == "" {
 | 
				
			||||||
		klog.V(5).Infof("PVC %s/%s has no StorageClass", namespace, pvcName)
 | 
							klog.V(5).Infof("PVC %s/%s has no StorageClass", namespace, pvcName)
 | 
				
			||||||
		return "", ""
 | 
							return "", ""
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	storageClass, err := c.scInfo.GetStorageClassInfo(*scName)
 | 
						storageClass, err := c.scInfo.GetStorageClassInfo(scName)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		klog.V(5).Infof("Could not get StorageClass for PVC %s/%s: %v", namespace, pvcName, err)
 | 
							klog.V(5).Infof("Could not get StorageClass for PVC %s/%s: %v", namespace, pvcName, err)
 | 
				
			||||||
		return "", ""
 | 
							return "", ""
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user