add liveness and readiness probe#565
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #565 +/- ##
==========================================
+ Coverage 27.63% 27.79% +0.15%
==========================================
Files 24 26 +2
Lines 3351 3404 +53
==========================================
+ Hits 926 946 +20
- Misses 2327 2359 +32
- Partials 98 99 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
|
||
| // CNI makes rpc calls to NP agent regardless NP is enabled or not | ||
| // need to start rpc always | ||
| // todo: add a liveness probe to this gRPC server and remove closing based on this errCh, liveness probe will check and re-start this container |
There was a problem hiding this comment.
can we simplify the closing based on errCh happen currently? since we are adding liveness and readiness probes
we don't need closing based on errCh now as liveness probe will re-start the container in case RPC handler is not running
There was a problem hiding this comment.
right now keeping it as it is. Once We update the manifest of node agent with liveness probe i will remove it.
There was a problem hiding this comment.
Pull request overview
This PR adds Kubernetes-style liveness/readiness probe support to the network policy agent by wiring controller-runtime health checks that validate the agent’s gRPC Unix socket (and, when network policy is enabled, key eBPF prerequisites).
Changes:
- Add a gRPC Unix-socket health check that performs a gRPC Health/Check RPC against the agent.
- Add readiness checks for bpffs correctness (mounted + writable) and presence of required pinned BPF maps.
- Register the new checks with the controller manager and add unit tests for the eBPF readiness checks.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| pkg/rpc/healthcheck.go | Implements gRPC-socket health check used by healthz/readyz. |
| pkg/ebpf/healthcheck.go | Adds bpffs + global map readiness checks. |
| pkg/ebpf/healthcheck_test.go | Adds unit tests for the new eBPF readiness checks. |
| main.go | Registers new healthz/readyz checks with controller-runtime manager. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const livenessCheckTimeout = 10 * time.Second | ||
|
|
||
| // NewGRPCSocketLivenessCheck returns a health check that issues a gRPC | ||
| // Health/Check RPC against the NPA Unix socket at socketPath. | ||
| func NewGRPCSocketLivenessCheck(socketPath string) func(_ *http.Request) error { | ||
| return func(_ *http.Request) error { | ||
| ctx, cancel := context.WithTimeout(context.Background(), livenessCheckTimeout) | ||
| defer cancel() |
| if err := mgr.AddReadyzCheck("grpc-socket", rpc.NewGRPCSocketLivenessCheck(npaSocketPath)); err != nil { | ||
| log.Errorf("unable to set up grpc-socket readiness check %v", err) |
| // NewGRPCSocketLivenessCheck returns a health check that issues a gRPC | ||
| // Health/Check RPC against the NPA Unix socket at socketPath. | ||
| func NewGRPCSocketLivenessCheck(socketPath string) func(_ *http.Request) error { | ||
| return func(_ *http.Request) error { | ||
| ctx, cancel := context.WithTimeout(context.Background(), livenessCheckTimeout) | ||
| defer cancel() |
Issue #, if available:
Description of changes:
Testing,
Tested readiness probe by removing grpc socket. Sample logs when socket is removed.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.