Repository navigation
feat(configuration): activate v3 runtime configuration - #2103
Conversation
78b1650 to
9aed035
Compare
There was a problem hiding this comment.
Pull request overview
This PR completes the final “configuration v3” runtime activation work for the tracker, removing legacy schema root re-exports, switching runtime/bootstrap to v3_0_0 configuration types, and updating templates/tests/docs to the v3 TOML schema and listener-scoped policies.
Changes:
- Activate v3 runtime configuration wiring across the application/bootstrap, and migrate consumers to explicit
torrust_tracker_configuration::v3_0_0::*imports. - Update shipped configuration templates, tests, examples/benches, and docs to v3 keys (
trace_filter,trace_style, new[udp_tracker_server], per-listenernetwork, etc.). - Add/extend coverage for listener order independence and shared UDP connection-id error budgeting; refine HTTP/UDP listener policy wiring (reverse proxy, query-IP, external IP).
Reviewed changes
Copilot reviewed 101 out of 102 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/scaffold.rs | Update test config to v3 keys |
| tests/metrics/fixed_ports.rs | Update fixture config to v3 keys |
| tests/common/workspace.rs | Allow unused helper in tests |
| tests/common/mod.rs | Re-export new UDP helper |
| tests/common/configuration.rs | Update fixture config to v3 keys |
| tests/banning/udp_shared_connection_id_error_limit.rs | New integration test for shared UDP limit |
| tests/banning/udp_shared_connection_id_error_limit_reverse_order.rs | New reverse-order integration test |
| src/container.rs | Switch runtime container to v3 config + bridge |
| src/console/ci/qbittorrent_e2e/tracker/config_builder.rs | Build v3 config for qBittorrent E2E |
| src/bootstrap/jobs/udp_tracker.rs | Pass connection-id policy into UDP job |
| src/bootstrap/jobs/udp_tracker_server.rs | Parameterize ban reset interval |
| src/bootstrap/jobs/udp_tracker_core.rs | Import v3 Configuration |
| src/bootstrap/jobs/tracker_core.rs | Import v3 Configuration |
| src/bootstrap/jobs/tracker_apis.rs | Use v3 API token types; fix tls_config typo |
| src/bootstrap/jobs/torrent_repository.rs | Import v3 Configuration |
| src/bootstrap/jobs/torrent_cleanup.rs | Import v3 Core |
| src/bootstrap/jobs/http_tracker.rs | Fix tls_config + per-listener ipv6_v6only |
| src/bootstrap/jobs/http_tracker_core.rs | Import v3 Configuration |
| src/bootstrap/jobs/health_check_api.rs | Import v3 HealthCheckApi |
| src/bootstrap/jobs/activity_metrics_updater.rs | Import v3 Configuration |
| src/bootstrap/config.rs | Load v3 config + template load tests |
| src/bootstrap/app.rs | Use v3 Configuration/logging modules |
| src/app.rs | Wire v3 UDP server policies + mapping |
| share/default/config/tracker.udp.benchmarking.toml | Migrate template to v3 schema |
| share/default/config/tracker.e2e.container.sqlite3.toml | Migrate template to v3 schema |
| share/default/config/tracker.development.sqlite3.toml | Migrate template to v3 schema |
| share/default/config/tracker.container.sqlite3.toml | Migrate template to v3 schema |
| share/default/config/tracker.container.postgresql.toml | Migrate template to v3 schema |
| share/default/config/tracker.container.mysql.toml | Migrate template to v3 schema |
| README.md | Update documented default bind addresses |
| packages/udp-server/tests/server/contract.rs | Update per-listener ipv6_v6only path |
| packages/udp-server/src/testing/environment.rs | Derive validation policy from v3 server config |
| packages/udp-server/src/server/mod.rs | Use v3 config/logging in tests |
| packages/udp-server/src/server/launcher.rs | Use per-listener network.ipv6_v6only |
| packages/udp-server/src/handlers/mod.rs | Per-listener external IP wiring in tests |
| packages/udp-server/src/handlers/announce.rs | Listener-scoped external IP test updates |
| packages/udp-server/src/container.rs | Import v3 Core |
| packages/udp-server/examples/udp_only_public_tracker.rs | Update example to v3 types |
| packages/udp-core/src/services/announce.rs | Pass listener external IP into handler |
| packages/udp-core/src/container.rs | v3 types; external IP wiring |
| packages/tracker-core/tests/common/test_env.rs | Update handle_announcement signature usage |
| packages/tracker-core/tests/common/fixtures.rs | Update optional database handling in tests |
| packages/tracker-core/src/whitelist/test_helpers.rs | Import v3 Configuration |
| packages/tracker-core/src/whitelist/manager.rs | Import v3 Core |
| packages/tracker-core/src/whitelist/authorization.rs | Import v3 Core |
| packages/tracker-core/src/torrent/manager.rs | Import v3 Core |
| packages/tracker-core/src/test_helpers.rs | Update optional database setup helpers |
| packages/tracker-core/src/lib.rs | Update handle_announcement calls (new arg) |
| packages/tracker-core/src/databases/setup.rs | Switch to v3 Database enum + URL builder |
| packages/tracker-core/src/databases/driver/sqlite/mod.rs | Update tests for optional database |
| packages/tracker-core/src/databases/driver/postgres/mod.rs | Build v3 DB config with secrecy password |
| packages/tracker-core/src/databases/driver/mysql/mod.rs | Build v3 DB config with secrecy password |
| packages/tracker-core/src/container.rs | Accept Option<&Database> for persistence |
| packages/tracker-core/src/authentication/service.rs | Import v3 Core |
| packages/tracker-core/src/authentication/mod.rs | Import v3 Configuration |
| packages/tracker-core/src/authentication/key/repository/persisted.rs | Update optional DB config in tests |
| packages/tracker-core/src/authentication/handler.rs | Import v3 Configuration |
| packages/tracker-core/src/announce_handler.rs | Add per-listener external IP parameter |
| packages/tracker-core/Cargo.toml | Add dev-dep secrecy |
| packages/tracker-client/src/udp/client.rs | Make UdpClient clonable |
| packages/test-helpers/src/udp.rs | Add multi-listener invalid connection-id helper |
| packages/test-helpers/src/logging.rs | Use v3 TraceStyle variants |
| packages/test-helpers/src/configuration.rs | Update ephemeral v3 configs (network/db) |
| packages/rest-api-runtime-adapter/src/v1/container.rs | Use v3 config types; optional DB |
| packages/persistence-benchmark/src/bin/persistence_benchmark/driver_bench/database/sqlite.rs | Use v3 DB enum for benches |
| packages/persistence-benchmark/src/bin/persistence_benchmark/driver_bench/database/postgres.rs | Use v3 DB enum + secrecy password |
| packages/persistence-benchmark/src/bin/persistence_benchmark/driver_bench/database/mysql.rs | Use v3 DB enum + secrecy password |
| packages/persistence-benchmark/Cargo.toml | Add secrecy dependency |
| packages/http-core/src/services/scrape.rs | Use per-listener reverse-proxy policy |
| packages/http-core/src/services/announce.rs | Use per-listener reverse-proxy/query-IP/external-IP |
| packages/http-core/src/container.rs | Use v3 types; instantiate services with listener config |
| packages/http-core/benches/helpers/util.rs | Import v3 config types |
| packages/configuration/src/v3_0_0/database.rs | Add v3 Database::connection_url() |
| packages/configuration/src/v2_0_0/mod.rs | Implement Default for v2 Configuration |
| packages/configuration/src/lib.rs | Remove root re-exports; set LATEST_VERSION=3.0.0 |
| packages/axum-server/src/tls.rs | Fix TslConfig→TlsConfig type |
| packages/axum-rest-api-server/src/v1/middlewares/auth.rs | Update docs + types to v3 HttpApi |
| packages/axum-rest-api-server/src/testing/environment.rs | Fix tls_config field name |
| packages/axum-rest-api-server/src/server.rs | Fix tls_config field name; v3 AccessTokens |
| packages/axum-rest-api-server/src/routes.rs | v3 AccessTokens |
| packages/axum-rest-api-server/src/lib.rs | Fix docs links for v3 tls_config |
| packages/axum-http-server/tests/server/v1/contract/using_ipv6_v6only.rs | Update per-listener ipv6_v6only path |
| packages/axum-http-server/tests/server/v1/contract/for_all_config_modes/receiving_an_announce_request.rs | Use per-listener external IP |
| packages/axum-http-server/src/v1/handlers/scrape.rs | Build scrape service from listener config |
| packages/axum-http-server/src/v1/handlers/announce.rs | Build announce service from listener config |
| packages/axum-http-server/src/v1/extractors/client_ip_sources.rs | Update docs link for v3 config |
| packages/axum-http-server/src/testing/environment.rs | Fix tls_config + per-listener ipv6_v6only |
| packages/axum-http-server/src/server.rs | Fix tls_config + per-listener ipv6_v6only |
| packages/axum-http-server/examples/http_only_public_tracker.rs | Update example to v3 types |
| packages/axum-health-check-api-server/tests/server/contract.rs | Fix TslConfig→TlsConfig in tests |
| packages/axum-health-check-api-server/src/environment.rs | Import v3 HealthCheckApi |
| docs/issues/open/999-1978-optional-database-configuration/ISSUE.md | Update progress log timestamp |
| docs/issues/open/1987-add-config-option-to-use-ip-from-announce-query-string/manual-verification.md | Record Phase 3 enabled-v3 evidence |
| docs/issues/open/1987-add-config-option-to-use-ip-from-announce-query-string/ISSUE.md | Mark enabled-v3 verification done |
| docs/issues/open/1980-1978-configuration-overhaul-final-cleanup.md | Mark tasks complete + in_review |
| docs/issues/open/1978-configuration-overhaul-epic/EPIC.md | Update epic statuses after #1980 |
| docs/issues/open/1978-configuration-overhaul-epic/configuration-v2-to-v3-migration.md | Complete v2→v3 migration guide |
| docs/issues/closed/889-1978-new-config-option-for-logging-style.md | Record deferred manual verification complete |
| docs/benchmarking.md | Update benchmarking config snippet to v3 |
| contrib/dev-tools/analysis/workspace-coupling/tests/parse_imports.rs | Update expected imports to v3 paths |
| Cargo.toml | Register new integration tests; add secrecy dep |
| Cargo.lock | Lockfile updates for added deps |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
josecelano
left a comment
There was a problem hiding this comment.
Implemented and pushed the review fixes in 1b4ff141ffad2e4fc3b066d3266aa6acb9a3cbc2 (fix(configuration): address v3 activation review feedback). The changes preserve explicit v3 database configuration, percent-encode network database DSNs, and propagate the global UDP connection-ID error limit. Focused tests and the mandatory pre-commit gate pass.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #2103 +/- ##
===========================================
+ Coverage 83.94% 84.08% +0.14%
===========================================
Files 350 349 -1
Lines 26686 27239 +553
Branches 26686 27239 +553
===========================================
+ Hits 22401 22904 +503
- Misses 3954 3994 +40
- Partials 331 341 +10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
ACK 7f88386 |
f33706b docs(review): record resolved PR 2108 suggestion (Jose Celano) 8a5fa28 docs(issues): link #2107 persistence activation (Jose Celano) bb18ca7 docs(issues): add specification for #2107 (Jose Celano) Pull request description: ## Summary - add the approved specification for #2107, persistence-free v3 runtime composition - record #2107 as a native subissue of configuration-overhaul EPIC #1978 - update the EPIC delivery graph and #1980 status after PR #2103 merged ## Scope Documentation only: the implementation of persistence-free composition, capability-aware REST API responses, and container behavior is intentionally not included. ## Validation - installed pre-commit hook: `cargo machete --with-metadata`, `cargo deny check bans`, `linter all`, and `cargo test --doc --workspace` - `git diff --check` Related to #2107 ACKs for top commit: josecelano: ACK f33706b Tree-SHA512: b08c548812f5dd78188066a581fbbe7cb357d3ca377e73239d3e427a6ae63c6652b419dd9c1fd4faf96ec1b9a8990bec44a9317ba223cad6b3d5e1e4f2fb5ac0
da2ce7
left a comment
There was a problem hiding this comment.
This is a post-merge review of the change from #2103 as it stands at a94c3ced8 on the default branch.
Most of what #2103 activated still runs. The tracker loads only the v3 schema (src/bootstrap/config.rs:45). The UDP connection-ID validation policy, the shared max_connection_id_errors_per_ip limit and the IP-ban reset interval come from [udp_tracker_server] (src/app.rs:535, src/app.rs:664, src/container.rs:108). Each HTTP and UDP listener applies its own external_ip and reverse-proxy setting (packages/http-core/src/services/announce.rs:96, packages/udp-core/src/container.rs:122). Network databases are configured by component fields that are assembled into a percent-encoded URL (packages/configuration/src/v3_0_0/database.rs:66). The shipped templates are v3, and a test loads each of them (src/bootstrap/config.rs:285). The fixed-SQLite fallback that #2103 added to the application container was removed by 8e97678, and the panics in database setup became typed errors in 56ea123, so neither is raised here.
[Minor] The network database host is accepted without validation (packages/configuration/src/v3_0_0/database.rs:215) and passed to Url::set_host, and a failure there becomes a panic (packages/configuration/src/v3_0_0/database.rs:80). With url 2.5.9, a host that is not bracketed is cut at its first colon. As a result, host = "::1" panics at startup with "database hosts must be representable in a URL", host = "2001:db8::10" silently becomes the URL host 2001, and host = "db.example:3307" silently loses :3307 and connects on the port value instead. A host that contains a space or another forbidden host character also panics. The panic skips the typed composition error that startup otherwise reports (src/container.rs:93). Smallest fix: validate host in build_network_database (reject empty values, whitespace and colons outside a bracketed IPv6 literal, or accept a bare IPv6 literal and add the brackets), and have connection_url return a Result that initialize_database_from_configuration maps into its error type.
[Minor] HttpTrackerCoreContainer::initialize still substitutes Database::default() when core.database is omitted (packages/http-core/src/container.rs:45). For a configuration that the application now runs without persistence (src/container.rs:90, since 8e97678), this public constructor therefore opens and creates SQLite at ./storage/tracker/lib/database/sqlite3.db relative to the working directory, and it panics if that directory does not exist. The UDP counterpart passes the optional database through unchanged (packages/udp-core/src/container.rs:57), so the two package entry points disagree on the same configuration. Smallest fix: pass core_config.database.as_ref() as the UDP container does, and update the doc comment and the expect message beside it.
[Minor] The description says #2103 removes the root logging module, and docs/issues/closed/1980-1978-configuration-overhaul-final-cleanup/ISSUE.md:258 records packages/configuration/src/logging.rs as deleted. In fact #2103 only removed the pub mod logging; declaration. The file is still in the tree, and because it is not compiled, no build, lint or test checks it. Two open issue records already plan work against it as if it were live code (docs/issues/open/2766-2758-daemon-json-logging/ISSUE.md:73, docs/issues/open/2993-secrets-and-client-error-text/EPIC.md:90). Smallest fix: delete the file and correct those three records.
[Minor] The database section of the migration guide says v3 removes the need to percent-encode the password, but it does not tell operators to decode a password they already encoded (packages/configuration/docs/migrate-v2-to-v3.md:264). The v2 MySQL and PostgreSQL templates told operators to do exactly that (a+b/c -> a%2Bb%2Fc). If such a password is copied from a v2 URL into the v3 password field, connection_url encodes it a second time, the server receives the literal a%2Bb%2Fc, and startup fails with an authentication error. The same sentence also calls the replaced field the v3 path field, when it is the v2 one. Smallest fix: add one sentence telling operators to percent-decode the user, password and database name when they move them out of a v2 URL, and change v3 to v2.
[Nit] The doc comment of initialize_database still says the driver is chosen by config.database.driver, is "either Sqlite3 or MySQL", and connects through config.database.path (packages/tracker-core/src/databases/setup.rs:49). V3 has neither field and also supports PostgreSQL. In the same file, lines 119 and 125 rebuild a Database by cloning the connection, password included, only to call connection_url, which database.connection_url() already provides.
[Nit] connection_url is public and returns the URL, credentials included, as a plain String (packages/configuration/src/v3_0_0/database.rs:66). The password therefore leaves the SecretString wrapper that the type's redacting Serialize relies on, and it sits in an ordinary string that any caller can log. Returning a SecretString and exposing it only at the Mysql::new and Postgres::new calls keeps the redaction in place.
[Nit] The loopback-to-external-IP substitution exists twice. HTTP applies it in packages/http-core/src/services/announce.rs:293 and then passes None to handle_announcement (line 224). UDP relies on packages/tracker-core/src/announce_handler.rs:292. The parameter doc at packages/tracker-core/src/announce_handler.rs:164 says tracker_external_ip carries the listener's external IP, which is never the case on the HTTP path, and the two copies already differ: only the core one guards against an unspecified address. Smallest fix: say in that parameter doc that HTTP callers resolve the external IP before the call and pass None.
Checked and found sound: v3-only loading with typed load errors in src/bootstrap/config.rs; the exhaustive mapping of the connection-ID validation policy and the per-listener UDP startup in src/app.rs; the IP-ban reset interval, whose type enforces a one-hour minimum, so the cleanup timer can never get a zero period; the single shared connection-ID error limit and its two integration tests with the listener order reversed (tests/banning/udp_shared_connection_id_error_limit*.rs); the per-listener reverse-proxy and external-IP policies in the HTTP announce and scrape services; the v2 Default keeping schema version 2.0.0 (packages/configuration/src/v2_0_0/mod.rs); the import-only changes under packages/tracker-core/src/authentication/; the test-only changes to the database drivers; and the templates in share/default/config/.
Summary
Implements #1980 by activating v3 configuration at runtime while completing the final configuration-overhaul cleanup.
v3_0_0imports.Deferred follow-up and manual evidence
ipGET parameter (sub-issue of #1978) #1987 is recorded indocs/issues/open/1987-add-config-option-to-use-ip-from-announce-query-string/manual-verification.md.[core.database]; a later follow-up will support persistence-free runtime composition.Verification
linter allcargo test --workspacecargo test --doc --workspacecargo machetegit diff --checkThis is a draft pending the deferred logging evidence.