Skip to content

feat(container-hook): restart on a lost or stuck gatekeeper; ship the gatekeeper - #1222

Open
matthyx wants to merge 3 commits into
mainfrom
feat/healthmanager-liveness-checks
Open

matthyx wants to merge 3 commits into
mainfrom
feat/healthmanager-liveness-checks

Conversation

@matthyx

@matthyx matthyx commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Picks up kubescape/inspektor-gadget#41 (merged as c23a76d66): the container hook now answers runc's fanotify permission events from a separate gatekeeper process with a deadline, so a stalled node-agent can no longer freeze runc on the node.

  • Pluggable liveness checks: HealthManager.AddLivenessCheck(name, check). /livez returns 503 with the joined errors while a check fails.
  • Container-hook check: cmd/main.go registers containerhook.Health. It fails when the gatekeeper was lost, or when a watcher has spent more than 30s on one event while another waits for it. In both cases the node keeps working, but containers are no longer detected until node-agent restarts. Running without a gatekeeper does not fail it, since a restart doesn't change that.
  • Gatekeeper binary: the release and debug images ship /usr/bin/ig-container-hook-gatekeeper, built from the same IG module version as node-agent (like fence-provision). The hook tries it first; without it, it re-executes node-agent as the gatekeeper (~18 MB more, charged to node-agent's cgroup).
  • IG pin: bumped to the merge of fix(container-hook): end a gatekeeper stall only on a reply in time inspektor-gadget#65 (0920c07e0), which includes validate we have the resource version before update filtered SBOM #41 and ends a gatekeeper stall only on a reply within its event's deadline. The other replace directives already match the fork's go.mod.

Overview

Docs: docs/features/liveness-checks.md, build/README.md, and the fork's docs/devel/container-hook-gatekeeper.md for the design.

How to Test

  • go test ./pkg/healthmanager/ (new TestLivenessProbe_Checks).
  • go build ./cmd and go build github.com/inspektor-gadget/inspektor-gadget/cmd/container-hook-gatekeeper pass.
  • The gatekeeper itself is tested in the fork: root tests in its CI, plus k3s A/B runs reproducing the customer freeze.
  • Not done locally: an image build and a cluster run.

Related issues/PRs

🤖 Generated with Claude Code

AI-skills: armosec-shared-rules:agent-dispatch-policy,gh-review,armosec-shared-rules:pr_comments

Summary by CodeRabbit

  • New Features
    • Container images, including debug images, now include the container-hook gatekeeper.
    • The liveness endpoint runs registered component health checks and returns an error status with details when a check fails. The container hook is included as a monitored component.
  • Documentation
    • Added information about liveness and readiness endpoints, health-check behavior, and the container-hook gatekeeper.

matthyx and others added 2 commits December 4, 2026 12:20
AddLivenessCheck registers a check that makes /livez return 503 while it
fails, so components can ask kubelet for a restart when they are broken in
a way a restart fixes (e.g. the container hook's fanotify gatekeeper was
lost).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
… gatekeeper

- Pin the inspektor-gadget fork to the merge of kubescape/inspektor-gadget#41
  (c23a76d66): the fanotify gatekeeper and containerhook.Health.
- Register containerhook.Health as a /livez check.
- Build cmd/container-hook-gatekeeper from the same IG module version and
  ship it as /usr/bin/ig-container-hook-gatekeeper in the release and debug
  images, where the hook looks first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
@matthyx matthyx added the ai-assisted Created through Armosec AI tooling (armosec-shared-rules plugin) label Dec 4, 2026
@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The images now build and include the container-hook gatekeeper. The liveness manager runs named checks and reports failures through /livez. The command registers the container-hook health check, with tests and documentation covering the behavior.

Changes: Container-hook health integration

Layer / File(s) Summary
Pin and package the gatekeeper
go.mod, build/Dockerfile, build/Dockerfile.debug, build/README.md
The Inspektor Gadget replacement advances to a revision associated with the gatekeeper and health function. Both images build and include the gatekeeper at /usr/bin/ig-container-hook-gatekeeper; the README describes its role.
Register and run liveness checks
pkg/healthmanager/health_manager.go, cmd/main.go, pkg/healthmanager/health_manager_test.go, docs/features/liveness-checks.md
HealthManager runs registered named checks and returns HTTP 503 with failure details. The command registers containerhook.Health. Tests cover success, failure, and recovery, and documentation describes the endpoints and container-hook checks.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Main as cmd/main.go
  participant HealthManager
  participant ContainerHook as containerhook.Health
  participant Probe as LivenessProbe
  Main->>HealthManager: Register container-hook check
  Probe->>HealthManager: Request /livez
  HealthManager->>ContainerHook: Run registered check
  ContainerHook-->>HealthManager: Return check result
  HealthManager-->>Probe: Return HTTP 200 or 503
Loading

Suggested reviewers: slashben

Merge Risk: Minimal · up to 0bf15 · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change, a container-hook restart on a lost or stuck gatekeeper, and the secondary change, shipping the gatekeeper binary. The changeset adds a liveness check that fails when t…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names the main change, a container-hook restart on a lost or stuck gatekeeper, and the secondary change, shipping the gatekeeper binary. The changeset adds a liveness check that fails when the gatekeeper is lost or stalled, registers it in cmd/main.go, and ships ig-container-hook-gatekeeper in the Dockerfiles. The title uses the conventional commit form and is 80 characters long, which is slightly above the usual short-title length but still readable.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

golangci-lint (2.15.0)

golangci-lint failed without an exit code
golangci-lint (2.15.0) exceeded its 180-second time budget. Findings from completed work are retained; remaining checks are incomplete.

OSV Scanner (2.7.0)

OSV Scanner (2.7.0) exceeded its 180-second time budget. Findings from completed work are retained; remaining checks are incomplete.

go.mod

Scanning dir go.mod
Starting filesystem walk for root: /
Scanned /go.mod file and found 505 packages
End status: 0 dirs visited, 1 inodes visited, 1 Extract calls, 2.557253ms elapsed, 2.557345ms wall time

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4c4040c4-4dec-48b3-b711-762273d30dfe
Commits

Reviewing files that changed from the base of the PR and between efb2f7e and 0bf1595.

Files ignored due to path filters: 1

  • go.sum is excluded by !**/*.sum
Files selected for processing: 1

  • go.mod

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The privileged fanotify process and host-cgroup changes need human runtime validation because neither image builds nor cluster validation were performed.

No open issues 🎉

What changed in this PR

Adds container-hook health monitoring so Kubernetes can restart node-agent after gatekeeper loss or a stuck watcher, and packages the gatekeeper to protect runc from node-agent stalls.

Changes:

  • Adds named liveness checks with error reporting and recovery tests.
  • Registers container-hook health with /livez.
  • Updates the Inspektor Gadget pin, ships its gatekeeper in both images, and documents the behavior.
File Description
pkg/​healthmanager/​health_manager.go Adds liveness-check registration and failure responses.
pkg/​healthmanager/​health_manager_test.go Tests healthy, failing, and recovered checks.
go.sum Updates Inspektor Gadget checksums.
go.mod Pins the gatekeeper-enabled Inspektor Gadget revision.
docs/​features/​liveness-checks.md Documents probe behavior and container-hook health.
cmd/​main.go Registers the container-hook liveness check.
build/​README.md Documents gatekeeper packaging and fallback behavior.
build/​Dockerfile.debug Builds and includes the gatekeeper in debug images.
build/​Dockerfile Builds and includes the gatekeeper in release images.

Review effort: Balanced

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown

Performance Benchmark Results

Node-Agent Resource Usage
Metric BEFORE AFTER Delta
Avg CPU (cores) 0.025 0.026 +5.2%
Peak CPU (cores) 0.030 0.029 -1.4%
Peak CPU p95 (cores) 0.028 0.028 -0.3%
Avg Memory (MiB) 205.409 194.636 -5.2%
Peak Memory (MiB) 210.320 201.867 -4.0%
Dedup Effectiveness

No data available.

kubescape/inspektor-gadget#65 (0920c07e0): a gatekeeper stall ends only on
a reply within its event's deadline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
@matthyx matthyx added the release Create release label Dec 4, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Created through Armosec AI tooling (armosec-shared-rules plugin) release Create release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants