Skip to content

BatchSandbox remains Failed after the same Pod recovers to Running and Ready #1497

Description

@jianpingpei

Summary

A BatchSandbox can remain permanently in Failed even when the same Pod later recovers to Running and Ready after a transient container-creation failure.

This leaves the control-plane state inconsistent with the actual Pod and causes clients that observed Failed to abandon an otherwise running sandbox.

Observed timeline

The following sequence was observed on a single-Pod BatchSandbox:

  1. The Pod was scheduled successfully; its sandbox, init container, image pull, and sidecar startup all succeeded.

  2. Creating the main container took longer than the runtime deadline and kubelet emitted:

    Create container agent error: context deadline exceeded
    
  3. A retry shortly afterward reported:

    container name ... already existed
    
  4. The BatchSandbox phase changed from Pending to Failed.

  5. About 85 seconds later, kubelet successfully created and started the same main container.

  6. The Pod became Running and Ready, but the BatchSandbox remained Failed indefinitely.

There was no rescheduling or replacement Pod involved.

Current behavior

applySteadyRuntimePhase returns immediately when the existing BatchSandbox phase is Failed:

if status.Phase == sandboxv1alpha1.BatchSandboxPhaseFailed {
    return
}

Therefore a later reconciliation cannot restore Succeed, even when all observed Pods are Running and Ready and no current failure remains.

Expected behavior

Transient container-creation failures should not leave a BatchSandbox permanently inconsistent with a recovered Pod.

Possible approaches:

  • avoid making the BatchSandbox terminal while the same Pod can still complete container creation; or
  • allow a narrowly scoped Failed -> Succeed reconciliation when the same Pod subsequently becomes Running and Ready and the recorded failure is no longer present.

The recovery rule should not hide genuine terminal failures or treat a replacement Pod as recovery without an explicit policy.

Suggested regression test

  1. Start with a Pending BatchSandbox and a Pod reporting a transient container creation failure.
  2. Reconcile it to Failed.
  3. Update the same Pod to Running, Ready, with the main container running and no active waiting/terminated failure.
  4. Reconcile again.
  5. Verify the BatchSandbox no longer remains stale in Failed (according to the chosen recovery semantics).

This is related to status convergence, but distinct from detecting a main-container restart after a sandbox was already Ready.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions