KEP-4603: Refactor various hardcoded backoffs into separate constants (#128369)

* Refactor various hardcoded backoffs into separate constants

Signed-off-by: Laura Lorenz <lauralorenz@google.com>

* Fix comment formatting

Signed-off-by: Laura Lorenz <lauralorenz@google.com>

---------

Signed-off-by: Laura Lorenz <lauralorenz@google.com>
This commit is contained in:
lauralorenz 2024-11-04 22:07:28 -08:00 committed by GitHub
parent e5a31e8bbc
commit 4965a7a8a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -144,9 +144,12 @@ const (
// DefaultContainerLogsDir is the location of container logs.
DefaultContainerLogsDir = "/var/log/containers"
// MaxContainerBackOff is the max backoff period, exported for the e2e test
// MaxContainerBackOff is the max backoff period for container restarts, exported for the e2e test
MaxContainerBackOff = 300 * time.Second
// MaxImageBackOff is the max backoff period for image pulls, exported for the e2e test
MaxImageBackOff = 300 * time.Second
// Period for performing global cleanup tasks.
housekeepingPeriod = time.Second * 2
@ -189,10 +192,15 @@ const (
eventedPlegMaxStreamRetries = 5
// backOffPeriod is the period to back off when pod syncing results in an
// error. It is also used as the base period for the exponential backoff
// container restarts and image pulls.
// error.
backOffPeriod = time.Second * 10
// Initial period for the exponential backoff for container restarts.
containerBackOffPeriod = time.Second * 10
// Initial period for the exponential backoff for image pulls.
imageBackOffPeriod = time.Second * 10
// ContainerGCPeriod is the period for performing container garbage collection.
ContainerGCPeriod = time.Minute
// ImageGCPeriod is the period for performing image garbage collection.
@ -615,7 +623,7 @@ func NewMainKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
machineInfo.Timestamp = time.Time{}
klet.setCachedMachineInfo(machineInfo)
imageBackOff := flowcontrol.NewBackOff(backOffPeriod, MaxContainerBackOff)
imageBackOff := flowcontrol.NewBackOff(imageBackOffPeriod, MaxImageBackOff)
klet.livenessManager = proberesults.NewManager()
klet.readinessManager = proberesults.NewManager()
@ -874,7 +882,7 @@ func NewMainKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
kubeDeps.Recorder,
volumepathhandler.NewBlockVolumePathHandler())
klet.backOff = flowcontrol.NewBackOff(backOffPeriod, MaxContainerBackOff)
klet.backOff = flowcontrol.NewBackOff(containerBackOffPeriod, MaxContainerBackOff)
// setup eviction manager
evictionManager, evictionAdmitHandler := eviction.NewManager(klet.resourceAnalyzer, evictionConfig,