美文网首页
failed to build map of initial c

failed to build map of initial c

作者: wwq2020 | 来源:发表于2023-09-23 09:28 被阅读0次

背景

早期使用的k8s版本为1.23.7,其中有一个bug,当开启cpumanager或者memory manager时,且kubelet管理的pod的container(即使是非运行状态)查不到关联的sandbox时,会导致kubelet启动失败

解决

永久方案

升级版本到1.23.17或者更新

临时解决

docker system prune
systemctl restart kubelet

··

相关代码

func buildContainerMapFromRuntime(runtimeService internalapi.RuntimeService) (containermap.ContainerMap, error) {
    podSandboxMap := make(map[string]string)
    podSandboxList, _ := runtimeService.ListPodSandbox(nil)
    for _, p := range podSandboxList {
        podSandboxMap[p.Id] = p.Metadata.Uid
    }

    containerMap := containermap.NewContainerMap()
    containerList, _ := runtimeService.ListContainers(nil)
    for _, c := range containerList {
        if _, exists := podSandboxMap[c.PodSandboxId]; !exists {
            return nil, fmt.Errorf("no PodsandBox found with Id '%s'", c.PodSandboxId)
        }
        containerMap.Add(podSandboxMap[c.PodSandboxId], c.Metadata.Name, c.Id)
    }

    return containerMap, nil
}

相关文章

网友评论

      本文标题:failed to build map of initial c

      本文链接:https://www.haomeiwen.com/subject/fadtbdtx.html