Change:
The log below was by myself to see the duration for empty dir. I have two pods in the node and one is created after kubelet restart, the other was created before kubelet restarted. Two volumes above are for empty dir. You can see the log above, volume is not called and volume is called by Both empty dir should be monitored by quota as the quota monitoring as LocalStorageCapacityIsolationFSQuotaMonitoring is enabled and the pquota is enabled. Create a pod as above and run under /data/test of the pod to generate about 1.9G data. If we add some log/metrics for volume stats, we can see that the of the empty dir will cost only about 100ms or less to get the disk usage of this empty dir. If using to get the disk usage of the folder above, it would cost about 10s. Restart the kubelet. We can see the disk-usage-stat is not using the quota. If you create another pod like above, the new pod would use the quota and the old one is using to get disk usage. N/A <details</details<detailsvsphere </details<details</details<detailskubeadm </details<detailscontainerd </details<detailscalico </details
/sig node /assign /triage accepted
does this only happen on emptydir?
I tested with empty dir. According to the code, the problem should be only with empty dir, see

Discussion:
} else if ed.medium == v1.StorageMediumDefault { // Further check dir exists if _, err := os.Stat(dir); err == nil { <del> return nil </del> <ins> 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 </ins> } // This situation should not happen unless user manually delete volume dir. // In this case, delete ready file and print a warning for it.

// enforcement. if err == nil { volumeutil.SetReady(ed.getMetaDir()) <del> if mounterArgs.DesiredSize != nil { // Deliberately shadow the outer use of err as noted // above. hasQuotas, err := fsquota.SupportsQuotas(ed.mounter, dir) </del> <ins> 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 // above. hasQuotas, err := fsquota.SupportsQuotas(ed.mounter, dir) if err != nil { klog.V(3).Infof("Unable to check for quota support on %s: %s", dir, err.Error()) } else if hasQuotas { klog.V(4).Infof("emptydir trying to assign quota %v on %s", mounterSize, dir) err := fsquota.AssignQuota(ed.mounter, dir, ed.pod.UID, mounterSize) </ins> if err != nil { <del> klog.V(3).Infof("Unable to check for quota support on %s: %s", dir, err.Error()) } else if hasQuotas { klog.V(4).Infof("emptydir trying to assign quota %v on %s", mounterArgs.DesiredSize, dir) err := fsquota.AssignQuota(ed.mounter, dir, ed.pod.UID, mounterArgs.DesiredSize) if err != nil { klog.V(3).Infof("Set quota on %s failed %s", dir, err.Error()) } </del> <ins> klog.V(3).Infof("Set quota on %s failed %s", dir, err.Error()) </ins> } <ins> return err </ins> } } <del> return err </del> <ins> return nil </ins> } // setupTmpfs creates a tmpfs mount at the specified directory.