From 0fe75d63ea9990aaab72e3a3759b47428d991584 Mon Sep 17 00:00:00 2001 From: Gus Eggert Date: Thu, 2 Jun 2022 10:31:06 -0400 Subject: [PATCH] feat: disable resource manager by default (#9003) * feat: disable resource manager by default We are disabling this by default for v0.13 as we work to improve the UX around Resource Manager. It is still usable and can be enabled in the IPFS config with "ipfs config --bool Swarm.ResourceMgr.Enabled true". We intend to enable Resource Manager by default in a subsequent release. * docs(config): Swarm.ResourceMgr disabled by default Co-authored-by: Marcin Rataj (cherry picked from commit b1c051d2507cec34a9d2b313ea43a092b3fdc4a4) --- CHANGELOG.md | 7 +++- core/node/libp2p/rcmgr.go | 2 +- docs/config.md | 2 +- .../t0116-prometheus-data/prometheus_metrics | 4 -- test/sharness/t0139-swarm-rcmgr.sh | 38 +++++++++---------- 5 files changed, 26 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 463b9448a..1c28aa805 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -74,16 +74,19 @@ To understand the wider context why we made these changes, read *Highlights* bel *You can now easily bound how much resource usage libp2p consumes! This aids in protecting nodes from consuming more resources then are available to them.* -The [libp2p Network Resource Manager](https://github.com/libp2p/go-libp2p-resource-manager#readme) is enabled by default, but can be disabled via: +The [libp2p Network Resource Manager](https://github.com/libp2p/go-libp2p-resource-manager#readme) is disabled by default, but can be enabled via: -`ipfs config --json Swarm.ResourceMgr.Enabled false` +`ipfs config --json Swarm.ResourceMgr.Enabled true` When enabled, it applies some safe defaults that can be inspected and adjusted with: + - `ipfs swarm stats --help` - `ipfs swarm limit --help` User changes persist to config at [`Swarm.ResourceMgr`](https://github.com/ipfs/go-ipfs/blob/master/docs/config.md#swarmresourcemgr). +The Resource Manager will be enabled by default in a future release. + #### 🔃 Relay V2 client with auto discovery (`Swarm.RelayClient`) *All the pieces are enabled for [hole-punching](https://blog.ipfs.io/2022-01-20-libp2p-hole-punching/) by default, improving connecting with nodes behind NATs and Firewalls!* diff --git a/core/node/libp2p/rcmgr.go b/core/node/libp2p/rcmgr.go index 4d4b29a56..c6a4a5f48 100644 --- a/core/node/libp2p/rcmgr.go +++ b/core/node/libp2p/rcmgr.go @@ -31,7 +31,7 @@ func ResourceManager(cfg config.SwarmConfig) interface{} { var manager network.ResourceManager var opts Libp2pOpts - enabled := cfg.ResourceMgr.Enabled.WithDefault(true) + enabled := cfg.ResourceMgr.Enabled.WithDefault(false) /// ENV overrides Config (if present) switch os.Getenv("LIBP2P_RCMGR") { diff --git a/docs/config.md b/docs/config.md index fbdc4540c..8f2cee06f 100644 --- a/docs/config.md +++ b/docs/config.md @@ -1637,7 +1637,7 @@ and tracking recource usage over time. Enables the libp2p Network Resource Manager and auguments the default limits using user-defined ones in `Swarm.ResourceMgr.Limits` (if present). -Default: `true` +Default: `false` Type: `flag` diff --git a/test/sharness/t0116-prometheus-data/prometheus_metrics b/test/sharness/t0116-prometheus-data/prometheus_metrics index adffa4c1b..dd358e82f 100644 --- a/test/sharness/t0116-prometheus-data/prometheus_metrics +++ b/test/sharness/t0116-prometheus-data/prometheus_metrics @@ -656,10 +656,6 @@ leveldb_datastore_sync_latency_seconds_bucket leveldb_datastore_sync_latency_seconds_count leveldb_datastore_sync_latency_seconds_sum leveldb_datastore_sync_total -libp2p_rcmgr_memory_allocations_allowed_total -libp2p_rcmgr_memory_allocations_blocked_total -libp2p_rcmgr_peer_blocked_total -libp2p_rcmgr_peers_allowed_total process_cpu_seconds_total process_max_fds process_open_fds diff --git a/test/sharness/t0139-swarm-rcmgr.sh b/test/sharness/t0139-swarm-rcmgr.sh index 895863004..24b9ebf65 100755 --- a/test/sharness/t0139-swarm-rcmgr.sh +++ b/test/sharness/t0139-swarm-rcmgr.sh @@ -6,6 +6,25 @@ test_description="Test ipfs swarm ResourceMgr config and commands" test_init_ipfs +# test correct behavior when resource manager is disabled (default behavior) +test_launch_ipfs_daemon + +test_expect_success 'Swarm limit should fail since RM is disabled' ' + test_expect_code 1 ipfs swarm limit system 2> actual && + test_should_contain "missing ResourceMgr" actual +' + +test_expect_success 'Swarm stats should fail since RM is disabled' ' + test_expect_code 1 ipfs swarm stats all 2> actual && + test_should_contain "missing ResourceMgr" actual +' + +test_kill_ipfs_daemon + +test_expect_success 'Enable resource manager' ' + ipfs config --bool Swarm.ResourceMgr.Enabled true +' + # swarm limit|stats should fail in offline mode test_expect_success 'disconnected: swarm limit requires running daemon' ' @@ -127,23 +146,4 @@ test_expect_success 'Set limit for peer scope with an invalid peer ID' ' test_kill_ipfs_daemon -# test correct behavior when resource manager is disabled -test_expect_success 'Disable resource manager' ' - ipfs config --bool Swarm.ResourceMgr.Enabled false -' - -test_launch_ipfs_daemon - -test_expect_success 'Swarm limit should fail since RM is disabled' ' - test_expect_code 1 ipfs swarm limit system 2> actual && - test_should_contain "missing ResourceMgr" actual -' - -test_expect_success 'Swarm stats should fail since RM is disabled' ' - test_expect_code 1 ipfs swarm stats all 2> actual && - test_should_contain "missing ResourceMgr" actual -' - -test_kill_ipfs_daemon - test_done