Skip to content

fix: surface clear disk space error when OpenSearch exceeds 90% threshold#1053

Merged
mfortman11 merged 3 commits into
mainfrom
fix/opensearch-disk-space-error-handling
Mar 16, 2026
Merged

fix: surface clear disk space error when OpenSearch exceeds 90% threshold#1053
mfortman11 merged 3 commits into
mainfrom
fix/opensearch-disk-space-error-handling

Conversation

@TejasQ

@TejasQ TejasQ commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

Problem

When OpenSearch disk usage exceeds 90%, it enters a degraded/read-only state and blocks search operations. OpenRAG was propagating the raw cryptic error (e.g. cluster_block_exception, FORBIDDEN/12) directly to the UI, which made all indexed knowledge appear to vanish with no actionable explanation.

Fixes #1042

Changes

  • utils/opensearch_utils.py — adds OpenSearchDiskSpaceError and is_disk_space_error() to detect all known OpenSearch disk-watermark error signatures (disk watermark, flood_stage, cluster_block_exception,
    index read-only, FORBIDDEN/12, no space left on device, etc.)
  • services/search_service.py — wraps detected disk errors as OpenSearchDiskSpaceError with a clear, human-readable message explaining the >90% threshold and how to resolve it
  • api/search.py and api/v1/search.py — catch OpenSearchDiskSpaceError and return HTTP 507 Insufficient Storage with the descriptive message instead of a generic 500

Testing

  • 20 new unit tests added covering every error-signature pattern and negative cases (uv run pytest tests/unit/test_opensearch_disk_space.py -v)
  • All pass locally

…hold

When OpenSearch's disk hits the high-watermark (>90%) or flood-stage
watermark, it blocks search and write operations and returns cryptic
cluster-block / forbidden errors. This caused OpenRAG to show
misleading messages (e.g. "all knowledge disappeared") with no
indication that disk space was the root cause.

Changes:
- Add `OpenSearchDiskSpaceError` exception and `is_disk_space_error()`
  helper to `opensearch_utils.py` to detect all known disk-constraint
  error signatures from OpenSearch.
- Update `search_service.py` to wrap disk-space errors as
  `OpenSearchDiskSpaceError` with a human-readable message explaining
  the threshold and how to resolve it.
- Update `api/search.py` and `api/v1/search.py` to return HTTP 507
  (Insufficient Storage) with the clear error message instead of a
  generic 500.
- Add 20 unit tests covering all detection patterns and edge cases.

Closes #1042
@github-actions github-actions Bot added community backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) tests bug 🔴 Something isn't working. labels Mar 2, 2026
Comment thread src/api/search.py Fixed
Comment thread src/api/v1/search.py Fixed
@github-actions github-actions Bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Mar 2, 2026
@github-actions github-actions Bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Mar 2, 2026

@mfortman11 mfortman11 left a comment

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.

Nice work! This works for me I see the error messaging just fine

One nit would be to just say that "disk space is low" instead of giving a percentage since search should work up to 100% usage and writes up to 95%

Image

@github-actions github-actions Bot added the lgtm label Mar 3, 2026
@mfortman11

Copy link
Copy Markdown
Contributor

It might be a bit overkill but we could also include a check before upload on how much disk space is left and return and error if >95% instead of waiting for the task service to run

@github-actions github-actions Bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Mar 16, 2026
@mfortman11 mfortman11 merged commit 4468cd3 into main Mar 16, 2026
9 checks passed
@github-actions github-actions Bot deleted the fix/opensearch-disk-space-error-handling branch March 16, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) bug 🔴 Something isn't working. community lgtm tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Disk space threshold of >90% causes OpenSearch to shut down and cripple OpenRAG

3 participants