feat(registry): migrate runtime service metadata - #2048
Conversation
There was a problem hiding this comment.
Pull request overview
This PR migrates the tracker’s runtime service registrations from torrust-server-lib 0.1.x raw registry access to torrust-server-lib 0.2.0’s immutable typed metadata and snapshot/query APIs, then updates health reporting and integration-test endpoint discovery to use canonical role/identity instead of bind-IP conventions or timing heuristics.
Changes:
- Upgrades workspace consumers to
torrust-server-lib = "0.2.0"and switches registrations toServiceRegistrationForm<RuntimeServiceMetadata>with acknowledgedregister().await. - Introduces
RuntimeServiceMetadata(derived role from canonicalConfigurationInstanceId) and propagates it through HTTP/UDP/REST/health registrations. - Reworks integration-test readiness and endpoint discovery helpers to wait for and query by canonical identities/roles (including new port-zero identity-to-final-binding coverage).
Reviewed changes
Copilot reviewed 35 out of 36 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/scaffold.rs | Updates test-module documentation to describe registry-ack readiness and snapshot-based endpoint discovery. |
| tests/common/workspace.rs | Replaces size/delay-based readiness and bind-IP endpoint classification with identity/role snapshot queries; adds service_binding_for_identity. |
| tests/common/mod.rs | Re-exports the new service_binding_for_identity helper. |
| tests/aggregate_stats_port_zero.rs | Adds regression test ensuring repeated port-zero instances retain canonical identity and resolve to distinct non-zero final bindings. |
| src/container.rs | Makes registar typed (Registar<RuntimeServiceMetadata>) and returns canonical identity alongside tracker containers. |
| src/bootstrap/jobs/udp_tracker.rs | Threads typed registration form + runtime metadata into UDP job startup. |
| src/bootstrap/jobs/tracker_apis.rs | Threads typed registration form + runtime metadata into REST API startup; updates unit test accordingly. |
| src/bootstrap/jobs/http_tracker.rs | Threads typed registration form + runtime metadata into HTTP tracker startup; updates unit test accordingly. |
| src/bootstrap/jobs/health_check_api.rs | Switches health API wiring from raw registry to typed Registar; registers health API metadata after bind/start. |
| src/app.rs | Propagates canonical ConfigurationInstanceId into runtime metadata at service startup; passes typed registar into health-check API job. |
| project-words.txt | Adds addext to the spell-check dictionary. |
| packages/udp-server/src/testing/environment.rs | Updates UDP server test environment to use typed registar + runtime metadata. |
| packages/udp-server/src/server/states.rs | Migrates UDP server registration from send(...) to acknowledged register(...).await with typed metadata. |
| packages/udp-server/src/server/mod.rs | Updates UDP server tests to use typed registar + runtime metadata. |
| packages/udp-server/src/server/launcher.rs | Adapts health-check job construction to torrust-server-lib 0.2.0 API. |
| packages/udp-server/Cargo.toml | Upgrades torrust-server-lib dependency to 0.2.0. |
| packages/primitives/src/runtime_service_metadata.rs | Adds new typed immutable metadata wrapper over ConfigurationInstanceId with derived role. |
| packages/primitives/src/lib.rs | Exposes the new runtime_service_metadata module and re-exports RuntimeServiceMetadata. |
| packages/axum-server/Cargo.toml | Upgrades torrust-server-lib dependency to 0.2.0. |
| packages/axum-rest-api-server/src/testing/environment.rs | Updates REST API test environment to pass typed metadata during registration. |
| packages/axum-rest-api-server/src/server.rs | Migrates REST API registration to typed metadata + acknowledged registration; adapts health-check job API. |
| packages/axum-rest-api-server/Cargo.toml | Upgrades torrust-server-lib dependency to 0.2.0. |
| packages/axum-http-server/src/testing/environment.rs | Updates HTTP server test environment to pass typed metadata during registration. |
| packages/axum-http-server/src/server.rs | Migrates HTTP tracker registration to typed metadata + acknowledged registration; adapts health-check job API. |
| packages/axum-http-server/Cargo.toml | Upgrades torrust-server-lib dependency to 0.2.0. |
| packages/axum-health-check-api-server/tests/server/contract.rs | Strengthens health JSON contract assertions to include service_binding and service_type compatibility. |
| packages/axum-health-check-api-server/src/server.rs | Switches server state from raw registry type to typed Registar<RuntimeServiceMetadata>. |
| packages/axum-health-check-api-server/src/handlers.rs | Builds reports from deterministic registry snapshots + metadata-derived service type, combining optional check execution results. |
| packages/axum-health-check-api-server/src/environment.rs | Updates health-check API test environment to use typed registar. |
| packages/axum-health-check-api-server/Cargo.toml | Adds torrust-tracker-primitives dep and upgrades torrust-server-lib to 0.2.0. |
| docs/issues/open/2041-migrate-runtime-service-registry-metadata/ISSUE.md | Updates implementation plan/progress and verification tracking for #2041. |
| docs/issues/open/2041-migrate-runtime-service-registry-metadata/evidence.md | Records automated/manual verification evidence for the migration, including port-zero scenarios. |
| docs/issues/drafts/fix-https-tracker-health-check-protocol.md | Adds a draft follow-up issue spec documenting the pre-existing HTTPS probe scheme mismatch. |
| Cargo.toml | Upgrades workspace torrust-server-lib dependency to 0.2.0. |
| Cargo.lock | Lockfile updates reflecting the torrust-server-lib 0.2.0 upgrade and resolved dependency graph changes. |
| .github/skills/dev/environment-setup/run-tracker-locally/SKILL.md | Documents a reusable local TLS workflow and notes the known aggregate HTTPS health-check limitation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2048 +/- ##
===========================================
+ Coverage 82.01% 82.10% +0.08%
===========================================
Files 348 348
Lines 24795 24828 +33
Branches 24795 24828 +33
===========================================
+ Hits 20336 20384 +48
+ Misses 4148 4139 -9
+ Partials 311 305 -6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 36 out of 37 changed files in this pull request and generated no new comments.
Suppressed comments (2)
tests/common/workspace.rs:139
http_api_urluses the canonicalServiceRole::RestApi, but it still constructs the client URL vialoopback_url(SocketAddr), which hard-codeshttp://. If the REST API is configured with TLS (HTTPS), this will return the wrong scheme and make tests/probes fail.
tests/common/workspace.rs:106http_tracker_urlsnow selects services byServiceRole::HttpTracker, which (per #2041 design) includes both HTTP and HTTPS registrations. Building URLs vialoopback_url(SocketAddr)hard-codes thehttp://scheme, so an HTTPS tracker would be returned ashttp://127.0.0.1:<tls-port>/...and clients/tests would probe the wrong protocol.
This issue also appears on line 135 of the same file.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 36 out of 37 changed files in this pull request and generated no new comments.
Suppressed comments (1)
.github/skills/dev/logging/structured-runtime-logging/SKILL.md:43
- The logging skill’s “Correct Form” example uses
%service_binding.url(), but the implementation in this PR logs theServiceBindingitself (e.g.,tracing::info!(service_binding = %service_binding, ...)). This makes the skill inconsistent with the codebase and also makes the example output below internally inconsistent.
Recommendation: adjust the example to log service_binding = %service_binding (and update the sample output accordingly, likely including the trailing / for HTTP URLs if that’s how ServiceBinding displays).
```rust
tracing::info!(
service_binding = %service_binding.url(),
"Started HTTP tracker"
);
|
ACK b0bc51e |
Summary
Migrates tracker runtime service registrations to
torrust-server-lib0.2.0 immutable typed metadata and deterministic snapshot queries.ConfigurationInstanceIdthrough HTTP(S), UDP, REST API, and health API registrations.RuntimeServiceMetadataroles from the canonical identity, preventing mismatched role/identity state.Validation
TORRUST_GIT_HOOKS_LOG_DIR=.tmp ./contrib/dev-tools/git/hooks/pre-commit.shFollow-up
A draft issue documents the pre-existing aggregate HTTPS health-check protocol defect separately. It is out of scope for this registry-metadata migration.
Closes #2041