kubo/repo/fsrepo/migrations/fs-repo-17-to-18/main.go
Marcin Rataj 71e883440e
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 / go-test (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
refactor(config): migration 17-to-18 to unify Provider/Reprovider into Provide.DHT (#10951)
* refactor: consolidate Provider/Reprovider into unified Provide config

- merge Provider and Reprovider configs into single Provide section
- add fs-repo-17-to-18 migration for config consolidation
- improve migration ergonomics with common package utilities
- convert deprecated "flat" strategy to "all" during migration
- improve Provide docs

* docs: add total_provide_count metric guidance

- document how to monitor provide success rates via prometheus metrics
- add performance comparison section to changelog
- explain how to evaluate sweep vs legacy provider effectiveness

* fix: add OpenTelemetry meter provider for metrics

- set up meter provider with Prometheus exporter in daemon
- enables metrics from external libs like go-libp2p-kad-dht
- fixes missing total_provide_count_total when SweepEnabled=true
- update docs to reflect actual metric names

---------

Co-authored-by: gammazero <11790789+gammazero@users.noreply.github.com>
Co-authored-by: guillaumemichel <guillaume@michel.id>
Co-authored-by: Daniel Norman <1992255+2color@users.noreply.github.com>
Co-authored-by: Hector Sanjuan <code@hector.link>
2025-09-18 22:17:43 +02:00

61 lines
1.6 KiB
Go

// Package main implements fs-repo-17-to-18 migration for IPFS repositories.
//
// This migration consolidates the Provider and Reprovider configurations into
// a unified Provide configuration section.
//
// Changes made:
// - Migrates Provider.Enabled to Provide.Enabled
// - Migrates Provider.WorkerCount to Provide.DHT.MaxWorkers
// - Migrates Reprovider.Strategy to Provide.Strategy (converts "flat" to "all")
// - Migrates Reprovider.Interval to Provide.DHT.Interval
// - Removes deprecated Provider and Reprovider sections
//
// The migration is reversible and creates config.17-to-18.bak for rollback.
//
// Usage:
//
// fs-repo-17-to-18 -path /path/to/ipfs/repo [-verbose] [-revert]
//
// This migration is embedded in Kubo and runs automatically during daemon startup.
// This standalone binary is provided for manual migration scenarios.
package main
import (
"flag"
"fmt"
"os"
"github.com/ipfs/kubo/repo/fsrepo/migrations/common"
mg17 "github.com/ipfs/kubo/repo/fsrepo/migrations/fs-repo-17-to-18/migration"
)
func main() {
var path = flag.String("path", "", "Path to IPFS repository")
var verbose = flag.Bool("verbose", false, "Enable verbose output")
var revert = flag.Bool("revert", false, "Revert migration")
flag.Parse()
if *path == "" {
fmt.Fprintf(os.Stderr, "Error: -path flag is required\n")
flag.Usage()
os.Exit(1)
}
opts := common.Options{
Path: *path,
Verbose: *verbose,
}
var err error
if *revert {
err = mg17.Migration.Revert(opts)
} else {
err = mg17.Migration.Apply(opts)
}
if err != nil {
fmt.Fprintf(os.Stderr, "Migration failed: %v\n", err)
os.Exit(1)
}
}