From db94b0edea635d8196d4899f7c644fcfdd75112a Mon Sep 17 00:00:00 2001 From: Kinara Shah Date: Tue, 22 Aug 2023 11:32:54 -0700 Subject: [PATCH] Don't use containerLogManager for cri-dockerd as docker rotating logs isn't supported --- pkg/kubelet/kubelet.go | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/pkg/kubelet/kubelet.go b/pkg/kubelet/kubelet.go index 2ff23947a4036..572f52f2162ae 100644 --- a/pkg/kubelet/kubelet.go +++ b/pkg/kubelet/kubelet.go @@ -277,6 +277,7 @@ type Dependencies struct { NodeStartupLatencyTracker util.NodeStartupLatencyTracker // remove it after cadvisor.UsingLegacyCadvisorStats dropped. useLegacyCadvisorStats bool + remoteRuntimeEndpoint string } // makePodSourceConfig creates a config.PodConfig from the given @@ -331,6 +332,7 @@ func PreInitRuntimeService(kubeCfg *kubeletconfiginternal.KubeletConfiguration, } kubeDeps.useLegacyCadvisorStats = cadvisor.UsingLegacyCadvisorStats(kubeCfg.ContainerRuntimeEndpoint) + kubeDeps.remoteRuntimeEndpoint = kubeCfg.ContainerRuntimeEndpoint return nil } @@ -623,19 +625,24 @@ func NewMainKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration, klet.runtimeClassManager = runtimeclass.NewManager(kubeDeps.KubeClient) } - // setup containerLogManager for CRI container runtime - containerLogManager, err := logs.NewContainerLogManager( - klet.runtimeService, - kubeDeps.OSInterface, - kubeCfg.ContainerLogMaxSize, - int(kubeCfg.ContainerLogMaxFiles), - int(kubeCfg.ContainerLogMaxWorkers), - kubeCfg.ContainerLogMonitorInterval, - ) - if err != nil { - return nil, fmt.Errorf("failed to initialize container log manager: %v", err) + // cri-dockerd does not support rotating logs, same as internal dockershim + if cadvisor.UsingCriDockerdSocket(kubeDeps.remoteRuntimeEndpoint) { + klet.containerLogManager = logs.NewStubContainerLogManager() + } else { + // setup containerLogManager for CRI container runtime + containerLogManager, err := logs.NewContainerLogManager( + klet.runtimeService, + kubeDeps.OSInterface, + kubeCfg.ContainerLogMaxSize, + int(kubeCfg.ContainerLogMaxFiles), + int(kubeCfg.ContainerLogMaxWorkers), + kubeCfg.ContainerLogMonitorInterval, + ) + if err != nil { + return nil, fmt.Errorf("failed to initialize container log manager: %v", err) + } + klet.containerLogManager = containerLogManager } - klet.containerLogManager = containerLogManager klet.reasonCache = NewReasonCache() klet.workQueue = queue.NewBasicWorkQueue(klet.clock)