-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug Fix , delete OpenSearch index when DROP INDEX #2250
Conversation
Signed-off-by: Peng Huo <[email protected]>
Signed-off-by: Peng Huo <[email protected]>
@@ -11,5 +11,5 @@ public interface FlintIndexMetadataReader { | |||
* @param indexDetails indexDetails. | |||
* @return jobId. | |||
*/ | |||
String getJobIdFromFlintIndexMetadata(IndexDetails indexDetails); | |||
FlintIndexMetadata getJobIdFromFlintIndexMetadata(IndexDetails indexDetails); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: change method name.
Also, return type in comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
JSONObject dummyData = new JSONObject(); | ||
dummyData.put("result", new JSONArray()); | ||
dummyData.put("schema", new JSONArray()); | ||
dummyData.put("applicationId", "fakeDropId"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: change to fakeApplicationId.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
String queryId = | ||
RandomStringUtils.randomAlphanumeric(PREFIX_LEN) | ||
+ String.join(DELIMITER, status, errorMsg); | ||
return Base64.getEncoder().encodeToString(queryId.getBytes(StandardCharsets.UTF_8)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the usual length of this result?
If it is more or less similar to emrJobId it would be good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SXlRbFhVczI1bEZBSUxFRA==
similar
@@ -23,4 +23,38 @@ public class IndexDetails { | |||
private Boolean autoRefresh = false; | |||
private boolean isDropIndex; | |||
private FlintIndexType indexType; | |||
|
|||
public String openSearchIndexName() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense 👍
Codecov Report
@@ Coverage Diff @@
## main #2250 +/- ##
=========================================
Coverage 96.59% 96.60%
- Complexity 4730 4736 +6
=========================================
Files 439 441 +2
Lines 12691 12728 +37
Branches 871 875 +4
=========================================
+ Hits 12259 12296 +37
Misses 424 424
Partials 8 8
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@@ -53,6 +67,8 @@ public class SparkQueryDispatcher { | |||
|
|||
private FlintIndexMetadataReader flintIndexMetadataReader; | |||
|
|||
private Client client; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Not a hard requirement if possible]
Instead of having client in SparkQueryDispatcher: can we move all the Flint Index logic to One class.
For example: Change FlintIndexMetadataReader -> FlintIndexHanlder and handle deletion logic in that class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree.
do it later. fix bug first.
try { | ||
AcknowledgedResponse response = | ||
client.admin().indices().delete(new DeleteIndexRequest().indices(indexName)).get(); | ||
if (!response.isAcknowledged()) { | ||
errorMsg = String.format("failed to delete index %s", indexName); | ||
LOG.error(errorMsg); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As suggested in above comment can we move this to FlintIndexHandler or some other class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree.
do it later. fix bug first.
String dropIndexDummyJobId = RandomStringUtils.randomAlphanumeric(16); | ||
FlintIndexMetadata indexMetadata = | ||
flintIndexMetadataReader.getJobIdFromFlintIndexMetadata(indexDetails); | ||
// if index is created without auto refresh. there is no job to cancel. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this. I missed a lot of cases.
@@ -64,6 +80,11 @@ public DispatchQueryResponse dispatch(DispatchQueryRequest dispatchQueryRequest) | |||
} | |||
|
|||
public JSONObject getQueryResponse(AsyncQueryJobMetadata asyncQueryJobMetadata) { | |||
// todo. refactor query process logic in plugin. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using if ... else.. not a good solution, we need to add abstraction. e.g. QueryTracker.
try { | ||
if (indexMetadata.isAutoRefresh()) { | ||
emrServerlessClient.cancelJobRun( | ||
dispatchQueryRequest.getApplicationId(), indexMetadata.getJobId()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so if this AppId is different from what's in metadata, we either fail here or assume job is already migrated to this App ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for open source, there is only one appid.
we should handle multiple appId cases in future.
Signed-off-by: Peng Huo <[email protected]>
* Bug Fix, delete opensearch index when DROP INDEX Signed-off-by: Peng Huo <[email protected]> * address comments Signed-off-by: Peng Huo <[email protected]> --------- Signed-off-by: Peng Huo <[email protected]> (cherry picked from commit 0c78105) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* Bug Fix, delete opensearch index when DROP INDEX Signed-off-by: Peng Huo <[email protected]> * address comments Signed-off-by: Peng Huo <[email protected]> --------- Signed-off-by: Peng Huo <[email protected]> (cherry picked from commit 0c78105) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* Bug Fix, delete opensearch index when DROP INDEX * address comments --------- (cherry picked from commit 0c78105) Signed-off-by: Peng Huo <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* Bug Fix, delete opensearch index when DROP INDEX * address comments --------- (cherry picked from commit 0c78105) Signed-off-by: Peng Huo <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Description
bug fix drop index
Issues Resolved
#2224
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.