Skip to content
Snippets Groups Projects
Commit 0aa23b3e authored by Steve Loeppky's avatar Steve Loeppky Committed by galargh
Browse files

fix: clarity: no user supplied rcmgr limits of 0 (#9563)

parent 14703e19
Branches
Tags
No related merge requests found
......@@ -52,7 +52,8 @@ func ResourceManager(cfg config.SwarmConfig) interface{} {
return nil, opts, fmt.Errorf("opening IPFS_PATH: %w", err)
}
limitConfig, err := createDefaultLimitConfig(cfg)
var limitConfig rcmgr.LimitConfig
defaultComputedLimitConfig, err := createDefaultLimitConfig(cfg)
if err != nil {
return nil, opts, err
}
......@@ -61,10 +62,15 @@ func ResourceManager(cfg config.SwarmConfig) interface{} {
// is documented in docs/config.md.
// Any changes here should be reflected there.
if cfg.ResourceMgr.Limits != nil {
l := *cfg.ResourceMgr.Limits
// This effectively overrides the computed default LimitConfig with any vlues from cfg.ResourceMgr.Limits
l.Apply(limitConfig)
limitConfig = l
userSuppliedOverrideLimitConfig := *cfg.ResourceMgr.Limits
// This effectively overrides the computed default LimitConfig with any non-zero values from cfg.ResourceMgr.Limits.
// Because of how how Apply works, any 0 value for a user supplied override
// will be overriden with a computed default value.
// There currently isn't a way for a user to supply a 0-value override.
userSuppliedOverrideLimitConfig.Apply(defaultComputedLimitConfig)
limitConfig = userSuppliedOverrideLimitConfig
} else {
limitConfig = defaultComputedLimitConfig
}
if err := ensureConnMgrMakeSenseVsResourceMgr(limitConfig, cfg.ConnMgr); err != nil {
......
......@@ -1844,6 +1844,9 @@ The `Swarm.ResourceMgr.Limits` override the default limits described above.
Any override `BaseLimits` or limit <key,value>s from `Swarm.ResourceMgr.Limits`
that aren't specified will use the [computed default limits](./libp2p-resource-management.md#computed-default-limits).
Until [ipfs/kubo#9564](https://github.com/ipfs/kubo/issues/9564) is addressed, there isn't a way to set an override limit of zero.
0 is currently ignored. 0 currently means use to use the [computed default limits](./libp2p-resource-management.md#computed-default-limits).
Example #1: setting limits for a specific scope
```json
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment