mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Record size of volume in desired and actual state of the world
This commit is contained in:
parent
16fe367389
commit
6eea80ec97
@ -25,6 +25,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
"k8s.io/kubernetes/pkg/volume"
|
"k8s.io/kubernetes/pkg/volume"
|
||||||
@ -284,6 +285,9 @@ type attachedVolume struct {
|
|||||||
// volumeInUseErrorForExpansion indicates volume driver has previously returned volume-in-use error
|
// volumeInUseErrorForExpansion indicates volume driver has previously returned volume-in-use error
|
||||||
// for this volume and volume expansion on this node should not be retried
|
// for this volume and volume expansion on this node should not be retried
|
||||||
volumeInUseErrorForExpansion bool
|
volumeInUseErrorForExpansion bool
|
||||||
|
|
||||||
|
// persistentVolumeSize records size of the volume when pod was started.
|
||||||
|
persistentVolumeSize resource.Quantity
|
||||||
}
|
}
|
||||||
|
|
||||||
// The mountedPod object represents a pod for which the kubelet volume manager
|
// The mountedPod object represents a pod for which the kubelet volume manager
|
||||||
|
@ -186,6 +186,9 @@ type volumeToMount struct {
|
|||||||
// desiredSizeLimit indicates the desired upper bound on the size of the volume
|
// desiredSizeLimit indicates the desired upper bound on the size of the volume
|
||||||
// (if so implemented)
|
// (if so implemented)
|
||||||
desiredSizeLimit *resource.Quantity
|
desiredSizeLimit *resource.Quantity
|
||||||
|
|
||||||
|
// persistentVolumeSize records desired size of a persistent volume.
|
||||||
|
persistentVolumeSize resource.Quantity
|
||||||
}
|
}
|
||||||
|
|
||||||
// The pod object represents a pod that references the underlying volume and
|
// The pod object represents a pod that references the underlying volume and
|
||||||
@ -274,7 +277,7 @@ func (dsw *desiredStateOfWorld) AddPodToVolume(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dsw.volumesToMount[volumeName] = volumeToMount{
|
vmt := volumeToMount{
|
||||||
volumeName: volumeName,
|
volumeName: volumeName,
|
||||||
podsToMount: make(map[types.UniquePodName]podToMount),
|
podsToMount: make(map[types.UniquePodName]podToMount),
|
||||||
pluginIsAttachable: attachable,
|
pluginIsAttachable: attachable,
|
||||||
@ -283,6 +286,15 @@ func (dsw *desiredStateOfWorld) AddPodToVolume(
|
|||||||
reportedInUse: false,
|
reportedInUse: false,
|
||||||
desiredSizeLimit: sizeLimit,
|
desiredSizeLimit: sizeLimit,
|
||||||
}
|
}
|
||||||
|
// record desired size of the volume
|
||||||
|
if volumeSpec.PersistentVolume != nil {
|
||||||
|
pvCap := volumeSpec.PersistentVolume.Spec.Capacity.Storage()
|
||||||
|
if pvCap != nil {
|
||||||
|
vmt.persistentVolumeSize = *pvCap
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dsw.volumesToMount[volumeName] = vmt
|
||||||
}
|
}
|
||||||
oldPodMount, ok := dsw.volumesToMount[volumeName].podsToMount[podName]
|
oldPodMount, ok := dsw.volumesToMount[volumeName].podsToMount[podName]
|
||||||
mountRequestTime := time.Now()
|
mountRequestTime := time.Now()
|
||||||
|
Loading…
Reference in New Issue
Block a user