Add limit of stored errors

There should be a limit so the set of errors does not grow too much in
case of some bug in the populator.
This commit is contained in:
Jan Safranek 2019-08-05 10:06:44 +02:00
parent af0c2fe572
commit c744385804

View File

@ -206,6 +206,12 @@ type podToMount struct {
outerVolumeSpecName string
}
const (
// Maximum errors to be stored per pod in desiredStateOfWorld.podErrors to
// prevent unbound growth.
maxPodErrors = 10
)
func (dsw *desiredStateOfWorld) AddPodToVolume(
podName types.UniquePodName,
pod *v1.Pod,
@ -436,7 +442,9 @@ func (dsw *desiredStateOfWorld) AddErrorToPod(podName types.UniquePodName, err s
defer dsw.Unlock()
if errs, found := dsw.podErrors[podName]; found {
errs.Insert(err)
if errs.Len() <= maxPodErrors {
errs.Insert(err)
}
return
}
dsw.podErrors[podName] = sets.NewString(err)