Skip to content

fix(p2p): read LOCALAI_P2P_ENABLE_LIMITS as documented - #13036

Closed
Vivek1898 wants to merge 1 commit into
mudler:masterfrom
Vivek1898:fix/13031-p2p-enable-limits
Closed

Vivek1898 wants to merge 1 commit into
mudler:masterfrom
Vivek1898:fix/13031-p2p-enable-limits

Conversation

@Vivek1898

Copy link
Copy Markdown
Contributor

Description

This PR fixes #13031

newNodeOpts reads LOCALAI_P2P_ENABLE_LIMITS with != "true" and passes the result straight into ResourceLimit.Enable, so the libp2p resource manager is enabled when the variable is unset and disabled when it is set to "true". That is the opposite of the docs table (distributed_inferencing.md: "Set to "true" to enable connection limits and resources management") and of the troubleshooting page, both of which set it to true to turn limits on.

The comparison was == "true" from #3125 through v3.0.0. #5889 flipped it to != without changing how the value is used; the debug example that the same PR added to the docs sets LOCALAI_P2P_ENABLE_LIMITS=true, so the flip looks unintended rather than a change of default. In edgevpn v0.34.0, Limit.Enable == false installs network.NullResourceManager, so unset now means "limits on, 100 max conns" and true means "no limits".

Changes:

  • core/p2p/p2p.go: compare with == "true" and name the result enableLimits. The config.Config literal moves into a new newNodeConfig(token) so the environment parsing is reachable from a test; newNodeOpts is otherwise unchanged.
  • core/p2p/node_config_internal_test.go + p2p_suite_test.go: ginkgo suite for the package (there was none) with specs for unset, "true", and other values. On the previous code the first three specs fail; on this branch all pass.

Notes for Reviewers

  • Behaviour change for anyone who relied on the inverted reading: an unset variable now leaves the resource manager off (as before fix(p2p): adapt to backend changes, general improvements #5889), and LOCALAI_P2P_ENABLE_LIMITS=true turns it on. If the intent in fix(p2p): adapt to backend changes, general improvements #5889 was to make limits the default, the docs table and troubleshooting page would need the opposite change instead; happy to do that if so.
  • go test ./core/p2p/ and go vet ./core/p2p/ pass locally (macOS arm64, Go 1.26). Note that on darwin edgevpn disables the resource manager regardless, so the effect is only observable on Linux.
  • No docs change: the existing text already describes the intended behaviour.

Signed commits

  • Yes, I signed my commits.
  • Documentation updated (docs/content/) for user-facing changes, or not applicable

Root cause: mudler#5889 changed the comparison to `!= "true"` while the result
still feeds ResourceLimit.Enable directly, so the libp2p resource manager
was enabled when the variable was unset and disabled when it was set to
"true" -- the opposite of the docs, and of the debug example that the same
PR added.

Extract newNodeConfig from newNodeOpts so the environment parsing can be
covered by a test.

Fixes mudler#13031

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Vivek1898 <viveksingh27795@gmail.com>
@mudler-agent

Copy link
Copy Markdown
Collaborator

Thank you for this fix. It is now on master, bundled with a few related fixes in #13044, with your commits and authorship kept (the P2P resource limits fix). Some small follow-up changes were needed while rebasing on current master; they are in the same series. Closing this PR as it is now redundant.

@Vivek1898

Copy link
Copy Markdown
Contributor Author

Thanks for carrying it through #13044 and keeping the authorship.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LOCALAI_P2P_ENABLE_LIMITS is read inverted: limits are on when unset and off when set to “true”

2 participants