Commit Graph

134 Commits

Author SHA1 Message Date
Gus Eggert
a09c8df24d
fix: remove timeout on default DHT operations (#9783)
* fix: remove timeout on default DHT operations

This removes the timeout by default for DHT operations. In particular
this causes issues with ProvideMany requests which can take an
indeterminate amount of time, but really these should just respect
context timeouts by default. Users can still specify timeouts here if
they want, but by default they will be set to "0" which means "no
timeout".

This is unlikely to break existing users of custom routing, because
there was previously no utility in configuring a router with timeout=0
because that would cause the router to immediately fail, so it is
unlikely (and incorrect) if anybody was using timeout=0.

* fix: remove 5m timeout on ProvideManyRouter

For context see
5fda291b66

---------

Co-authored-by: Marcin Rataj <lidel@lidel.org>
2023-03-30 16:08:43 -04:00
Jorropo
3ab1086f71 chore: migrate go-libipfs to boxo
Resolves #9677, #9676, #9675, #9736
2023-03-28 22:05:25 -04:00
Jorropo
a3b417779c fix: future proof with > rcmgr.DefaultLimit for new enum rcmgr values 2023-03-16 13:41:24 +01:00
Jorropo
e870dcdc0e fix: preserve Unlimited StreamsInbound in connmgr reconciliation
Fixes #9695
2023-03-16 13:41:24 +01:00
Gus Eggert
0d94bac30c feat: add "autoclient" routing type
This routing type is the same as "auto" but it creates the DHT in
"client" mode and hence does not start a DHT server.
2023-03-09 08:18:14 -05:00
Jorropo
7986196414 feat: Reduce RM code footprint
Co-Authored-By: Antonio Navarro Perez <antnavper@gmail.com>
2023-03-06 12:46:58 +01:00
Marten Seemann
a3366c522a
chore: update go-libp2p to v0.26 (#9656)
Co-authored-by: Henrique Dias <hacdias@gmail.com>
2023-02-24 10:34:10 +01:00
Jorropo
0ff406170d fix: update rcmgr for go-libp2p v0.25 2023-02-14 22:19:46 +01:00
Marten Seemann
a00f5cae23 chore: update go-libp2p to v0.25.1 2023-02-14 22:19:46 +01:00
Antonio Navarro Perez
633c497f63 Adjust inbound connection limits depending on memory. 2023-01-30 11:01:03 +01:00
Steve Loeppky
9327ee64ce
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>
2023-01-22 20:04:18 +01:00
Jorropo
8328bab28d fix: ensure connmgr is smaller then autoscalled ressource limits
Fixes #9545
2023-01-20 19:25:38 +01:00
Jorropo
b84cd11566
fix: typo in ensureConnMgrMakeSenseVsResourcesMgr 2023-01-20 15:29:54 +01:00
Jorropo
73ebad1892 fix: refuse to start if connmgr is smaller than ressource limits and not using none connmgr
Fixes: #9548
2023-01-19 01:40:48 +01:00
Antonio Navarro Perez
3bc9b675a0
fix: stats dht command when Routing.Type=auto (#9538)
Fixes default auto mode, but Routing.Type=custom needs more work.
Continued in https://github.com/ipfs/kubo/issues/9482
2023-01-13 00:38:38 +01:00
Antonio Navarro Perez
8cdc86d8c4 fix: disable provide over HTTP with Routing.Type=auto (#9511)
Closes https://github.com/ipfs/kubo/issues/9504
2023-01-04 13:56:15 +01:00
Jorropo
e927dc8e59 fix: correct libp2p transports TODO comments 2022-12-12 22:26:48 +01:00
Jorropo
16d189b8b8 feat: turn on WebTransport by default
Fixes #9292
2022-12-12 21:56:55 +01:00
Jorropo
f08b439d48 update go-libp2p to v0.24.0 2022-12-12 03:47:17 +01:00
Marcin Rataj
70e604ff99
feat: Routing.Type=auto (DHT+IPNI) (#9475)
This changes the default routing to use both DHT and IPNI
at the same time. Closes #9454 Closes #9422

Full context:
https://github.com/ipfs/kubo/issues/9454
https://github.com/ipfs/kubo/issues/9422

Co-authored-by: Steve Loeppky <biglep@protocol.ai>
Co-authored-by: Gus Eggert <gus@gus.dev>
Co-authored-by: Steve Loeppky <biglep@protocol.ai>
2022-12-08 23:20:24 +01:00
Steve Loeppky
01e0bfa359
docs: libp2p resource management (#9468)
Co-authored-by: Antonio Navarro Perez <antnavper@gmail.com>
Co-authored-by: Marcin Rataj <lidel@lidel.org>
2022-12-08 16:18:04 +01:00
Antonio Navarro Perez
9662c8e3f9 Fix sharness test
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
2022-12-07 18:30:21 +01:00
Antonio Navarro Perez
be9539db03 Added a message when RM is disabled.
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
2022-12-07 18:30:21 +01:00
Antonio Navarro Perez
a54cf2a95a Requested changes.
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
2022-12-07 18:30:21 +01:00
Antonio Navarro Perez
67886f7bd3 Fix: RM: Improve init RM message and fix final memory value.
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
2022-12-07 18:30:21 +01:00
Antonio Navarro Perez
d16e63a23e Fix: Resource Manager: Filter stats correctly by %
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
2022-12-07 18:05:15 +01:00
Antonio Navarro Perez
7a8639ee33 Apply suggestions from code review
Co-authored-by: Steve Loeppky <biglep@protocol.ai>
2022-12-07 16:47:37 +01:00
Antonio Navarro Perez
22a03bda6d Increase MaxMemory param to use half of total memory.
Previously it was using 1/8 of the total memory.

Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
2022-12-07 16:47:37 +01:00
Antonio Navarro Perez
df828c0a47 feature: delegated-routing: Add HTTP delegated routing.
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
2022-12-07 16:34:59 +01:00
Antonio Navarro Perez
4587d1c1cb Fix: Change RM log output to WARN level
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
2022-12-07 16:30:43 +01:00
Antonio Navarro Perez
96bbd53033 Fix: RM: Set no-limit value to 1e9 (1000000000).
Added a comment next to the value to make possible to people to grep
over the code and find where that value is set.

Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
2022-12-07 15:56:41 +01:00
Marcin Rataj
5047c02d9a fix: apply agent-version-suffix to libp2p identify
Closes #9456
2022-12-06 12:52:54 +01:00
Marcin Rataj
09765951ea fix(rcmgr): improve error phrasing
limits were not exceeded, manager protects us from that
https://github.com/ipfs/kubo/issues/9432#issuecomment-1334160936
2022-12-02 11:13:42 +01:00
Steve Loeppky
83034d840c Doc improvements and changelog for resource manager (#9413)
Co-authored-by: Antonio Navarro Perez <antnavper@gmail.com>
2022-11-16 13:09:12 +01:00
Antonio Navarro Perez
dfa631e841 Apply go fmt
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
2022-11-15 18:43:44 +01:00
Antonio Navarro Perez
4bff042036 Update core/node/libp2p/rcmgr_defaults.go
Co-authored-by: Steve Loeppky <biglep@protocol.ai>
2022-11-15 18:43:44 +01:00
Antonio Navarro Perez
377d4e9938 Remove limitation by HighWater param.
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
2022-11-15 18:43:44 +01:00
Antonio Navarro Perez
fb42b53f58 Fix RM errors when acceleratedDHT is active
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
2022-11-15 18:43:44 +01:00
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
Antonio Navarro Perez
bf8274f6e2
feat: --reset flag on swarm limit command (#9310)
* feat: --reset flag on swarm limit command

This flag allows to the user to reset limits to default values.

Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>

* Use adjusted default limits and remove already fixed FIXME

Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>

* Apply suggestions from code review

Co-authored-by: Gus Eggert <gus@gus.dev>

* Return correct defaults

* Remove resetting all values from a map.

Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>

Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
Co-authored-by: Gus Eggert <gus@gus.dev>
2022-10-12 11:02:43 -04:00
Gus Eggert
e550d9e476
ci: add stylecheck to golangci-lint (#9334) 2022-10-06 10:18:40 -04:00
Antonio Navarro Perez
bffc012c6b Fix: swarm stats all command
`swarm stats all` requires that the ResourceManager instance
implements `rcmgr.ResourceManagerState`, and `loggingResourceManager`
was not implementing it, so the command was failing.

Also added a sharness test to check that the command is executing
correctly, because `jq -e` doesn't return an error if the json is nil.

Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
2022-10-06 14:55:18 +02:00
Jorropo
baccaef1b5
Merge pull request #9293 from Jorropo/webtransport
feat: add webtransport as an optin transport
2022-09-23 20:09:33 +02:00
Jorropo
8baec10146 feat: add webtransport as an optin transport 2022-09-23 19:50:55 +02:00
Antonio Navarro Perez
d1b9e41fc2
feat: Delegated routing with custom configuration. (#9274)
New multi-router configuration system based on https://hackmd.io/G1KRDEX5T3qyfoBMkIrBew#Methods

- Added a new routing type: "custom"
- Added specific struct types for different Routers (instead of map[string]interface{})
- Added `Duration` config type, to make easier time string parsing
- Added config documentation.
- Use the latest go-delegated-routing library version with GET support.
- Added changelog notes for this feature.

It:
- closes #9157
- closes #9079
- closes #9186
2022-09-22 15:47:45 +02:00
Jorropo
fb22320c9a fix: error message for DefaultServiceLimits change 2022-09-21 23:16:03 +02:00
Jorropo
74aaf37cec chore: bump go-libp2p v0.23.1
This does not include any WebTransport config code in Kubo, this will be done later in an other PR.
2022-09-21 23:16:03 +02:00
Jorropo
196887cbe5 chore: bump go-libp2p v0.22.0 & go1.18&go1.19
Fixes: #9225
2022-09-09 17:09:38 +02:00
Marco Munizaga
da54d5ce4b Check err for view.Register 2022-08-15 14:12:21 -07:00
Marco Munizaga
27b046f98e Move register exporter to metrics file 2022-08-15 14:12:21 -07:00