mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-11-02 06:47:34 +00:00
Second attempt: Plumb context to Kubelet CRI calls (#113591)
* plumb context from CRI calls through kubelet * clean up extra timeouts * try fixing incorrectly cancelled context
This commit is contained in:
@@ -21,6 +21,7 @@ package cm
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
@@ -551,9 +552,10 @@ func (cm *containerManagerImpl) Start(node *v1.Node,
|
||||
podStatusProvider status.PodStatusProvider,
|
||||
runtimeService internalapi.RuntimeService,
|
||||
localStorageCapacityIsolation bool) error {
|
||||
ctx := context.Background()
|
||||
|
||||
// Initialize CPU manager
|
||||
containerMap := buildContainerMapFromRuntime(runtimeService)
|
||||
containerMap := buildContainerMapFromRuntime(ctx, runtimeService)
|
||||
err := cm.cpuManager.Start(cpumanager.ActivePodsFunc(activePods), sourcesReady, podStatusProvider, runtimeService, containerMap)
|
||||
if err != nil {
|
||||
return fmt.Errorf("start cpu manager error: %v", err)
|
||||
@@ -561,7 +563,7 @@ func (cm *containerManagerImpl) Start(node *v1.Node,
|
||||
|
||||
// Initialize memory manager
|
||||
if utilfeature.DefaultFeatureGate.Enabled(kubefeatures.MemoryManager) {
|
||||
containerMap := buildContainerMapFromRuntime(runtimeService)
|
||||
containerMap := buildContainerMapFromRuntime(ctx, runtimeService)
|
||||
err := cm.memoryManager.Start(memorymanager.ActivePodsFunc(activePods), sourcesReady, podStatusProvider, runtimeService, containerMap)
|
||||
if err != nil {
|
||||
return fmt.Errorf("start memory manager error: %v", err)
|
||||
@@ -719,15 +721,15 @@ func (cm *containerManagerImpl) SystemCgroupsLimit() v1.ResourceList {
|
||||
}
|
||||
}
|
||||
|
||||
func buildContainerMapFromRuntime(runtimeService internalapi.RuntimeService) containermap.ContainerMap {
|
||||
func buildContainerMapFromRuntime(ctx context.Context, runtimeService internalapi.RuntimeService) containermap.ContainerMap {
|
||||
podSandboxMap := make(map[string]string)
|
||||
podSandboxList, _ := runtimeService.ListPodSandbox(nil)
|
||||
podSandboxList, _ := runtimeService.ListPodSandbox(ctx, nil)
|
||||
for _, p := range podSandboxList {
|
||||
podSandboxMap[p.Id] = p.Metadata.Uid
|
||||
}
|
||||
|
||||
containerMap := containermap.NewContainerMap()
|
||||
containerList, _ := runtimeService.ListContainers(nil)
|
||||
containerList, _ := runtimeService.ListContainers(ctx, nil)
|
||||
for _, c := range containerList {
|
||||
if _, exists := podSandboxMap[c.PodSandboxId]; !exists {
|
||||
klog.InfoS("no PodSandBox found for the container", "podSandboxId", c.PodSandboxId, "containerName", c.Metadata.Name, "containerId", c.Id)
|
||||
|
||||
Reference in New Issue
Block a user