fix: surface clear disk space error when OpenSearch exceeds 90% threshold#1053
Merged
Conversation
…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
mfortman11
approved these changes
Mar 3, 2026
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 |
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.

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— addsOpenSearchDiskSpaceErrorandis_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 asOpenSearchDiskSpaceErrorwith a clear, human-readable message explaining the >90% threshold and how to resolve itapi/search.pyandapi/v1/search.py— catchOpenSearchDiskSpaceErrorand return HTTP 507 Insufficient Storage with the descriptive message instead of a generic 500Testing
uv run pytest tests/unit/test_opensearch_disk_space.py -v)