Add a function to record volume size in dsow

This commit is contained in:
Hemant Kumar 2022-02-21 16:37:29 -05:00
parent 10f91a9951
commit 2e54686f1b

View File

@ -124,6 +124,11 @@ type DesiredStateOfWorld interface {
// MarkVolumeAttachability updates the volume's attachability for a given volume
MarkVolumeAttachability(volumeName v1.UniqueVolumeName, attachable bool)
// UpdatePersistentVolumeSize updates persistentVolumeSize in desired state of the world
// so as it can be compared against actual size and volume expansion performed
// if necessary
UpdatePersistentVolumeSize(volumeName v1.UniqueVolumeName, size resource.Quantity)
}
// VolumeToMount represents a volume that is attached to this node and needs to
@ -359,6 +364,19 @@ func (dsw *desiredStateOfWorld) DeletePodFromVolume(
}
}
// UpdatePersistentVolumeSize updates last known PV size. This is used for volume expansion and
// should be only used for persistent volumes.
func (dsw *desiredStateOfWorld) UpdatePersistentVolumeSize(volumeName v1.UniqueVolumeName, size resource.Quantity) {
dsw.Lock()
defer dsw.Unlock()
vol, volExists := dsw.volumesToMount[volumeName]
if volExists {
vol.persistentVolumeSize = size
dsw.volumesToMount[volumeName] = vol
}
}
func (dsw *desiredStateOfWorld) VolumeExists(
volumeName v1.UniqueVolumeName) bool {
dsw.RLock()