mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
check existing size before querying new size from api-server
This commit is contained in:
parent
1809094389
commit
a99466ca86
@ -588,6 +588,11 @@ func (asw *actualStateOfWorld) InitializeClaimSize(volumeName v1.UniqueVolumeNam
|
||||
klog.V(5).Infof("no-op InitializeClaimSize call in attach-detach controller.")
|
||||
}
|
||||
|
||||
func (asw *actualStateOfWorld) GetClaimSize(volumeName v1.UniqueVolumeName) *resource.Quantity {
|
||||
// not needed in attach-detach controller
|
||||
return nil
|
||||
}
|
||||
|
||||
func (asw *actualStateOfWorld) GetAttachedVolumes() []AttachedVolume {
|
||||
asw.RLock()
|
||||
defer asw.RUnlock()
|
||||
|
@ -613,6 +613,17 @@ func (asw *actualStateOfWorld) InitializeClaimSize(volumeName v1.UniqueVolumeNam
|
||||
}
|
||||
}
|
||||
|
||||
func (asw *actualStateOfWorld) GetClaimSize(volumeName v1.UniqueVolumeName) *resource.Quantity {
|
||||
asw.RLock()
|
||||
defer asw.RUnlock()
|
||||
|
||||
volumeObj, ok := asw.attachedVolumes[volumeName]
|
||||
if ok {
|
||||
return volumeObj.persistentVolumeSize
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (asw *actualStateOfWorld) DeletePodFromVolume(
|
||||
podName volumetypes.UniquePodName, volumeName v1.UniqueVolumeName) error {
|
||||
asw.Lock()
|
||||
|
@ -248,6 +248,8 @@ type ActualStateOfWorldAttacherUpdater interface {
|
||||
|
||||
// InitializeClaimSize sets pvc claim size by reading pvc.Status.Capacity
|
||||
InitializeClaimSize(volumeName v1.UniqueVolumeName, claimSize *resource.Quantity)
|
||||
|
||||
GetClaimSize(volumeName v1.UniqueVolumeName) *resource.Quantity
|
||||
}
|
||||
|
||||
// VolumeLogger defines a set of operations for generating volume-related logging and error msgs
|
||||
|
@ -1480,9 +1480,10 @@ func (og *operationGenerator) GenerateVerifyControllerAttachedVolumeFunc(
|
||||
|
||||
verifyControllerAttachedVolumeFunc := func() volumetypes.OperationContext {
|
||||
migrated := getMigratedStatusBySpec(volumeToMount.VolumeSpec)
|
||||
var claimSize *resource.Quantity
|
||||
claimSize := actualStateOfWorld.GetClaimSize(volumeToMount.VolumeName)
|
||||
|
||||
if volumeToMount.VolumeSpec.PersistentVolume != nil {
|
||||
// only fetch claimSize if it was not set previously
|
||||
if volumeToMount.VolumeSpec.PersistentVolume != nil && claimSize == nil {
|
||||
pv := volumeToMount.VolumeSpec.PersistentVolume
|
||||
pvc, err := og.kubeClient.CoreV1().PersistentVolumeClaims(pv.Spec.ClaimRef.Namespace).Get(context.TODO(), pv.Spec.ClaimRef.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user