Skip to content

mobile-config: serve gateways from dbt tables#1221

Draft
bbalser wants to merge 2 commits into
mainfrom
bbalser/hotspot-inventory-gateways-236a57
Draft

mobile-config: serve gateways from dbt tables#1221
bbalser wants to merge 2 commits into
mainfrom
bbalser/hotspot-inventory-gateways-236a57

Conversation

@bbalser

@bbalser bbalser commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

What

Repoints the mobile-config gateway service to read from the dbt-maintained chain tables instead of the locally-ingested gateways table, and retires the S3 change-report ingestion entirely.

  • Reads now come from dbt.mobile_gateway_inventory (one row per gateway, current state) joined to a local deployment_info cache. info_at_timestamp reads dbt.mobile_hotspot_history (latest version <= query_time).
  • Deleted the hotspot_change_stream and ownership_change_stream daemons + their S3 pollers. The gateways table is left in place (not dropped) so we can roll back to the old code path without data loss — a follow-up migration drops it after soak.
  • tracker.rsDeploymentInfoTracker: the only gateway field the dbt chain tables can't supply is the WiFi (antenna, elevation) pair (not on-chain; only azimuth is). A periodic job bulk-copies it from the metadata DB into a local deployment_info table that reads join against — keeping the metadata DB off the request path.
  • Settings: removed ingest and gateway_stream_start_after; added deployment_info_interval (default 1h).

Why

The dbt models (network-dbt) now maintain gateway state and full change history in Postgres, so mobile-config no longer needs to poll S3 and reconstruct the gateways table itself. mobile-config no longer touches S3.

Reviewer notes

  • Companion dbt models live in network-dbt and must be deployed for this to run: mobile_config.dbt.mobile_gateway_inventory and mobile_config.dbt.mobile_hotspot_history.
  • Rollback: the legacy gateways table is retained; reverting the code restores the old path with data intact.
  • Config change required on deploy: drop ingest / gateway_stream_start_after from the mobile-config config.
  • antenna/elevation are refresh-interval stale and current-only for info_at_timestamp (the metadata DB holds no history for them) — this matches prior behavior, not a regression.
  • metadata_pool stays required regardless: entity, carrier, and sub_dao services still depend on the metadata DB; within the gateway path only the tracker uses it now.

Testing

  • 40 tests pass (DATABASE_URL=… cargo nextest run -p mobile-config -j 1): reworked gateway_db / gateway_service{,_v3,_v4} / gateway_tracker integration tests + new unit tests for hex-location and device-type parsing.
  • cargo clippy -p mobile-config --all-targets clean.

bbalser added 2 commits July 13, 2026 10:10
Repoint the gateway service to read from the dbt-maintained chain tables
(dbt.mobile_gateway_inventory + dbt.mobile_hotspot_history) instead of the
locally-ingested `gateways` table, and retire the S3 change-report ingestion.

- db.rs: all current-state reads now hit dbt.mobile_gateway_inventory joined
  to a local deployment_info cache; info_at_timestamp reads
  dbt.mobile_hotspot_history (latest version <= query_time). device_type is
  parsed from the screaming-snake dbt form and location from asserted_hex.
- Delete hotspot_change_stream and ownership_change_stream daemons and their
  S3 pollers; drop the `gateways` table.
- tracker.rs -> DeploymentInfoTracker: the only field the dbt chain tables
  can't supply is the WiFi (antenna, elevation) pair, so a periodic job bulk-
  copies it from the metadata DB into a local `deployment_info` table that
  reads join against, keeping the metadata DB off the request path.
- settings: drop `ingest` and `gateway_stream_start_after`; add
  `deployment_info_interval`.
- Rework the gateway integration tests to seed the dbt-shaped tables; add unit
  coverage for hex/device-type parsing.

antenna/elevation are refresh-interval stale and current-only for
info_at_timestamp (the metadata DB has no history for them) -- unchanged from
prior behavior. The metadata pool remains required for the entity, carrier,
and sub_dao services regardless.
Don't drop the legacy gateways table in the cutover migration so we can roll
back to the old ingestion code path without data loss. A follow-up migration
can drop it after the dbt-backed path has soaked.
@bbalser
bbalser marked this pull request as draft July 14, 2026 13:18
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.

1 participant