slimtoolkit/slim · error
unexpected - more than one target pod found
Error message
unexpected - more than one target pod found
What it means
The pod inspector resolves a single target pod by polling until exactly one pod matches the selector. If the poll finds more than one matching pod, it aborts with this error rather than guessing which pod is the target. It is a guard against ambiguous pod selection.
Source
Thrown at pkg/app/master/inspectors/pod/pod_inspector.go:731
Static().
CoreV1().
Pods(namespace).
List(context.TODO(), metav1.ListOptions{
LabelSelector: targetPodLabelName + "=" + targetPodLabelValue,
})
if err != nil {
return false, err
}
if len(pods.Items) == 0 {
return false, nil // Keep waiting
}
if len(pods.Items) == 1 {
pod = pods.Items[0]
return true, nil // Done
}
return false, errors.New("unexpected - more than one target pod found")
})
return pod, err
}
func waitForContainer(
ctx context.Context,
client *kubernetes.Client,
namespace string,
podName string,
contName string,
isInit bool,
) error {
return wait.PollImmediateWithContext(ctx, 1*time.Second, 5*time.Minute, func(ctx context.Context) (bool, error) {
pod, err := client.Static().CoreV1().Pods(namespace).Get(ctx, podName, metav1.GetOptions{})
if err != nil {
return false, err
}View on GitHub (pinned to 81940d17fa)
Solutions
- Ensure the target workload runs a single replica (scale down others) while inspecting
- Narrow the pod selector/labels so only one pod matches
- Delete stale/terminating pods from prior runs that still match the selector
Example fix
// before deploy.spec.replicas = 3 // after deploy.spec.replicas = 1 // keep one target pod during inspection
Defensive patterns
Strategy: validation
Validate before calling
// before waiting for the pod
pods, _ := clientset.CoreV1().Pods(ns).List(ctx, metav1.ListOptions{LabelSelector: sel})
if len(pods.Items) != 1 { return fmt.Errorf("selector %q matches %d pods, need exactly 1", sel, len(pods.Items)) } Try / catch
if err := runInspection(); err != nil {
if strings.Contains(err.Error(), "more than one target pod") {
// list matching pods, scale to 1 or refine selector, then retry
}
} Prevention
- Run inspections against single-replica workloads
- Use unique labels per inspected instance
- Clean up stale pods from previous runs
When it happens
Trigger: Calling an inspector flow that waits for a target pod (via waitForPod) when the pod selector/label query matches 2+ pods in the namespace at the same time.
Common situations: ReplicaSets/Deployments with more than one replica behind the inspected workload; leftover pods from a previous run still matching the same labels; two containers/rollouts overlapping during a rolling update.
Related errors
- Pod terminated
- Pod not running
- start monitor timeout
- couldn't unambiguously identify workload in cluster
- no pods
AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31).
Data as JSON: /api/errors/657d7a1dbe173f6b.
Report an issue: GitHub.