Skip to content

Commit

Permalink
Don't use containerLogManager for cri-dockerd as docker rotating logs…
Browse files Browse the repository at this point in the history
… isn't supported
  • Loading branch information
kinarashah authored and github-actions[bot] committed Nov 22, 2024
1 parent 41352be commit db94b0e
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions pkg/kubelet/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -331,6 +332,7 @@ func PreInitRuntimeService(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
}

kubeDeps.useLegacyCadvisorStats = cadvisor.UsingLegacyCadvisorStats(kubeCfg.ContainerRuntimeEndpoint)
kubeDeps.remoteRuntimeEndpoint = kubeCfg.ContainerRuntimeEndpoint
return nil
}

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit db94b0e

Please sign in to comment.