k8s deployer: WaitForDeploymentAvailable errors on a 0-replica Deployment (keda scale-to-zero redeploy)
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 72/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- go, kubernetes
- Lĩnh vực
- infrastructure
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Go
- Star
- 365
- Fork
- 224
- Merge trung bình
- 1 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 17
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của knative/func
-
KEDA deployer: default minReplicaCount prevents scale-to-zeroCó thể đã có người làm @Tushar-Khandelwal-2004 đã nhận 112 ngày trước. Đang mởlifecycle/stale
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
knative/func#3924 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
git/gitlab: default project webhooks to SSL verification when creating hooksCó thể đã có người làm @Vi-shub đã nhận 159 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 2 ngày
-
mcp: config add/remove handlers bypass readonly guardCó thể đã có người làm @Elvand-Lie đã nhận 161 ngày trước. Đang mởkind/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
knative/func#3704 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
operator sync creates registry auth Secret as Opaque/config.json, incompatible with func-operator (expects dockerconfigjson)Có thể đã có người làm @gauron99 đã nhận 6 ngày trước. Đang mở
knative/func#4081 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
func.yaml schema generator truncates fractional `minimum` values (e.g. 0.01 -> 0)Có thể đã có người làm @Elvand-Lie đã nhận 24 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
Maintainer thường phản hồi trong vòng 2 ngày
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Rafaeldelinares/gentle-mesh#125 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Gentleman-Programming/gentle-ai#5643 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
FootprintAI/Containarium#2869 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
kind/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
kubevirt/kubevirt#19559 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug raised-by:verifier
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
medici-finance/assay#3817 ·
Maintainer thường phản hồi trong vòng 1 ngày