Skip to content

Commit 3a73d67

Browse files
authored
Add webhook readiness check to operator /readyz endpoint (#4778)
* Add webhook readiness check to operator /readyz endpoint Add a "webhook" readyz check using controller-runtime's StartedChecker() which verifies the webhook TLS listener is accepting connections. The check is only registered when webhooks are enabled, so webhooks-disabled deployments are unaffected. * update script in chainsaw test * use kubectl wait in tests
1 parent b22e994 commit 3a73d67

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: enhancement
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
5+
component: operator
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: Add webhook server readiness check to the operator's /readyz endpoint so the pod is not marked ready before the webhook server is listening.
9+
10+
# One or more tracking issues related to the change
11+
issues: [3772]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext: |
17+
Previously the readiness probe used only healthz.Ping, causing a race where CRs
18+
created right after deployment could hit "connection refused" from the webhook.
19+
Now the readyz endpoint includes a check using controller-runtime's
20+
StartedChecker which verifies the webhook TLS listener is actually accepting connections.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ add-rbac-permissions-to-operator: manifests kustomize
321321
.PHONY: deploy
322322
deploy: set-image-controller
323323
$(KUSTOMIZE) build config/default | kubectl apply -f -
324-
go run hack/check-operator-ready.go 300
324+
kubectl wait --for=condition=available deployment/opentelemetry-operator-controller-manager -n opentelemetry-operator-system --timeout=300s
325325

326326
# Undeploy controller in the current Kubernetes context, configured in ~/.kube/config
327327
.PHONY: undeploy

main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,12 @@ func main() {
529529
setupLog.Error(err, "unable to set up ready check")
530530
os.Exit(1)
531531
}
532+
if cfg.EnableWebhooks {
533+
if err := mgr.AddReadyzCheck("webhook", mgr.GetWebhookServer().StartedChecker()); err != nil {
534+
setupLog.Error(err, "unable to set up webhook ready check")
535+
os.Exit(1)
536+
}
537+
}
532538

533539
setupLog.Info("starting manager")
534540
// NOTE: We enable LeaderElectionReleaseOnCancel, and to be safe we need to exit right after the manager does

0 commit comments

Comments
 (0)