mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Merge pull request #107302 from pacoxu/fix/empty-dir-quota-monitoring
assignQuota checks if the underlying medium supports quotas and if so setting it
This commit is contained in:
commit
4f35d80f4e
@ -257,7 +257,9 @@ func (ed *emptyDir) SetUpAt(dir string, mounterArgs volume.MounterArgs) error {
|
|||||||
} else if ed.medium == v1.StorageMediumDefault {
|
} else if ed.medium == v1.StorageMediumDefault {
|
||||||
// Further check dir exists
|
// Further check dir exists
|
||||||
if _, err := os.Stat(dir); err == nil {
|
if _, err := os.Stat(dir); err == nil {
|
||||||
return nil
|
klog.V(6).InfoS("Dir exists, so check and assign quota if the underlying medium supports quotas", "dir", dir)
|
||||||
|
err = ed.assignQuota(dir, mounterArgs.DesiredSize)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
// This situation should not happen unless user manually delete volume dir.
|
// This situation should not happen unless user manually delete volume dir.
|
||||||
// In this case, delete ready file and print a warning for it.
|
// In this case, delete ready file and print a warning for it.
|
||||||
@ -286,23 +288,30 @@ func (ed *emptyDir) SetUpAt(dir string, mounterArgs volume.MounterArgs) error {
|
|||||||
// enforcement.
|
// enforcement.
|
||||||
if err == nil {
|
if err == nil {
|
||||||
volumeutil.SetReady(ed.getMetaDir())
|
volumeutil.SetReady(ed.getMetaDir())
|
||||||
if mounterArgs.DesiredSize != nil {
|
err = ed.assignQuota(dir, mounterArgs.DesiredSize)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// assignQuota checks if the underlying medium supports quotas and if so, sets
|
||||||
|
func (ed *emptyDir) assignQuota(dir string, mounterSize *resource.Quantity) error {
|
||||||
|
if mounterSize != nil {
|
||||||
// Deliberately shadow the outer use of err as noted
|
// Deliberately shadow the outer use of err as noted
|
||||||
// above.
|
// above.
|
||||||
hasQuotas, err := fsquota.SupportsQuotas(ed.mounter, dir)
|
hasQuotas, err := fsquota.SupportsQuotas(ed.mounter, dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.V(3).Infof("Unable to check for quota support on %s: %s", dir, err.Error())
|
klog.V(3).Infof("Unable to check for quota support on %s: %s", dir, err.Error())
|
||||||
} else if hasQuotas {
|
} else if hasQuotas {
|
||||||
klog.V(4).Infof("emptydir trying to assign quota %v on %s", mounterArgs.DesiredSize, dir)
|
klog.V(4).Infof("emptydir trying to assign quota %v on %s", mounterSize, dir)
|
||||||
err := fsquota.AssignQuota(ed.mounter, dir, ed.pod.UID, mounterArgs.DesiredSize)
|
err := fsquota.AssignQuota(ed.mounter, dir, ed.pod.UID, mounterSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.V(3).Infof("Set quota on %s failed %s", dir, err.Error())
|
klog.V(3).Infof("Set quota on %s failed %s", dir, err.Error())
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// setupTmpfs creates a tmpfs mount at the specified directory.
|
// setupTmpfs creates a tmpfs mount at the specified directory.
|
||||||
func (ed *emptyDir) setupTmpfs(dir string) error {
|
func (ed *emptyDir) setupTmpfs(dir string) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user