Repository navigation
feat(operator): expose health and readiness probes - #116
Merged
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove test-name filtering so newly added tagged tests run automatically. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove ZooKeeper outage mocks and scaling fixtures; retain real cache startup, zero-ensemble readiness, and draining shutdown regressions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Derive controller watches and eager informer setup from the same primary and owned resource declarations. Keep health checks free of resource-type knowledge. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change log description
--health-probe-bind-address(default:8081), without changing metrics binding.Purpose of the change
Implements PR-12 under #101. This does not close the broader workstream or implement its deferred items.
What the code does
Uses the existing manager health listener and health-check registration APIs.
/healthzis a process-liveness ping and does not depend on ZooKeeper availability.SetupWithManagerdeclares the primary resource and owned resources once, then uses those same objects for both watch registration and eager informer initialization. There is no separate resource list inmain.goto keep synchronized: adding an owned resource to the controller's declaration configures both behaviors. Controller-runtime otherwise registers those sources lazily, allowing its initial cache-sync phase to finish with an empty cache./readyzbecomes successful only after the actual watched caches initialize and fails when shutdown begins, including while controller work drains. Health-check setup itself contains no resource-type knowledge.Initialized standby managers may be ready without holding the leader lease. Requiring leadership would block the default single-replica rolling update from replacing its old leader. Neither endpoint claims that managed ensembles are ready.
Both deployment paths expose named container port
health:8081, with/healthzevery 10 seconds and/readyzevery 5 seconds, each with failure threshold 3. Metrics configuration and ZooKeeper ensemble status semantics are unchanged.The existing rendered-contract suite covers Helm, default Kustomize, and the inheriting e2e overlay. The new in-process manager test uses Kubernetes 1.34.1 envtest with no ensembles: it blocks the real initial informer request, verifies readiness after the empty caches synchronize, and holds shutdown open while checking HTTP responses. There is no ZooKeeper failure mock, scaling scenario, or cluster/StatefulSet fixture. The existing
make test-envtesttarget now includes the root package and selects opt-in files through theenvtestbuild tag, without a test-name filter, so CI and releases exercise new tagged tests regardless of their names. Ordinary tests in those packages also run because Go build tags are additive.How to verify it
Passed locally on this branch:
make check— passed formatting and license checks.make test— passed the full ordinary Go suite with race detection; rerun immediately before publication.go test -tags=envtest . ./controllers -count=1 -race -v— passed with existing Kubernetes 1.34.1 assets selected throughKUBEBUILDER_ASSETS.go test -tags=manifests ./test/manifests -race -count=1— passed all rendered contracts.helm lint --strict charts/zookeeper-operator— passed.golangci-lint run --new-from-rev=4b580e5daecb97df1b153e2fd8a98f7ad187cc8c ./...— passed, zero new issues.golangci-lint run --build-tags=envtest,manifests --new-from-rev=4b580e5daecb97df1b153e2fd8a98f7ad187cc8c . ./controllers ./test/manifests— passed, zero new issues.go vet ./...— passed.python3 -B -m unittest discover -s scripts -p 'test_*.py'— passed, 35 tests.git diff --check— passed.Actual Kubernetes validation used a disposable kind v1.34.3 cluster with the repository-pinned node image:
The final source-built linux/arm64 operator image, including the colocated watch/informer setup, passed startup and
kubectl rollout restartfor both Helm and the Kustomize/e2e-base deployment.kubectl rollout status deployment/zookeeper-operator --timeout=90spassed in both test namespaces. Both operator Pods were 1/1 Ready with zero restarts. Real Pod-proxy requests to/healthzand/readyzreturnedokwith zero ZooKeeperCluster objects in the cluster. The test cluster and task-specific image tag were removed afterward.Not run: the full ZooKeeper ensemble e2e suite or independent code review. The
make test-envtestinstallation wrapper was not rerun; its updated Go test selection was run directly with cached 1.34.1 assets and additional race detection. No dependencies were added.