Skip to content

feat(registry): migrate runtime service metadata - #2048

Merged
josecelano merged 9 commits into
torrust:developfrom
josecelano:2041-migrate-runtime-service-registry-metadata
Jul 31, 2026
Merged

feat(registry): migrate runtime service metadata#2048
josecelano merged 9 commits into
torrust:developfrom
josecelano:2041-migrate-runtime-service-registry-metadata

Conversation

@josecelano

Copy link
Copy Markdown
Member

Summary

Migrates tracker runtime service registrations to torrust-server-lib 0.2.0 immutable typed metadata and deterministic snapshot queries.

  • Propagates canonical ConfigurationInstanceId through HTTP(S), UDP, REST API, and health API registrations.
  • Derives RuntimeServiceMetadata roles from the canonical identity, preventing mismatched role/identity state.
  • Replaces Allow multiple integration tests at the main app level #1419 test-helper readiness and endpoint discovery heuristics with exact identity and role queries.
  • Preserves health-report compatibility fields and adds repeated port-zero identity-to-final-binding coverage.
  • Records local HTTP/HTTPS/UDP/REST/health verification and documents a reusable local TLS workflow.

Validation

  • TORRUST_GIT_HOOKS_LOG_DIR=.tmp ./contrib/dev-tools/git/hooks/pre-commit.sh
  • Pre-push checks: nightly format/check/doc and stable all-target tests
  • Focused health API, port-zero, scaffold, and primitive tests
  • Manual local port-zero probes for HTTP, HTTPS, UDP, REST API, and health API

Follow-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

@josecelano
josecelano requested a review from a team as a code owner July 31, 2026 15:34
Copilot AI review requested due to automatic review settings July 31, 2026 15:34
@josecelano josecelano self-assigned this Jul 31, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 to ServiceRegistrationForm<RuntimeServiceMetadata> with acknowledged register().await.
  • Introduces RuntimeServiceMetadata (derived role from canonical ConfigurationInstanceId) 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

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.10%. Comparing base (c1ea423) to head (b0bc51e).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI review requested due to automatic review settings July 31, 2026 16:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_url uses the canonical ServiceRole::RestApi, but it still constructs the client URL via loopback_url(SocketAddr), which hard-codes http://. If the REST API is configured with TLS (HTTPS), this will return the wrong scheme and make tests/probes fail.
    tests/common/workspace.rs:106
  • http_tracker_urls now selects services by ServiceRole::HttpTracker, which (per #2041 design) includes both HTTP and HTTPS registrations. Building URLs via loopback_url(SocketAddr) hard-codes the http:// scheme, so an HTTPS tracker would be returned as http://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.

Copilot AI review requested due to automatic review settings July 31, 2026 17:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the ServiceBinding itself (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"
);

@josecelano

Copy link
Copy Markdown
Member Author

ACK b0bc51e

@josecelano
josecelano merged commit 2b84ac6 into torrust:develop Jul 31, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate runtime service registry metadata

2 participants