Skip to content

[BUG] AutoPause can pause from stale probe results after a same-name probe update #956

Description

@AiRanthem

What happened:

On a Running Sandbox with the AutoPauseController feature gate enabled, updating an existing named exec probe can leave the controller evaluating the old Pod condition in the same reconcile. EnsureProbe patches the Pod's kruise.io/podprobe annotation for the new spec.probes value, but then immediately mirrors the already-read Pod.Status.Conditions into Sandbox.Status.Conditions. Conditions are selected by probe name, with no configuration generation/version check.

If the old Active probe had reported True with message idle, and the probe is updated in the same spec patch to run printf active, an accompanying policy with probe: Active, messageRegex: ^idle$, and thresholdDuration: 0 can make the same reconcile call handleAutoPause with the stale idle result. The Sandbox can therefore be paused before the new probe configuration has produced a result.

This is a static code-path counterexample from the baseline source; it has not been reproduced on a live cluster.

What you expected to happen:

After a named probe's configuration changes, AutoPause should wait for a result produced by the new configuration. It should not treat a condition produced by the previous command as evidence that the updated probe is idle. With thresholdDuration: 0, pausing should be immediate only after the new probe reports a matching idle result.

How to reproduce it (as minimally and precisely as possible):

  1. Use a Running, claimed Sandbox with the AutoPauseController feature gate enabled. Start with an Active exec probe whose command is equivalent to printf idle, and with no pause policy so the old result cannot pause the Sandbox before the update.

  2. Wait until the Pod condition for agents.kruise.io/Active is True with message idle.

  3. Apply one Sandbox.spec update that both replaces the same-named probe command with printf active and sets this pause policy:

    probes:
    - name: Active
      exec:
        command: ["sh", "-c", "printf active"]
    autoPausePolicy:
      pause:
        whenProbedIdleState:
          probe: Active
          messageRegex: '^idle$'
          thresholdDuration: 0s
  4. On the first reconcile after this update, before the runtime has emitted the new probe result, the baseline path is:

    • EnsureProbe patches the Pod annotation, then calls syncConditions on the old in-memory Pod object and finds the old Active=True/idle condition;
    • handleAutoPause evaluates that mirrored condition; calculatePauseTime adds zero to its old LastTransitionTime and considers the pause due;
    • tryPause patches spec.paused=true.

    Relevant baseline source at commit cb37dce59730f1bf6a9a34fafa3e07c27b906e09: EnsureProbe, syncConditions, handleAutoPause, calculatePauseTime, and tryPause.

Anything else we need to know?:

  • This affects the auto-pause behavior introduced by commit 7a16b1562b9eb72681e67099ffa454e475361b05 (Sandbox Auto-Pause and Resume, Sandbox Auto-Pause and Resume #612). The affected runtime files are unchanged from the baseline commit above; this report is independent of the current SandboxClaim auto-pause-policy change.
  • Related context: found while reviewing #955; the affected code path is already present at the baseline commit above.
  • The example uses a legal zero threshold. Repository validation explicitly treats zero as “pause as soon as the probe reports idle”; negative thresholds are rejected.
  • No Kubernetes version, installation details, or live-cluster observation are available for this report.

Environment:

  • OpenKruiseAgent version: Repository source at commit cb37dce59730f1bf6a9a34fafa3e07c27b906e09 (baseline)
  • Kubernetes version (use kubectl version): Not reproduced on a live cluster
  • Install details (e.g. helm install args): Not available
  • Others: Static source analysis; AutoPauseController feature gate enabled in the reproduction scenario

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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