{"record":{"id":"e79854795712592c","repo":"derailed/k9s","slug":"expected-d-but-got-d","errorCode":null,"errorMessage":"expected %d but got %d","messagePattern":"expected (.+?) but got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/render/pdb.go","lineNumber":92,"sourceCode":"\t\tnumbToStr(pdb.Spec.MaxUnavailable),\n\t\tstrconv.Itoa(int(pdb.Status.DisruptionsAllowed)),\n\t\tstrconv.Itoa(int(pdb.Status.CurrentHealthy)),\n\t\tstrconv.Itoa(int(pdb.Status.DesiredHealthy)),\n\t\tstrconv.Itoa(int(pdb.Status.ExpectedPods)),\n\t\tmapToStr(pdb.Labels),\n\t\tAsStatus(p.diagnose(pdb.Spec.MinAvailable, pdb.Status.CurrentHealthy)),\n\t\tToAge(pdb.GetCreationTimestamp()),\n\t}\n\n\treturn nil\n}\n\nfunc (PodDisruptionBudget) diagnose(v *intstr.IntOrString, healthy int32) error {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.IntVal > healthy {\n\t\treturn fmt.Errorf(\"expected %d but got %d\", v.IntVal, healthy)\n\t}\n\n\treturn nil\n}\n\n// Helpers...\n\nfunc numbToStr(n *intstr.IntOrString) string {\n\tif n == nil {\n\t\treturn NAValue\n\t}\n\tif n.Type == intstr.Int {\n\t\treturn strconv.Itoa(int(n.IntVal))\n\t}\n\treturn n.StrVal\n}\n","sourceCodeStart":74,"sourceCodeEnd":109,"githubUrl":"https://github.com/derailed/k9s/blob/2d3ccc6ba2ce98c3781bfc441bb3e884f072774f/internal/render/pdb.go#L74-L109","documentation":"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.","triggerScenarios":"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.","commonSituations":"Autoscaling minReplicas below PDB minAvailable (deadlock on evictions); node drains hanging during upgrades; replicas set smaller after cost cuts without adjusting the PDB.","solutions":["Scale healthy pods up to at least minAvailable: kubectl scale deploy/<owner> --replicas=N","Or lower minAvailable (use a percentage like 50% for flexibility)","Fix unhealthy pods first — currentHealthy counts ready pods only","During planned drains, temporarily relax the PDB rather than forcing deletion"],"exampleFix":"# before: workload scaled to 2, budget still demands 3\nspec:\n  minAvailable: 3\n# after\nspec:\n  minAvailable: 50%","handlingStrategy":"fallback","validationCode":"if pdb.Spec.MinAvailable != nil && pdb.Spec.MinAvailable.Type == intstr.Int {\n\tif int32(pdb.Spec.MinAvailable.IntVal) > pdb.Status.CurrentHealthy {\n\t\t// disruptions blocked; scale up or lower budget\n\t}\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use percentage minAvailable for autoscaled workloads","Keep minAvailable <= minReplicas of the protected workload","Check PDB health before node drains and planned maintenance"],"tags":["pdb","disruption-budget","health","kubernetes"],"backgroundTag":null,"analyzedSha":"2d3ccc6ba2ce98c3781bfc441bb3e884f072774f","analyzedAt":"2026-08-15T16:09:14.432Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}