Repository navigation
Conversation
Only defer closing the network namespace handle when GetFromPath succeeds. Avoid calling Close on the invalid handle returned by netns.None when using the current network namespace. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Replace the global IPVS family ID and sync.Once with sync.OnceValues to cache both the family ID and initialization error. Try discovering the IPVS generic-netlink family before attempting modprobe. Linux 5.17 and newer support automatic module loading, but older kernels may still require explicit module loading. Keep modprobe as a best-effort fallback and retry discovery afterward. Only report module-loading errors if discovery also fails, preserving both errors to help diagnose initialization failures. Return initialization errors instead of logging them, removing the dependency on logrus. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
thaJeztah
force-pushed
the
cleanup_init
branch
from
October 15, 2026 20:53
8ae0b6a to
9264de4
Compare
thaJeztah
marked this pull request as ready for review
October 15, 2026 20:53
There was a problem hiding this comment.
🟡 Changes recommended
Failed module-loading diagnostics are discarded, and initialization failure paths lack regression coverage.
2 open findings
What changed in this PR
Updates IPVS netlink initialization to return errors to callers and removes its logging dependency.
Changes:
- Caches family discovery results and errors, with best-effort module-loading fallback.
- Closes namespace handles only when explicitly opened.
- Removes logrus and unused dependency checksums.
| File | Description |
|---|---|
| netlink_linux.go | Reworks family discovery, caching, and module-loading fallback. |
| ipvs_linux.go | Returns initialization errors and guards namespace cleanup. |
| go.sum | Removes unused dependency checksums. |
| go.mod | Removes logrus dependency. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| } | ||
| // ipvsFamily lazily discovers and caches the IPVS generic-netlink family ID | ||
| // and any initialization error. | ||
| var ipvsFamily = sync.OnceValues(func() (int, error) { |
Comment on lines
+81
to
+86
| _, _ = exec.Command("modprobe", "-va", "ip_vs").CombinedOutput() | ||
|
|
||
| family, err = getIPVSFamily() | ||
| if err != nil { | ||
| return 0, fmt.Errorf("get IPVS generic-netlink family: %w", err) | ||
| } |
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.

ipvs: only close namespace handles when opened
Only defer closing the network namespace handle when GetFromPath
succeeds. Avoid calling Close on the invalid handle returned by
netns.None when using the current network namespace.
ipvs: propagate errors during netlink initialization
Replace the global IPVS family ID and sync.Once with sync.OnceValues
to cache both the family ID and initialization error.
Try discovering the IPVS generic-netlink family before attempting
modprobe. Linux 5.17 and newer support automatic module loading,
but older kernels may still require explicit module loading.
Keep modprobe as a best-effort fallback and retry discovery afterward.
Only report module-loading errors if discovery also fails, preserving
both errors to help diagnose initialization failures.
Return initialization errors instead of logging them, removing the
dependency on logrus.