mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
feat(provider): info log AcceleratedDHTClient crawl (#11143)
Some checks are pending
CodeQL / codeql (push) Waiting to run
Docker Check / lint (push) Waiting to run
Docker Check / build (push) Waiting to run
Gateway Conformance / gateway-conformance (push) Waiting to run
Gateway Conformance / gateway-conformance-libp2p-experiment (push) Waiting to run
Go Build / go-build (push) Waiting to run
Go Check / go-check (push) Waiting to run
Go Lint / go-lint (push) Waiting to run
Go Test / unit-tests (push) Waiting to run
Go Test / cli-tests (push) Waiting to run
Go Test / example-tests (push) Waiting to run
Interop / interop-prep (push) Waiting to run
Interop / helia-interop (push) Blocked by required conditions
Interop / ipfs-webui (push) Blocked by required conditions
Sharness / sharness-test (push) Waiting to run
Spell Check / spellcheck (push) Waiting to run
Some checks are pending
CodeQL / codeql (push) Waiting to run
Docker Check / lint (push) Waiting to run
Docker Check / build (push) Waiting to run
Gateway Conformance / gateway-conformance (push) Waiting to run
Gateway Conformance / gateway-conformance-libp2p-experiment (push) Waiting to run
Go Build / go-build (push) Waiting to run
Go Check / go-check (push) Waiting to run
Go Lint / go-lint (push) Waiting to run
Go Test / unit-tests (push) Waiting to run
Go Test / cli-tests (push) Waiting to run
Go Test / example-tests (push) Waiting to run
Interop / interop-prep (push) Waiting to run
Interop / helia-interop (push) Blocked by required conditions
Interop / ipfs-webui (push) Blocked by required conditions
Sharness / sharness-test (push) Waiting to run
Spell Check / spellcheck (push) Waiting to run
* feat(provider): log fullrt crawl * fix(provider): improve AcceleratedDHTClient log messages use config option name instead of internal "fullrt" jargon, align terminology with daemon startup message, add time estimate --------- Co-authored-by: Marcin Rataj <lidel@lidel.org>
This commit is contained in:
parent
4bdc9ad220
commit
698354342e
@ -16,6 +16,7 @@ import (
|
||||
"github.com/ipfs/go-datastore"
|
||||
"github.com/ipfs/go-datastore/namespace"
|
||||
"github.com/ipfs/go-datastore/query"
|
||||
log "github.com/ipfs/go-log/v2"
|
||||
"github.com/ipfs/kubo/config"
|
||||
"github.com/ipfs/kubo/repo"
|
||||
irouting "github.com/ipfs/kubo/routing"
|
||||
@ -53,6 +54,8 @@ const (
|
||||
keystoreDatastorePath = "keystore"
|
||||
)
|
||||
|
||||
var errAcceleratedDHTNotReady = errors.New("AcceleratedDHTClient: routing table not ready")
|
||||
|
||||
// Interval between reprovide queue monitoring checks for slow reprovide alerts.
|
||||
// Used when Provide.DHT.SweepEnabled=true
|
||||
const reprovideAlertPollInterval = 15 * time.Minute
|
||||
@ -325,13 +328,34 @@ type dhtImpl interface {
|
||||
|
||||
type fullrtRouter struct {
|
||||
*fullrt.FullRT
|
||||
ready bool
|
||||
logger *log.ZapEventLogger
|
||||
}
|
||||
|
||||
func newFullRTRouter(fr *fullrt.FullRT, loggerName string) *fullrtRouter {
|
||||
return &fullrtRouter{
|
||||
FullRT: fr,
|
||||
ready: true,
|
||||
logger: log.Logger(loggerName),
|
||||
}
|
||||
}
|
||||
|
||||
// GetClosestPeers overrides fullrt.FullRT's GetClosestPeers and returns an
|
||||
// error if the fullrt's initial network crawl isn't complete yet.
|
||||
func (fr *fullrtRouter) GetClosestPeers(ctx context.Context, key string) ([]peer.ID, error) {
|
||||
if !fr.Ready() {
|
||||
return nil, errors.New("fullrt: initial network crawl still running")
|
||||
if fr.ready {
|
||||
if !fr.Ready() {
|
||||
fr.ready = false
|
||||
fr.logger.Info("AcceleratedDHTClient: waiting for routing table initialization (5-10 min, depends on DHT size and network) to complete before providing")
|
||||
return nil, errAcceleratedDHTNotReady
|
||||
}
|
||||
} else {
|
||||
if fr.Ready() {
|
||||
fr.ready = true
|
||||
fr.logger.Info("AcceleratedDHTClient: routing table ready, providing can begin")
|
||||
} else {
|
||||
return nil, errAcceleratedDHTNotReady
|
||||
}
|
||||
}
|
||||
return fr.FullRT.GetClosestPeers(ctx, key)
|
||||
}
|
||||
@ -382,6 +406,9 @@ func SweepingProviderOpt(cfg *config.Config) fx.Option {
|
||||
// provides happen as fast as possible via a dedicated worker that continuously
|
||||
// processes the queue regardless of this timing.
|
||||
bufferedIdleWriteTime = time.Minute
|
||||
|
||||
// loggerName is the name of the go-log logger used by the provider.
|
||||
loggerName = dhtprovider.DefaultLoggerName
|
||||
)
|
||||
|
||||
bufferedProviderOpts := []buffered.Option{
|
||||
@ -411,6 +438,8 @@ func SweepingProviderOpt(cfg *config.Config) fx.Option {
|
||||
ddhtprovider.WithDedicatedPeriodicWorkers(int(cfg.Provide.DHT.DedicatedPeriodicWorkers.WithDefault(config.DefaultProvideDHTDedicatedPeriodicWorkers))),
|
||||
ddhtprovider.WithDedicatedBurstWorkers(int(cfg.Provide.DHT.DedicatedBurstWorkers.WithDefault(config.DefaultProvideDHTDedicatedBurstWorkers))),
|
||||
ddhtprovider.WithMaxProvideConnsPerWorker(int(cfg.Provide.DHT.MaxProvideConnsPerWorker.WithDefault(config.DefaultProvideDHTMaxProvideConnsPerWorker))),
|
||||
|
||||
ddhtprovider.WithLoggerName(loggerName),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@ -419,7 +448,7 @@ func SweepingProviderOpt(cfg *config.Config) fx.Option {
|
||||
}
|
||||
case *fullrt.FullRT:
|
||||
if inDht != nil {
|
||||
impl = &fullrtRouter{inDht}
|
||||
impl = newFullRTRouter(inDht, loggerName)
|
||||
}
|
||||
}
|
||||
if impl == nil {
|
||||
@ -454,6 +483,8 @@ func SweepingProviderOpt(cfg *config.Config) fx.Option {
|
||||
dhtprovider.WithDedicatedPeriodicWorkers(int(cfg.Provide.DHT.DedicatedPeriodicWorkers.WithDefault(config.DefaultProvideDHTDedicatedPeriodicWorkers))),
|
||||
dhtprovider.WithDedicatedBurstWorkers(int(cfg.Provide.DHT.DedicatedBurstWorkers.WithDefault(config.DefaultProvideDHTDedicatedBurstWorkers))),
|
||||
dhtprovider.WithMaxProvideConnsPerWorker(int(cfg.Provide.DHT.MaxProvideConnsPerWorker.WithDefault(config.DefaultProvideDHTMaxProvideConnsPerWorker))),
|
||||
|
||||
dhtprovider.WithLoggerName(loggerName),
|
||||
}
|
||||
|
||||
prov, err := dhtprovider.New(opts...)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user