Conversation
📝 WalkthroughWalkthroughValidates that the target Elasticsearch index or alias exists before starting resharding by adding a private Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Client
participant API as Resharding API
participant ESIdx as es-index (conn)
participant ES as Elasticsearch
Client->>API: POST /reshard/start (index, es-cluster-name)
API->>API: validate-index-exists(context, index, es-cluster-name)
API->>ESIdx: context->conn(context, es-cluster-name)
ESIdx->>ES: exists?(index or alias)
ES-->>ESIdx: exists? result (true/false)
ESIdx-->>API: exists? result
alt index exists
API->>API: proceed with existing validations and start resharding
API-->>Client: 200 Started
else index missing
API-->>Client: 404 "Index or alias [name] does not exist in the Elasticsearch cluster [cluster-name]"
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| (when (string/blank? es-cluster-name) | ||
| (errors/throw-service-error :bad-request "Empty elastic cluster name is not allowed."))) | ||
|
|
||
| (defn- validate-index-exists |
| [context index es-cluster-name] | ||
| (let [conn (es-index/context->conn context es-cluster-name)] | ||
| (when-not (or (es-helper/exists? conn index) | ||
| (es-helper/alias-exists? conn index)) |
There was a problem hiding this comment.
I do not think we allow resharding based on alias names. Can you check this?
There was a problem hiding this comment.
Good call, I tested it and it does not allow aliases, it returns index doesn't exist error. I will remove the alias check to avoid confusion
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2372 +/- ##
==========================================
- Coverage 58.02% 58.01% -0.02%
==========================================
Files 1064 1064
Lines 72827 72835 +8
Branches 2115 2112 -3
==========================================
- Hits 42258 42255 -3
- Misses 28601 28610 +9
- Partials 1968 1970 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Overview
What is the objective?
Fix bug that allows calling the start reshard endpoint on an index that no longer exists.
What are the changes?
Added new validation step for checking existence of index/alias earlier in flow, at the API receiving function where it was already doing other validation.
What areas of the application does this impact?
bootstrap-app
Required Checklist
Additional Checklist
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.