From 4965a7a8a06b08a1f2cc816cc0d46ddd68a1e8fe Mon Sep 17 00:00:00 2001 From: lauralorenz Date: Mon, 4 Nov 2024 22:07:28 -0800 Subject: [PATCH] KEP-4603: Refactor various hardcoded backoffs into separate constants (#128369) * Refactor various hardcoded backoffs into separate constants Signed-off-by: Laura Lorenz * Fix comment formatting Signed-off-by: Laura Lorenz --------- Signed-off-by: Laura Lorenz --- pkg/kubelet/kubelet.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/pkg/kubelet/kubelet.go b/pkg/kubelet/kubelet.go index 8da0e4fb691..32730eb0bb2 100644 --- a/pkg/kubelet/kubelet.go +++ b/pkg/kubelet/kubelet.go @@ -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,