Skip to content

feat(opensearch): Admin configuration 0 - REST APIs for migration stuff#8364

Merged
acaprau merged 2 commits intomainfrom
andrei/260211/2/opensearch/admin-configuration-0
Feb 12, 2026
Merged

feat(opensearch): Admin configuration 0 - REST APIs for migration stuff#8364
acaprau merged 2 commits intomainfrom
andrei/260211/2/opensearch/admin-configuration-0

Conversation

@acaprau
Copy link
Copy Markdown
Contributor

@acaprau acaprau commented Feb 12, 2026

Description

This PR introduces REST APIs for getting migration and retrieval settings, and for setting retrieval settings.

How Has This Been Tested?

Approve this PR now and I'll throw in an integration test file for free.

Additional Options

  • [Required] I have considered whether this PR needs to be cherry-picked to the latest beta branch.
  • [Optional] Override Linear Check

Summary by cubic

Adds admin REST APIs to read OpenSearch migration status and toggle OpenSearch retrieval. Router is wired into the app; integration tests cover defaults, persistence, and admin auth.

  • New Features
    • GET /admin/opensearch-migration/status — returns total_chunks_migrated, created_at, migration_completed_at (defaults: 0/None/None when no record).
    • GET /admin/opensearch-migration/retrieval — returns enable_opensearch_retrieval (defaults to false when no record).
    • PUT /admin/opensearch-migration/retrieval — sets enable_opensearch_retrieval; creates the singleton record if missing and commits.
    • Admin auth required for all endpoints.

Written for commit 2da70b0. Summary will update on new commits.

@acaprau acaprau requested a review from a team as a code owner February 12, 2026 00:14
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Feb 12, 2026

Greptile Overview

Greptile Summary

This PR introduces REST APIs for managing OpenSearch migration settings. It adds three database helper functions in opensearch_migration.py and three admin-protected endpoints (/admin/opensearch-migration/status, /admin/opensearch-migration/retrieval GET/PUT) for retrieving migration status and toggling the OpenSearch retrieval feature flag.

Key changes:

  • Database layer: get_opensearch_migration_state(), get_opensearch_retrieval_state(), and set_enable_opensearch_retrieval_with_commit() functions
  • API layer: Three admin-only endpoints with proper authentication
  • Models: Pydantic request/response models with immutability
  • Tests: Comprehensive integration tests covering all endpoints, defaults, persistence, and authorization
  • Router registration: Properly registered in main.py following existing patterns

The implementation is clean, follows existing code patterns, uses proper authentication, and includes thorough test coverage. All endpoints are admin-protected via current_admin_user dependency.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The code is well-structured, follows existing patterns throughout the codebase, includes comprehensive integration tests, and all endpoints are properly protected with admin authentication. The database layer functions are simple queries/updates with no complex logic, and the API layer is straightforward request/response handling.
  • No files require special attention

Important Files Changed

Filename Overview
backend/onyx/db/opensearch_migration.py Adds three new database helper functions for getting and setting migration state and retrieval settings. Clean implementation following existing patterns.
backend/onyx/main.py Registers the new OpenSearch migration admin router. Simple, clean change following existing patterns.
backend/onyx/server/manage/opensearch_migration/api.py New REST API endpoints for migration status and retrieval settings. All endpoints properly protected with admin authentication.
backend/onyx/server/manage/opensearch_migration/models.py Clean Pydantic models for request/response objects with proper immutability settings.
backend/tests/integration/tests/opensearch_migration/test_opensearch_migration_api.py Comprehensive integration tests covering all endpoints, default values, persistence, and authorization. Well-structured tests following project patterns.

Sequence Diagram

sequenceDiagram
    participant Admin as Admin User
    participant API as FastAPI Router
    participant DB as Database Layer
    participant PG as PostgreSQL

    Note over Admin,PG: GET /admin/opensearch-migration/status
    Admin->>API: GET /status (with auth)
    API->>API: Verify current_admin_user
    API->>DB: get_opensearch_migration_state(db_session)
    DB->>PG: Query OpenSearchTenantMigrationRecord
    PG-->>DB: Return record or None
    DB-->>API: (total_chunks, created_at, completed_at)
    API-->>Admin: OpenSearchMigrationStatusResponse

    Note over Admin,PG: GET /admin/opensearch-migration/retrieval
    Admin->>API: GET /retrieval (with auth)
    API->>API: Verify current_admin_user
    API->>DB: get_opensearch_retrieval_state(db_session)
    DB->>PG: Query OpenSearchTenantMigrationRecord
    PG-->>DB: Return record or None
    DB-->>API: enable_opensearch_retrieval (bool)
    API-->>Admin: OpenSearchRetrievalStatusResponse

    Note over Admin,PG: PUT /admin/opensearch-migration/retrieval
    Admin->>API: PUT /retrieval (with auth + payload)
    API->>API: Verify current_admin_user
    API->>DB: set_enable_opensearch_retrieval_with_commit()
    DB->>DB: try_insert_opensearch_tenant_migration_record_with_commit()
    DB->>PG: INSERT record if not exists
    PG-->>DB: Record exists
    DB->>PG: UPDATE enable_opensearch_retrieval
    DB->>PG: COMMIT
    PG-->>DB: Success
    DB-->>API: void
    API-->>Admin: OpenSearchRetrievalStatusResponse
Loading

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 5 files

Copy link
Copy Markdown
Contributor

@evan-onyx evan-onyx left a comment

Choose a reason for hiding this comment

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

nit


def get_opensearch_migration_state(
db_session: Session,
) -> tuple[int, datetime | None, datetime | None]:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: baseModel

@github-actions
Copy link
Copy Markdown
Contributor

Preview Deployment

Status Preview Commit Updated
https://onyx-preview-puljs45l7-danswer.vercel.app 2da70b0 2026-02-12 03:25:55 UTC

@acaprau acaprau added this pull request to the merge queue Feb 12, 2026
Merged via the queue into main with commit 15b372f Feb 12, 2026
83 checks passed
@acaprau acaprau deleted the andrei/260211/2/opensearch/admin-configuration-0 branch February 12, 2026 06:23
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.

2 participants