Set sizeLimit to the smaller of the ephemeral storage limit and the emptydir limit (if set)

This commit is contained in:
Robert Krawitz 2019-05-21 18:30:37 -04:00
parent 9f4a4d1f49
commit 38753efcc7

View File

@ -238,6 +238,12 @@ func (dsw *desiredStateOfWorld) AddPodToVolume(
_, podLimits := apiv1resource.PodRequestsAndLimits(pod)
ephemeralStorageLimit := podLimits[v1.ResourceEphemeralStorage]
sizeLimit = resource.NewQuantity(ephemeralStorageLimit.Value(), resource.BinarySI)
if volumeSpec.Volume.EmptyDir != nil &&
volumeSpec.Volume.EmptyDir.SizeLimit != nil &&
volumeSpec.Volume.EmptyDir.SizeLimit.Value() > 0 &&
volumeSpec.Volume.EmptyDir.SizeLimit.Value() < sizeLimit.Value() {
sizeLimit = resource.NewQuantity(volumeSpec.Volume.EmptyDir.SizeLimit.Value(), resource.BinarySI)
}
}
}
dsw.volumesToMount[volumeName] = volumeToMount{