feat/migration admin dash#1501
Open
naraen-ram wants to merge 5 commits into
Open
Conversation
3722f5d to
4099f98
Compare
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
d0a6045 to
e1eaa8c
Compare
d017d24 to
fb19e0c
Compare
…dash # Conflicts: # observal-server/api/routes/admin/__init__.py
2bfae39 to
67b4bcd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose / Description
Brings the existing
observal migrateCLI capabilities into the admin dashboard as a self-contained Migration Panel, so asuper_admincan move an Observal instance's data in a few clicks without using the CLI.Today, migrating data requires an operator to know and correctly sequence CLI commands, manage connection strings, and shuttle archive files between machines by hand. This feature reduces that to three operations driven from the UI:
.tar.gzarchives.All operations run as background jobs on the existing arq worker, with progress streamed to the UI and artifacts offered for download when ready. The existing CLI commands remain fully functional — both the UI and CLI share the same migration service core.
Approach
Architecture
Shared Migration Service (
observal-server/services/migration/): Extracted all migration logic fromcmd_migrate.pyinto a shared, import-light package with notyper/rich/FastAPIdependencies at module scope. Both the CLI and the server import from this core.REST API (
api/routes/admin/migrate.py): 8 endpoints for export/import/validate (start + status polling + artifact download + current-org). All requiresuper_adminrole. Concurrency check prevents duplicate jobs. Upload validation checks magic bytes and size.Background Job (
jobs/migration.py):run_migration_jobloads the job row, creates artifact directory (0o700), dispatches to the shared service, writes progress to DB (throttled 1s), and handles success/failure with audit events.purge_migration_artifactscron deletes expired artifacts.Frontend (
web/src/pages/admin/dashboard/components/migrate-*.tsx): Migrate button (super_admin-gated), tabbed dialog (Export/Import/Validate), spinner-based progress, result display with download buttons.PostgreSQL Model + Alembic Migration:
MigrationJobtable with enums for operation/scope/status, progress fields, result JSON, and artifact metadata.Key Design Decisions
refetchInterval(1.5s) while job is active. Simpler, survives reconnects, matches existing InsightReport pattern.pg_export.tar.gz+telemetry_export.tar.gz) for clean UX.How Has This Been Tested?
Unit tests (
tests/test_migration_*.py,observal_cli/tests/test_cmd_migrate.py):Property-based tests (Hypothesis,
tests/test_migration_properties.py):Integration tests (
tests/test_migration_integration.py):Manual E2E testing against local Docker stack:
Checklist
Licenses
AI Assistance