mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
fix: clarity: no user supplied rcmgr limits of 0 (#9563)
Co-authored-by: Antonio Navarro Perez <antnavper@gmail.com> Co-authored-by: Marcin Rataj <lidel@lidel.org>
This commit is contained in:
parent
c706c638fc
commit
9327ee64ce
@ -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
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user