feat(cli): add kerno preflight command#97
Conversation
|
Fix conlicts |
btwshivam
left a comment
There was a problem hiding this comment.
merge state is conflicting and the branch is on a stale base (merge-base bdfe9a6), so the diff drags in completion.go, doctor.go, kerno-mangen, install.sh, Makefile and others that diverge from main. rebase on upstream main first so the diff is just the preflight feature, then the two notes inline. also note the job validates one node, not every daemonset node, so a mixed-kernel cluster can pass preflight and still fail on some nodes, worth calling out in the docs.
| limits: | ||
| cpu: 100m | ||
| memory: 64Mi | ||
| volumeMounts: |
There was a problem hiding this comment.
the job mounts btf, proc, and cgroup, but CheckTracefs (checks.go:362) looks for /sys/kernel/tracing or /sys/kernel/debug/tracing, and neither is mounted here. the daemonset mounts /sys/kernel/debug (daemonset.yaml), so the actual daemon has it but this pre-install hook doesn't, which means the hook reports a tracefs problem on every healthy node and can block install. add the same /sys/kernel/debug (and tracing) mounts so the job's checks match what the daemon actually runs with.
|
|
||
| // CheckBTF verifies that /sys/kernel/btf/vmlinux is readable. | ||
| func CheckBTF(opts CheckOptions) Result { | ||
| _, err := os.Stat(opts.BTFPath) |
There was a problem hiding this comment.
os.Stat only proves the path exists, not that it's readable, but the message says "readable". a root-readable-only or zero-perm vmlinux would pass here and then fail at load. minor, but either open it (os.Open + close) or soften the message. also the Detail says "kernel >= 5.2" while CheckKernelVersion requires 5.8, pick one.
Signed-off-by: Devansh Soni <devanshsoni899@gmail.com>
Signed-off-by: Devansh Soni <devanshsoni899@gmail.com>
Signed-off-by: Devansh Soni <devanshsoni899@gmail.com>
Signed-off-by: Devansh Soni <devanshsoni899@gmail.com>
Signed-off-by: Devansh Soni <devanshsoni899@gmail.com>
Signed-off-by: Devansh Soni <devanshsoni899@gmail.com>
Signed-off-by: Devansh Soni <devanshsoni899@gmail.com>
- CheckBTF opens vmlinux instead of stat so a root-only or zero-perm file fails here rather than later at eBPF load; fix Detail to say kernel >= 5.8 to match CheckKernelVersion. - Mount /sys/kernel/debug in the Helm preflight Job and DaemonSet init container so CheckTracefs matches what the daemon actually runs with, preventing a false tracefs WARN that can block install. - Document in values.yaml that the pre-install hook validates only one node; initContainer gates every node on mixed-kernel clusters. Signed-off-by: Devansh Soni <devanshsoni899@gmail.com>
5b35e1e to
ca4339d
Compare
|
Thanks for the review @btwshivam — addressed all points and force-pushed: Rebase / conflicts. Rebased onto current tracefs mounts (preflight-job.yaml). Added the CheckBTF (checks.go). Switched Mixed-kernel docs. Documented in Verified: |
|
fix conflict |
What
Adds the
kerno preflightsubcommand to validate host prerequisites (kernel version, BTF, capabilities, cgroups, etc.) before running the diagnostic engine. Includes a Helm pre-install hook Job and an optional DaemonSet init container.Why
Fixes #44
When kerno fails to start due to host misconfigurations, users currently see cryptic Go/eBPF verifier errors. This provides a clean, upfront check that reports PASS/FAIL/WARN with actionable, copy-pasteable remediation hints.
How
internal/preflightpackage containing 10 checks. Usesgolang.org/x/sys/unixfor capability checks to avoid CGO and new dependencies.internal/cli/preflight.gofor the Cobra command with pretty terminal output and JSON output (--output json).preflight-job.yaml) withhostNetwork: trueto ensure accurate port checks.initContainersblock to the DaemonSet.ExecStartPre=/usr/local/bin/kerno preflightto the systemd unit.checks_test.gothat simulate filesystem mounts and synthetic capability masks.Testing
go build ./...passesgo test ./...passesgo vet ./...passesgolangci-lint run ./...passesTested locally with:
./bin/kerno preflight(to verify sudo hints) andsudo ./bin/kerno preflight --output jsonN/A — pure docs/refactor (Did not modify BPF C code)
sudo ./bin/bpf-verify --read 5sconfirms 6/6 programs still load./scripts/verify.shpasses (or specific phase:./scripts/verify.sh quality)Checklist
feat(scope): subject)git commit -s)scripts/verify.sh