Skip to content

Bug: BatchSandbox does not rebind a new Pod from Pool after allocated Pod is deleted #954

@longsuizhi

Description

@longsuizhi

问题描述

在 Pool 模式下,当一个已分配给 BatchSandbox 的 Pod 被外部删除(如手动 delete、节点驱逐等)后,BatchSandbox 不会从 Pool 中重新获取一个新的 Pod 来替代,导致 sandbox 永久处于不可用状态。

复现步骤

  1. 创建一个 Pool 和 BatchSandbox(使用 poolRef 引用该 Pool,replicas: 1)
  2. 等待 Pod 分配成功(alloc-status 注解中记录了分配的 Pod 名称)
  3. 手动删除该 Pod
  4. 观察 BatchSandbox 状态:allocated: 0, replicas: 0,且不会恢复

根因分析

allocator.go 中的 getSandboxRequest 函数通过 alloc-status 注解获取已分配的 Pod 列表,然后计算:

supplement = replicas - len(allocated)

Pod 被删除后注解中仍保留该 Pod 名称,导致 len(allocated) 不变,supplement 始终为 0,Pool 调度器不会分配新 Pod。

源码中已有 TODO 注释确认此功能缺失:

// TODO consider supply Pods if Pods is deleted unexpectedly

期望行为

当已分配的 Pod 不再存在时,allocator 应检测到该 Pod 已不在 Pool 的活跃 Pod 列表中,将其从有效分配中排除,从而使 supplement > 0,触发 Pool 重新分配新 Pod 给 BatchSandbox。

影响范围

  • 所有使用 Pool 模式的 BatchSandbox
  • 当 Pod 因任何原因(手动删除、节点驱逐、OOM Kill 等)消失时均会触发此问题

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions