k8s deployer: WaitForDeploymentAvailable errors on a 0-replica Deployment (keda scale-to-zero redeploy)
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 72/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- go, kubernetes
- Área
- infrastructure
Línea de trabajo
Start by reading WaitForDeploymentAvailable and checkIfDeploymentIsAvailable in pkg/k8s/wait.go, then compare how deployments are applied in pkg/k8s/deployer.go. Add coverage for the zero-replica case and verify the existing wait behavior remains intact; a KEDA-backed redeploy can provide the integration repro if needed.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
WaitForDeploymentAvailable (pkg/k8s/wait.go) can fail a redeploy with
could not find current pod-template-hash for deployment <name> when the live
Deployment has 0 desired replicas. This is reachable today via the keda
(HTTP-scaler) deployer, whose ScaledObject scales idle functions down to zero.
Note: this is reasoned from the code, not yet reproduced (it's a timing race).
Filing so the analysis is tracked; repro TBD.
Details
WaitForDeploymentAvailable re-fetches the live Deployment on every poll tick:
deployment, err := clientset.AppsV1().Deployments(namespace).Get(ctx, deploymentName, metav1.GetOptions{})
...
return checkIfDeploymentIsAvailable(ctx, clientset, deployment)
checkIfDeploymentIsAvailable finds the active ReplicaSet by looking for one with
*rs.Spec.Replicas > 0. A Deployment sitting at 0 desired replicas has no such
ReplicaSet, so currentPodTemplateHash stays empty and the function returns an error
(pkg/k8s/wait.go):
if currentPodTemplateHash == "" {
return false, fmt.Errorf("could not find current pod-template-hash for deployment %s", deployment.Name)
}
The func deployer itself always applies replicas >= 1 (pkg/k8s/deployer.go), so
it never creates a 0-replica Deployment. But because the wait inspects live state,
reachability is governed by what KEDA does during the wait, not by what func wrote:
- An idle keda-HTTP function has been scaled to 0 replicas by KEDA.
- User redeploys. func applies the Deployment with
replicas: 1, then starts polling. - If the KEDA controller reasserts 0 replicas on the live Deployment before the poll
observes it as ready, the live fetch returnsspec.replicas == 0, and the wait
returns the pod-template-hash error — failing the redeploy.
Suggested fix
Short-circuit when there is nothing to wait for:
desiredReplicas := *deployment.Spec.Replicas
if desiredReplicas == 0 {
return true, nil // no replicas desired; nothing to wait for
}
This also unblocks any future spec-level scale-to-zero on the raw/keda Deployment.
Notes
- Reasoned from code; not reproduced. A repro needs a cluster with KEDA and an idle,
scaled-to-zero HTTP function being redeployed. - Fix is small and self-contained but likely wants a repro or unit test first, hence
filing as an issue rather than an immediate PR.
- Lenguaje dominante
- Go
- Estrellas
- 366
- Forks
- 226
- Merge medio
- 2 d 17 h
- PR fusionados (30 d)
- 21
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de knative/func
-
Kafka sidecar: add a startupProbe so slow-starting functions aren't restart-loopedPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertokind/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
KEDA deployer: default minReplicaCount prevents scale-to-zeroPosiblemente ocupada @Tushar-Khandelwal-2004 la tomó hace 113 días. Abiertolifecycle/stale
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
knative/func#3924 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
git/gitlab: default project webhooks to SSL verification when creating hooksPosiblemente ocupada @Vi-shub la tomó hace 160 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
mcp: config add/remove handlers bypass readonly guardPosiblemente ocupada @Elvand-Lie la tomó hace 162 días. Abiertokind/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
knative/func#3704 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
kind/cleanup
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
Los mantenedores suelen responder en 1 día
Todos los issues de knative/func
Issues similares
-
Mend: dependency security vulnerability
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
kube-tarian/sigrun#202 ·
-
question raised-by:verifier
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
medici-finance/assay#4013 ·
Los mantenedores suelen responder en 1 día
-
TestRegistry_ConcurrentMixedOperations fetches from the network and can hang the short suiteAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
tsukumogami/tsuku#2775 ·
Los mantenedores suelen responder en 1 día
-
automation models
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 69/100
Los mantenedores suelen responder en 1 día