{"record":{"id":"84a0883bd36864ce","repo":"kubernetes/kubernetes","slug":"unexpected-deployment-strategy-type-s","errorCode":null,"errorMessage":"unexpected deployment strategy type: %s","messagePattern":"unexpected deployment strategy type: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/controller/deployment/deployment_controller.go","lineNumber":659,"sourceCode":"\t\treturn err\n\t}\n\tif scalingEvent {\n\t\treturn dc.sync(ctx, d, rsList)\n\t}\n\n\tswitch d.Spec.Strategy.Type {\n\tcase apps.RecreateDeploymentStrategyType:\n\t\t// List all Pods owned by this Deployment, grouped by their ReplicaSet, to\n\t\t// check that no old Pods are running in the middle of a Recreate rollout.\n\t\tpodMap, err := dc.getPodMapForDeployment(d, rsList)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn dc.rolloutRecreate(ctx, d, rsList, podMap)\n\tcase apps.RollingUpdateDeploymentStrategyType:\n\t\treturn dc.rolloutRolling(ctx, d, rsList)\n\t}\n\treturn fmt.Errorf(\"unexpected deployment strategy type: %s\", d.Spec.Strategy.Type)\n}\n","sourceCodeStart":641,"sourceCodeEnd":661,"githubUrl":"https://github.com/kubernetes/kubernetes/blob/b882c60b4023bdf09264c2d5d30a2cadebc240fb/pkg/controller/deployment/deployment_controller.go#L641-L661","documentation":"From syncDeployment (deployment_controller.go:659). After handling Recreate and RollingUpdate, the switch on spec.strategy.type falls through to the default, meaning the type is neither of the two supported values. The API server should reject any other type at admission, so reaching this line implies a corrupt, hand-crafted, or bypass-admission Deployment object.","triggerScenarios":"A Deployment whose spec.strategy.type is something other than Recreate/RollingUpdate (e.g. empty string, a typo, or a custom value). Possible if the object was written directly to etcd or by a buggy controller that set an invalid enum.","commonSituations":"Direct etcd writes; a CR/operator that constructed a Deployment struct with an unset/typo strategy type; version skew where a new strategy type was read by an older controller that doesn't know it.","solutions":["kubectl get deploy <ns>/<name> -o yaml and check spec.strategy.type.","Set it to RollingUpdate (default) or Recreate and re-apply.","Ensure all writes go through the API server so the strategy enum is validated at admission."],"exampleFix":"// before\nspec:\n  strategy:\n    type: \"Rolling\"   # typo, not a valid value\n// after\nspec:\n  strategy:\n    type: RollingUpdate","handlingStrategy":"validation","validationCode":"func validStrategyType(t apps.DeploymentStrategyType) bool {\n    return t == apps.RecreateDeploymentStrategyType || t == apps.RollingUpdateDeploymentStrategyType\n}","typeGuard":null,"tryCatchPattern":"switch d.Spec.Strategy.Type {\ncase apps.RecreateDeploymentStrategyType, apps.RollingUpdateDeploymentStrategyType:\n    // handle\ndefault:\n    dc.eventRecorder.Eventf(d, v1.EventTypeWarning, \"InvalidStrategy\", string(d.Spec.Strategy.Type))\n    return reconcile.Result{RequeueAfter: 30 * time.Second}, nil\n}","preventionTips":["Rely on API admission to enforce the strategy-type enum; never write Deployments directly to etcd.","If forking to add a strategy type, update both syncDeployment and NewRSNewReplicas."],"tags":["deployment","strategy","validation","rollout"],"analyzedSha":"b882c60b4023bdf09264c2d5d30a2cadebc240fb","analyzedAt":"2026-08-07T04:07:48.144Z","schemaVersion":2},"datasetVersion":"2026-08-07T07:17:06.508Z"}