{"record":{"id":"14225f30c1ede3af","repo":"kubernetes/kubernetes","slug":"invalid-value-for-maxunavailable-v","errorCode":null,"errorMessage":"invalid value for MaxUnavailable: %v","messagePattern":"invalid value for MaxUnavailable: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/controller/daemon/update.go","lineNumber":609,"sourceCode":"\tlogger := klog.FromContext(ctx)\n\ttolerations := daemonPodTolerations(ds)\n\trequiredNodeAffinity := nodeaffinity.NewRequiredNodeAffinity(ds.Spec.Template.Spec.NodeSelector, ds.Spec.Template.Spec.Affinity)\n\tfor i := range nodeList {\n\t\tnode := nodeList[i]\n\t\twantToRun, _ := nodeShouldRunDaemonPod(logger, node, ds, tolerations, requiredNodeAffinity)\n\t\tif !wantToRun {\n\t\t\tcontinue\n\t\t}\n\t\tdesiredNumberScheduled++\n\n\t\tif _, exists := nodeToDaemonPods[node.Name]; !exists {\n\t\t\tnodeToDaemonPods[node.Name] = nil\n\t\t}\n\t}\n\n\tmaxUnavailable, err := util.UnavailableCount(ds, desiredNumberScheduled)\n\tif err != nil {\n\t\treturn -1, -1, -1, fmt.Errorf(\"invalid value for MaxUnavailable: %v\", err)\n\t}\n\n\tmaxSurge, err := util.SurgeCount(ds, desiredNumberScheduled)\n\tif err != nil {\n\t\treturn -1, -1, -1, fmt.Errorf(\"invalid value for MaxSurge: %v\", err)\n\t}\n\n\t// if the daemonset returned with an impossible configuration, obey the default of unavailable=1 (in the\n\t// event the apiserver returns 0 for both surge and unavailability)\n\tif desiredNumberScheduled > 0 && maxUnavailable == 0 && maxSurge == 0 {\n\t\tlogger.Info(\"DaemonSet is not configured for surge or unavailability, defaulting to accepting unavailability\", \"daemonset\", klog.KObj(ds))\n\t\tmaxUnavailable = 1\n\t}\n\tlogger.V(5).Info(\"DaemonSet with maxSurge and maxUnavailable\", \"daemonset\", klog.KObj(ds), \"maxSurge\", maxSurge, \"maxUnavailable\", maxUnavailable)\n\treturn maxSurge, maxUnavailable, desiredNumberScheduled, nil\n}\n\ntype historiesByRevision []*apps.ControllerRevision","sourceCodeStart":591,"sourceCodeEnd":627,"githubUrl":"https://github.com/kubernetes/kubernetes/blob/b882c60b4023bdf09264c2d5d30a2cadebc240fb/pkg/controller/daemon/update.go#L591-L627","documentation":"Wraps a failure from util.UnavailableCount (daemonset_util.go:153) during updatedDesiredNodeCounts (update.go:609). UnavailableCount only errors when GetScaledValueFromIntOrPercent cannot parse the RollingUpdate.MaxUnavailable IntOrString (e.g. a malformed percentage string, empty, or a value that overflows when scaled). For a RollingUpdate DaemonSet this blocks rollout math, so the whole reconcile for that DS fails and requeues.","triggerScenarios":"DS has spec.updateStrategy.type=RollingUpdate but rollingUpdate.maxUnavailable is set to an unparseable value (e.g. \"-1%\", \"abc\", \"\") or an intstr that GetScaledValueFromIntOrPercent rejects for the given desiredNumberScheduled.","commonSituations":"Hand-edited YAML with a typo in maxUnavailable; a templating/Helm rendering bug emitting an empty field; API version mismatch where the field shape changed.","solutions":["Inspect the DS: kubectl get ds <name> -o yaml and check spec.updateStrategy.rollingUpdate.maxUnavailable.","Set maxUnavailable to a valid int (e.g. 1) or percent string (e.g. \"25%\") and kubectl apply.","If generated by Helm/kustomize, fix the template so the field renders a concrete intstr value."],"exampleFix":"// before\nspec:\n  updateStrategy:\n    type: RollingUpdate\n    rollingUpdate:\n      maxUnavailable: \"\"   # unparseable -> error\n// after\nspec:\n  updateStrategy:\n    type: RollingUpdate\n    rollingUpdate:\n      maxUnavailable: 1","handlingStrategy":"validation","validationCode":"// Validate maxUnavailable before relying on it.\nfunc validMaxUnavailable(v *intstr.IntOrString) bool {\n    if v == nil { return true }\n    _, err := intstrutil.GetScaledValueFromIntOrPercent(v, 1, true)\n    return err == nil\n}","typeGuard":null,"tryCatchPattern":"if _, _, _, err := dsc.updatedDesiredNodeCounts(ctx, ds, nodes, nodeToPods); err != nil {\n    if strings.Contains(err.Error(), \"invalid value for MaxUnavailable\") {\n        // Bad user input; surface as a Deployment/DaemonSet event, do not hot-loop.\n        dsc.eventRecorder.Eventf(ds, v1.EventTypeWarning, \"InvalidMaxUnavailable\", err.Error())\n        return reconcile.Result{RequeueAfter: 30 * time.Second}, nil\n    }\n    return reconcile.Result{}, err\n}","preventionTips":["Run kubectl apply --dry-run=server to let admission validate intstr fields.","Render manifests through templates and assert maxUnavailable is a concrete int/percent in CI.","Default maxUnavailable explicitly rather than relying on an empty/ambiguous value."],"tags":["daemonset","rolling-update","max-unavailable","validation","intstr"],"analyzedSha":"b882c60b4023bdf09264c2d5d30a2cadebc240fb","analyzedAt":"2026-08-07T04:07:48.144Z","schemaVersion":2},"datasetVersion":"2026-08-07T07:17:06.508Z"}