kubo/core/commands
Antonio Navarro Perez 254d81a9d5
feat: Improve ResourceManager UX (#9338)
This PR adds several new functionalities to make easier the usage of ResourceManager:

- Now resource manager logs when resources are exceeded are on ERROR instead of warning.
- The resources exceeded error now shows what kind of limit was reached and the scope.
- When there was no limit exceeded, we print a message for the user saying that limits are not exceeded anymore.
- Added `swarm limit all` command to show all set limits with the same format as `swarm stats all`
- Added `min-used-limit-perc` option to `swarm stats all` to only show stats that are above a specific percentage
- Simplify a lot default values.
- **Enable ResourceManager by default.**

Output example:
```
2022-11-09T10:51:40.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:59      Consider inspecting logs and raising the resource manager limits. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#swarmresourcemgr
2022-11-09T10:51:50.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 483095 times with error "transient: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:51:50.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:59      Consider inspecting logs and raising the resource manager limits. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#swarmresourcemgr
2022-11-09T10:52:00.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 455294 times with error "transient: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:52:00.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:59      Consider inspecting logs and raising the resource manager limits. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#swarmresourcemgr
2022-11-09T10:52:10.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 471384 times with error "transient: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:52:10.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:59      Consider inspecting logs and raising the resource manager limits. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#swarmresourcemgr
2022-11-09T10:52:20.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 8 times with error "peer:12D3KooWKqcaBtcmZKLKCCoDPBuA6AXGJMNrLQUPPMsA5Q6D1eG6: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:52:20.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 192 times with error "peer:12D3KooWPjetWPGQUih9LZTGHdyAM9fKaXtUxDyBhA93E3JAWCXj: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:52:20.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 469746 times with error "transient: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:52:20.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:59      Consider inspecting logs and raising the resource manager limits. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#swarmresourcemgr
2022-11-09T10:52:30.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 484137 times with error "transient: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:52:30.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 29 times with error "peer:12D3KooWPjetWPGQUih9LZTGHdyAM9fKaXtUxDyBhA93E3JAWCXj: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:52:30.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:59      Consider inspecting logs and raising the resource manager limits. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#swarmresourcemgr
2022-11-09T10:52:40.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 468843 times with error "transient: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:52:40.566+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:59      Consider inspecting logs and raising the resource manager limits. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#swarmresourcemgr
2022-11-09T10:52:50.566+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 366638 times with error "transient: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:52:50.566+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:59      Consider inspecting logs and raising the resource manager limits. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#swarmresourcemgr
2022-11-09T10:53:00.566+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 405526 times with error "transient: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:53:00.566+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 107 times with error "peer:12D3KooWQZQCwevTDGhkE9iGYk5sBzWRDUSX68oyrcfM9tXyrs2Q: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:53:00.566+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:59      Consider inspecting logs and raising the resource manager limits. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#swarmresourcemgr
2022-11-09T10:53:10.566+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 336923 times with error "transient: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:53:10.566+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:59      Consider inspecting logs and raising the resource manager limits. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#swarmresourcemgr
2022-11-09T10:53:20.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 71 times with error "transient: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:53:20.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:59      Consider inspecting logs and raising the resource manager limits. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#swarmresourcemgr
2022-11-09T10:53:30.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:64      Resrouce limits are no longer being exceeded.

```
## Validation tests

- Accelerated DHT client runs with no errors when ResourceManager is active. No problems were observed.
- Running an attack with 200 connections and 1M streams using yamux protocol. Node was usable during the attack. With ResourceManager deactivated, the node was killed by the OS because of the amount of memory consumed.
	- Actions done when the attack was active:
		- Add files 
		- Force a reprovide
		- Use the gateway to resolve an IPNS address.

It closes #9001 
It closes #9351
It closes #9322
2022-11-10 12:25:57 +01:00
..
cmdenv ci: add stylecheck to golangci-lint (#9334) 2022-10-06 10:18:40 -04:00
cmdutils refactor: rename to kubo 2022-07-06 18:40:37 +02:00
dag chore(cmds): dag import: use ipld legacy decode 2022-10-13 16:45:50 +02:00
e Fix typo in an error.go comment: "is adds" -> "adds". 2018-01-17 15:25:54 -08:00
keyencode chore: bump go-libp2p v0.22.0 & go1.18&go1.19 2022-09-09 17:09:38 +02:00
name chore: bump go-libp2p v0.22.0 & go1.18&go1.19 2022-09-09 17:09:38 +02:00
object refactor: rename to kubo 2022-07-06 18:40:37 +02:00
pin docs: pin remote arg 2022-10-14 21:16:36 +02:00
unixfs refactor: rename to kubo 2022-07-06 18:40:37 +02:00
active.go refactor: rename to kubo 2022-07-06 18:40:37 +02:00
add.go fix: ensure hasher is registered when using a hashing function 2022-09-26 10:05:26 +02:00
bitswap.go chore: bump go-libp2p v0.22.0 & go1.18&go1.19 2022-09-09 17:09:38 +02:00
block.go refactor: rename to kubo 2022-07-06 18:40:37 +02:00
bootstrap.go chore: bump go-libp2p v0.22.0 & go1.18&go1.19 2022-09-09 17:09:38 +02:00
cat.go refactor: rename to kubo 2022-07-06 18:40:37 +02:00
cid.go ci: add stylecheck to golangci-lint (#9334) 2022-10-06 10:18:40 -04:00
commands_test.go feat: Add command line completion for fish 2022-10-30 21:13:53 +00:00
commands.go feat: Add command line completion for fish 2022-10-30 21:13:53 +00:00
completion.go feat: Add command line completion for fish 2022-10-30 21:13:53 +00:00
config_test.go add remote pinning policy for mfs (#7798) 2021-01-28 18:58:44 -05:00
config.go fmt: applies go1.19 fmt 2022-09-08 18:34:06 +02:00
dht_test.go chore: bump go-libp2p v0.22.0 & go1.18&go1.19 2022-09-09 17:09:38 +02:00
dht.go chore: bump go-libp2p v0.22.0 & go1.18&go1.19 2022-09-09 17:09:38 +02:00
diag.go feat: add an "ipfs diag profile" command 2021-07-21 14:51:47 -07:00
dns.go refactor: rename to kubo 2022-07-06 18:40:37 +02:00
external.go refactor: get rid of cmdDetails awkwardness 2020-08-04 18:28:40 -04:00
extra.go refactor: get rid of cmdDetails awkwardness 2020-08-04 18:28:40 -04:00
files.go feat(cmds/add): --to-files option automates files cp (#8927) 2022-09-21 18:08:36 +02:00
filestore.go refactor: rename to kubo 2022-07-06 18:40:37 +02:00
get_test.go cmdkit -> cmds 2019-05-10 23:00:20 -07:00
get.go refactor: rename to kubo 2022-07-06 18:40:37 +02:00
helptext_test.go gx: unrewrite 2019-03-05 18:33:56 +01:00
id.go ci: add stylecheck to golangci-lint (#9334) 2022-10-06 10:18:40 -04:00
keystore.go ci: add stylecheck to golangci-lint (#9334) 2022-10-06 10:18:40 -04:00
log.go docs: note log tail is broken (#9383) 2022-11-10 00:20:53 +01:00
ls.go refactor: rename to kubo 2022-07-06 18:40:37 +02:00
mount_nofuse.go chore: mark fuse experimental (#8962) 2022-05-12 10:32:54 -07:00
mount_unix.go refactor: rename to kubo 2022-07-06 18:40:37 +02:00
mount_windows.go cmdkit -> cmds 2019-05-10 23:00:20 -07:00
multibase.go ci: add stylecheck to golangci-lint (#9334) 2022-10-06 10:18:40 -04:00
p2p.go chore: bump go-libp2p v0.22.0 & go1.18&go1.19 2022-09-09 17:09:38 +02:00
ping.go chore: bump go-libp2p v0.22.0 & go1.18&go1.19 2022-09-09 17:09:38 +02:00
profile.go refactor: rename to kubo 2022-07-06 18:40:37 +02:00
pubsub.go refactor: rename to kubo 2022-07-06 18:40:37 +02:00
refs.go docs(cmds): Clarify block fetching of refs endpoint. 2022-10-13 17:29:29 +02:00
repo.go add refs local alias repo ls (#9320) 2022-10-13 17:30:19 +02:00
resolve.go refactor: rename to kubo 2022-07-06 18:40:37 +02:00
root_test.go pre-populate required arguments from request body 2018-03-18 13:04:25 -07:00
root.go ci: add stylecheck to golangci-lint (#9334) 2022-10-06 10:18:40 -04:00
routing.go chore: bump go-libp2p v0.22.0 & go1.18&go1.19 2022-09-09 17:09:38 +02:00
shutdown.go refactor: rename to kubo 2022-07-06 18:40:37 +02:00
stat_dht.go chore: bump go-libp2p v0.22.0 & go1.18&go1.19 2022-09-09 17:09:38 +02:00
stat_provide.go refactor: rename to kubo 2022-07-06 18:40:37 +02:00
stat.go ci: add stylecheck to golangci-lint (#9334) 2022-10-06 10:18:40 -04:00
swarm.go feat: Improve ResourceManager UX (#9338) 2022-11-10 12:25:57 +01:00
sysdiag.go refactor: rename to kubo 2022-07-06 18:40:37 +02:00
tar.go refactor: rename to kubo 2022-07-06 18:40:37 +02:00
urlstore.go refactor: rename to kubo 2022-07-06 18:40:37 +02:00
version.go fix: kubo in daemon and cli stdout 2022-07-20 16:26:49 +02:00