Skip to content

fix(status-page): adopt existing environment monitors - #939

Merged
dviejokfs merged 4 commits into
mainfrom
fix/adopt-legacy-status-monitors
Sep 8, 2026
Merged

fix(status-page): adopt existing environment monitors#939
dviejokfs merged 4 commits into
mainfrom
fix/adopt-legacy-status-monitors

Conversation

@dviejokfs

@dviejokfs dviejokfs commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • adopt the existing reserved environment monitor instead of creating a new managed row
  • preserve the oldest monitor ID and merge duplicate checks/incidents into it
  • carry the deployment health path from .temps.yaml onto that adopted monitor
  • keep custom-named monitors independent and validate project/environment ownership
  • retire the stale 20260904 ownership backup and provide a reversible, append-only reconciliation migration
  • preserve unrelated monitor edits, health-path updates, and explicit path clears across rollback and reapply

Root cause

The is_managed rollout changed environment reconciliation from “reuse the existing environment monitor” to “reuse only an is_managed monitor.” Legacy rows remained unmanaged, so every restart created another reserved-name monitor. Deployment health-path updates then targeted only the replacement row, splitting configuration and uptime history.

The exact {environment} Monitor name is the reserved environment-monitor slot. is_managed now identifies which existing row receives automatic lifecycle and .temps.yaml updates; it is no longer used as a reason to create a duplicate.

Evidence

Runtime service: existing reserved-name monitor is adopted, keeps its ID, receives the deployment/YAML path, and no duplicate is inserted.

cargo test --lib -p temps-status-page ensure_monitor_for_environment_adopts_an_existing_default_name -- --nocapture
cargo test: 1 passed, 93 filtered out (1 suite, 5.13s)

Path-write tracking: changed, equal-valued, and cleared deployment paths each advance the managed monitor revision atomically; custom monitors remain unchanged.

cargo test --lib -p temps-status-page deployment_health_path_only_updates_and_clears_the_managed_monitor -- --nocapture
cargo test: 1 passed, 93 filtered out (1 suite, 5.52s)

Migration: real TimescaleDB apply merges reserved-name monitor history, down restores every original row/reference, the prior migration rolls down without stale ownership replay, and both migrations reapply.

cargo test -p temps-migrations --test migration_tests test_legacy_monitor_reconciliation_merges_duplicates_and_preserves_history -- --nocapture
cargo test: 1 passed, 42 filtered out (1 suite, 3.85s)

Complete verification:

cargo check --lib -p temps-status-page -p temps-migrations
cargo test --lib -p temps-status-page
cargo test --lib -p temps-monitoring
cargo test --lib -p temps-migrations
cargo test -p temps-migrations --test migration_tests -- --nocapture
python3 scripts/source_attribution.py check
cargo build: 0 errors, 2 pre-existing workspace/dependency warnings
cargo test: 94 passed (1 suite, 63.03s)
cargo test: 110 passed (1 suite, 0.01s)
cargo test: 21 passed (1 suite, 0.01s)
cargo test: 43 passed (1 suite, 36.77s)
Attribution check passed for 3759 source files.

Review gates

  • Rust/migration review: APPROVE
  • Test review: APPROVE
  • Security/data-integrity review: APPROVE; no findings

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

📓 Changelog preview

This is what your commits will add to the generated CHANGELOG.md at release time (via git-cliff). Do not edit CHANGELOG.md by hand — it is generated from your Conventional Commit messages.

## [Unreleased]

### Fixed

- **status-page:** Adopt existing environment monitors
- **migrations:** Preserve newer monitor paths on rollback
- **migrations:** Distinguish monitor path changes
- **status-page:** Track monitor path revisions

@greptile-apps

greptile-apps Bot commented Sep 8, 2026

Copy link
Copy Markdown

Greptile Summary

The PR adopts existing reserved-name environment monitors, reconciles duplicate history, and adds revision-based health-path ownership so rollback can distinguish deployment writes from migration state.

  • Preserves the oldest reserved monitor and moves duplicate checks and incidents onto it.
  • Tracks every managed health-path write with an atomic revision increment.
  • Restores duplicate ownership during rollback while preserving later path changes, equal-valued writes, explicit clears, and unrelated monitor edits.
  • Validates project/environment ownership and keeps custom-named monitors independent.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
crates/temps-migrations/src/migration/m20260908_000001_reconcile_legacy_status_monitors.rs Reconciles reserved-name monitor duplicates and implements reversible, revision-aware rollback without a remaining issue from the prior threads.
crates/temps-status-page/src/services/monitor_service.rs Adopts existing reserved monitors, validates ownership, handles concurrent reconciliation, and atomically revisions managed path writes.
crates/temps-entities/src/status_monitors.rs Adds the non-null check-path revision field required by the migration and service update logic.
crates/temps-migrations/tests/migration_tests.rs Covers duplicate-history reconciliation and rollback/reapply behavior for unrelated edits, changed paths, equal-valued writes, and explicit clears.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Legacy reserved-name monitors] --> B[Select oldest monitor as canonical]
    B --> C[Mark canonical managed]
    C --> D[Move duplicate checks and incidents]
    D --> E[Delete reserved duplicates]
    E --> F[Deployment writes health path and increments revision]
    F --> G{Migration rollback?}
    G -- No later path write --> H[Restore original canonical path]
    G -- Revision changed --> I[Preserve later path via duplicate handoff]
    H --> J[Restore duplicate rows and references]
    I --> J
Loading

Reviews (5): Last reviewed commit: "fix(status-page): track monitor path rev..." | Re-trigger Greptile

Signed-off-by: David Viejo <dviejo@kfs.es>
Signed-off-by: David Viejo <dviejo@kfs.es>
Signed-off-by: David Viejo <dviejo@kfs.es>
Signed-off-by: David Viejo <dviejo@kfs.es>
@dviejokfs
dviejokfs force-pushed the fix/adopt-legacy-status-monitors branch from fc24135 to 97bc70b Compare September 8, 2026 12:47
@dviejokfs
dviejokfs merged commit 49795fc into main Sep 8, 2026
35 checks passed
@dviejokfs
dviejokfs deleted the fix/adopt-legacy-status-monitors branch September 9, 2026 07:16
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