feat: explicit announce-on/off profiles (#10524)
moving reprovide on/off to separate profile to avoid footgun where node no longer announces to DHT + ipfs daemon check that prints warning on start if reprovide system is disabled
Marcin Rataj committed
Oct 3, 2024 at 21:39 UTC
a8ecf014a9ed15c15760c827e8909d99f176e4c4
4 files changed
+102
-33
cmd/ipfs/kubo/daemon.go
+18
-1
@@ -600,8 +600,25 @@ take effect.
600
fmt.Println("(Hit ctrl-c again to force-shutdown the daemon.)")
601
}()
602
603
- // Give the user heads up if daemon running in online mode has no peers after 1 minute
603
if !offline {
604
+ // Warn users who were victims of 'lowprofile' footgun (https://github.com/ipfs/kubo/pull/10524)
605
+ if cfg.Experimental.StrategicProviding {
606
+ fmt.Print(`
607
+⚠️ Reprovide system is disabled due to 'Experimental.StrategicProviding=true'
608
+⚠️ Local CIDs will not be announced to Amino DHT, making them impossible to retrieve without manual peering
609
+⚠️ If this is not intentional, call 'ipfs config profile apply announce-on'
610
+
611
+`)
612
+ } else if cfg.Reprovider.Interval.WithDefault(config.DefaultReproviderInterval) == 0 {
613
+ fmt.Print(`
614
+⚠️ Reprovider system is disabled due to 'Reprovider.Interval=0'
615
+⚠️ Local CIDs will not be announced to Amino DHT, making them impossible to retrieve without manual peering
616
+⚠️ If this is not intentional, call 'ipfs config profile apply announce-on', or set 'Reprovider.Interval=22h'
617
+
618
+`)
619
+ }
620
+
621
+ // Give the user heads up if daemon running in online mode has no peers after 1 minute
622
time.AfterFunc(1*time.Minute, func() {
623
cfg, err := cctx.GetConfig()
624
if err != nil {
config/profile.go
+26
-1
@@ -174,10 +174,12 @@ functionality - performance of content discovery and data
174
fetching may be degraded.
175
`,
176
Transform: func(c *Config) error {
177
+ // Disable "server" services (dht, autonat, limited relay)
178
c.Routing.Type = NewOptionalString("autoclient")
179
c.AutoNAT.ServiceMode = AutoNATServiceDisabled
179
- c.Reprovider.Interval = NewOptionalDuration(0)
180
+ c.Swarm.RelayService.Enabled = False
181
182
+ // Keep bare minimum connections around
183
lowWater := int64(20)
184
highWater := int64(40)
185
gracePeriod := time.Minute
@@ -188,6 +190,29 @@ fetching may be degraded.
190
return nil
191
},
192
},
193
+ "announce-off": {
194
+ Description: `Disables Reprovide system (and announcing to Amino DHT).
195
+
196
+ USE WITH CAUTION:
197
+ The main use case for this is setups with manual Peering.Peers config.
198
+ Data from this node will not be announced on the DHT. This will make
199
+ DHT-based routing an data retrieval impossible if this node is the only
200
+ one hosting it, and other peers are not already connected to it.
201
+`,
202
+ Transform: func(c *Config) error {
203
+ c.Reprovider.Interval = NewOptionalDuration(0) // 0 disables periodic reprovide
204
+ c.Experimental.StrategicProviding = true // this is not a typo (the name is counter-intuitive)
205
+ return nil
206
+ },
207
+ },
208
+ "announce-on": {
209
+ Description: `Re-enables Reprovide system (reverts announce-off profile).`,
210
+ Transform: func(c *Config) error {
211
+ c.Reprovider.Interval = NewOptionalDuration(DefaultReproviderInterval) // have to apply explicit default because nil would be ignored
212
+ c.Experimental.StrategicProviding = false // this is not a typo (the name is counter-intuitive)
213
+ return nil
214
+ },
215
+ },
216
"randomports": {
217
Description: `Use a random port number for swarm.`,
218
docs/changelogs/v0.31.md
+13
@@ -6,6 +6,7 @@
6
7
- [Overview](#overview)
8
- [🔦 Highlights](#-highlights)
9
+ - [`lowpower` profile no longer breaks DHT announcements](#lowpower-profile-no-longer-breaks-dht-announcements)
10
- [📝 Changelog](#-changelog)
11
- [👨👩👧👦 Contributors](#-contributors)
12
@@ -13,6 +14,18 @@
14
15
### 🔦 Highlights
16
17
+#### `lowpower` profile no longer breaks DHT announcements
18
+
19
+We've notices users were applying `lowpower` profile, and then reporting content routing issues. This was because `lowpower` disabled reprovider system and locally hosted data was no longer announced on Amino DHT.
20
+
21
+This release changes [`lowpower` profile](https://github.com/ipfs/kubo/blob/master/docs/config.md#lowpower-profile) to not change reprovider settings, ensuring the new users are not sabotaging themselves. It also adds [`annouce-on`](https://github.com/ipfs/kubo/blob/master/docs/config.md#announce-on-profile) and [`announce-off`](https://github.com/ipfs/kubo/blob/master/docs/config.md#announce-off-profile) profiles for controlling announcement settings separately.
22
+
23
+> [!IMPORTANT]
24
+> If you've ever applied the `lowpower` profile before, there is a high chance your node is not announcing to DHT anymore.
25
+> If you have `Reprovider.Interval` set to `0` you may want to wet it to `22h` (or run `ipfs config profile apply announce-on`) to fix your system.
26
+>
27
+> As a convenience, `ipfs daemon` will warn if reprovide system is disabled, creating oportinity to fix configuration if it was not intentional.
28
+
29
### 📝 Changelog
30
31
### 👨👩👧👦 Contributors
docs/config.md
+45
-31
@@ -183,6 +183,8 @@ config file at runtime.
183
- [`flatfs` profile](#flatfs-profile)
184
- [`badgerds` profile](#badgerds-profile)
185
- [`lowpower` profile](#lowpower-profile)
186
+ - [`announce-off` profile](#announce-off-profile)
187
+ - [`announce-on` profile](#announce-on-profile)
188
- [`legacy-cid-v0` profile](#legacy-cid-v0-profile)
189
- [`test-cid-v1` profile](#test-cid-v1-profile)
190
- [Types](#types)
@@ -299,7 +301,7 @@ Map of HTTP headers to set on responses from the RPC (`/api/v0`) HTTP server.
301
Example:
302
```json
303
{
302
- "Foo": ["bar"]
304
+ "Foo": ["bar"]
305
}
306
```
307
@@ -534,27 +536,27 @@ Default:
536
```
537
{
538
"mounts": [
537
- {
538
- "child": {
539
- "path": "blocks",
540
- "shardFunc": "/repo/flatfs/shard/v1/next-to-last/2",
541
- "sync": true,
542
- "type": "flatfs"
543
- },
544
- "mountpoint": "/blocks",
545
- "prefix": "flatfs.datastore",
546
- "type": "measure"
547
- },
548
- {
549
- "child": {
550
- "compression": "none",
551
- "path": "datastore",
552
- "type": "levelds"
553
- },
554
- "mountpoint": "/",
555
- "prefix": "leveldb.datastore",
556
- "type": "measure"
557
- }
539
+ {
540
+ "child": {
541
+ "path": "blocks",
542
+ "shardFunc": "/repo/flatfs/shard/v1/next-to-last/2",
543
+ "sync": true,
544
+ "type": "flatfs"
545
+ },
546
+ "mountpoint": "/blocks",
547
+ "prefix": "flatfs.datastore",
548
+ "type": "measure"
549
+ },
550
+ {
551
+ "child": {
552
+ "compression": "none",
553
+ "path": "datastore",
554
+ "type": "levelds"
555
+ },
556
+ "mountpoint": "/",
557
+ "prefix": "leveldb.datastore",
558
+ "type": "measure"
559
+ }
560
],
561
"type": "mount"
562
}
@@ -1145,7 +1147,7 @@ Example:
1147
"API" : {
1148
"Endpoint" : "https://pinningservice.tld:1234/my/api/path",
1149
"Key" : "someOpaqueKey"
1148
- }
1150
+ }
1151
}
1152
}
1153
}
@@ -2439,18 +2441,30 @@ This profile may only be applied when first initializing the node.
2441
2442
### `lowpower` profile
2443
2442
-Reduces daemon overhead on the system. Affects node
2443
-functionality - performance of content discovery and data
2444
-fetching may be degraded.
2445
-
2446
-> [!CAUTION]
2447
-> Local data won't be announced on routing systems like Amino DHT.
2444
+Reduces daemon overhead on the system by disabling optional swarm services.
2445
2446
+- [`Routing.Type`](#routingtype) set to `autoclient` (no DHT server, only client).
2447
- `Swarm.ConnMgr` set to maintain minimum number of p2p connections at a time.
2450
-- Disables [`Reprovider`](#reprovider) service → no CID will be announced on Amino DHT and other routing systems(!)
2448
- Disables [`AutoNAT`](#autonat).
2449
+- Disables [`Swam.RelayService`](#swarmrelayservice).
2450
+
2451
+> [!NOTE]
2452
+> This profile is provided for legacy reasons.
2453
+> With modern Kubo setting the above should not be necessary.
2454
+
2455
+### `announce-off` profile
2456
+
2457
+Disables [Reprovider](#reprovider) system (and announcing to Amino DHT).
2458
+
2459
+> [!CAUTION]
2460
+> The main use case for this is setups with manual Peering.Peers config.
2461
+> Data from this node will not be announced on the DHT. This will make
2462
+> DHT-based routing an data retrieval impossible if this node is the only
2463
+> one hosting it, and other peers are not already connected to it.
2464
+
2465
+### `announce-on` profile
2466
2453
-Use this profile with caution.
2467
+(Re-)enables [Reprovider](#reprovider) system (reverts [`announce-off` profile](#annouce-off-profile).
2468
2469
### `legacy-cid-v0` profile
2470