derailed/k9s · warning

expected %d but got %d

Error message

expected %d but got %d

What it means

PodDisruptionBudget.diagnose errors when spec.minAvailable (integer form) exceeds status.currentHealthy: the budget cannot be satisfied, voluntary disruptions are blocked, and the PDB row shows unhealthy.

Source

Thrown at internal/render/pdb.go:92

		numbToStr(pdb.Spec.MaxUnavailable),
		strconv.Itoa(int(pdb.Status.DisruptionsAllowed)),
		strconv.Itoa(int(pdb.Status.CurrentHealthy)),
		strconv.Itoa(int(pdb.Status.DesiredHealthy)),
		strconv.Itoa(int(pdb.Status.ExpectedPods)),
		mapToStr(pdb.Labels),
		AsStatus(p.diagnose(pdb.Spec.MinAvailable, pdb.Status.CurrentHealthy)),
		ToAge(pdb.GetCreationTimestamp()),
	}

	return nil
}

func (PodDisruptionBudget) diagnose(v *intstr.IntOrString, healthy int32) error {
	if v == nil {
		return nil
	}
	if v.IntVal > healthy {
		return fmt.Errorf("expected %d but got %d", v.IntVal, healthy)
	}

	return nil
}

// Helpers...

func numbToStr(n *intstr.IntOrString) string {
	if n == nil {
		return NAValue
	}
	if n.Type == intstr.Int {
		return strconv.Itoa(int(n.IntVal))
	}
	return n.StrVal
}

View on GitHub (pinned to 2d3ccc6ba2)

Solutions

  1. Scale healthy pods up to at least minAvailable: kubectl scale deploy/<owner> --replicas=N
  2. Or lower minAvailable (use a percentage like 50% for flexibility)
  3. Fix unhealthy pods first — currentHealthy counts ready pods only
  4. During planned drains, temporarily relax the PDB rather than forcing deletion

Example fix

# before: workload scaled to 2, budget still demands 3
spec:
  minAvailable: 3
# after
spec:
  minAvailable: 50%
Defensive patterns

Strategy: fallback

Validate before calling

if pdb.Spec.MinAvailable != nil && pdb.Spec.MinAvailable.Type == intstr.Int {
	if int32(pdb.Spec.MinAvailable.IntVal) > pdb.Status.CurrentHealthy {
		// disruptions blocked; scale up or lower budget
	}
}

Prevention

When it happens

Trigger: minAvailable: 3 with only 2 healthy replicas; scale-down of the protected workload below the budget; pods crashing so currentHealthy drops under a previously fine minAvailable.

Common situations: Autoscaling minReplicas below PDB minAvailable (deadlock on evictions); node drains hanging during upgrades; replicas set smaller after cost cuts without adjusting the PDB.

Related errors


AI-assisted analysis of derailed/k9s@2d3ccc6ba2 (2026-08-15). Data as JSON: /api/errors/e79854795712592c. Report an issue: GitHub.