Skip to content
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

add rollover and delete history custom result index conditions #16

Open
wants to merge 3 commits into
base: forecasting18_3
Choose a base branch
from

Conversation

jackiehanyang
Copy link

add rollover conditions (size & age) and delete history index condition (ttl) on custom result index

Copy link
Owner

@kaituo kaituo left a comment

Choose a reason for hiding this comment

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

Finished the 1st pass of the code.

// We have to pass null for newIndexName in order to get Elastic to increment the index count.
RolloverRequest rollOverRequest = new RolloverRequest(resultIndexAlias, null);
// perform rollover and delete on AD custom result index alias
if (config.getCustomResultIndexOrAlias().startsWith(ADCommonName.CUSTOM_RESULT_INDEX_PREFIX)) {
Copy link
Owner

Choose a reason for hiding this comment

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

I already did the check in getConfigsWithCustomResultIndexAlias. You don't need it.

Copy link
Author

Choose a reason for hiding this comment

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

Removed the part that's checking if config.getCustomResultIndexOrAlias() starts with AD custom result index prefix or forecasting custom result index prefix


// perform rollover and delete on Forecasting custom result index alias
Copy link
Owner

Choose a reason for hiding this comment

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

You can remove forecasting code as the code is in base class. We will schedule two tasks: one for AD, and one for forecasting. The base case just abstracts out which it is run for (AD or forecasting). ADIndexManagement and ForecastIndexManagement will override rolloverAndDeleteHistoryIndex and rollover and delete their own indices.

Copy link
Author

Choose a reason for hiding this comment

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

same as above, removed this part

@@ -1234,35 +1242,113 @@ protected void rolloverAndDeleteHistoryIndex(
String rolloverIndexPattern,
IndexType resultIndex
) {
if (!doesDefaultResultIndexExist()) {
return;

Copy link
Owner

Choose a reason for hiding this comment

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

You only roll over default indices when there is an error or there is no custom result indices.

Copy link
Author

Choose a reason for hiding this comment

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

changed to perform rollover and delete on default result index first if default result index exist. Then perform rollover and delete custom result index

proceedWithRolloverAndDelete(resultIndexAlias, rolloverRequest, allResultIndicesPattern, resultIndex, null);
}

private RolloverRequest buildRolloverRequest(String resultIndexAlias, String rolloverIndexPattern) {
Copy link
Owner

Choose a reason for hiding this comment

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

for custom result index, we don't need addMaxIndexDocsCondition. For default result index, we only need addMaxIndexDocsCondition. In this way, if customers don't elect any ISM option from AD dashboard, we won't touch it and cx can decide on their own. I think you can put addMaxIndexDocsCondition outside and only do it if you are handling default result index.

Copy link
Author

Choose a reason for hiding this comment

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

changed to only build addMaxIndexDocsCondition when performing rollover on default result index

@@ -283,7 +289,7 @@ protected void choosePrimaryShards(CreateIndexRequest request, boolean hiddenInd
);
}

protected void deleteOldHistoryIndices(String indexPattern, TimeValue historyRetentionPeriod) {
protected void deleteOldHistoryIndices(String indexPattern, TimeValue historyRetentionPeriod, Integer customResultIndexTtl) {
Copy link
Owner

Choose a reason for hiding this comment

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

This is running for default result indices. But we want to check each custom index's custom ttl and do it one by one. Also, since there can be a lot of custom indices and the method is async, you may want to run the delete in batches. Finish batch of delete before the other custom indices.

Copy link
Owner

Choose a reason for hiding this comment

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

Also, can we still keep current method signature?

void deleteOldHistoryIndices(String indexPattern, TimeValue historyRetentionPeriod)

If it is default index, you called it the old way. If it is custom index, you translate customResultIndexTtl of type integer to historyRetentionPeriod of type TimeValue.

Copy link
Author

Choose a reason for hiding this comment

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

kept current method signature.

Not sure what you mean by run the delete in batches. Right now in deleteOldHistoryIndices, it seems like we already collecting candidates indices for deletion into a list, then perform deletion. Let's sync offline about this

config.getCustomResultIndexOrAlias(),
rolloverRequest,
getAllCustomResultIndexPattern(config.getCustomResultIndexOrAlias()),
(IndexType) ADIndex.CUSTOM_RESULT,
Copy link
Owner

Choose a reason for hiding this comment

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

You can make ADIndex.CUSTOM_RESULT as an input of the calling method and let the sublcass to pass in ADIndex.CUSTOM_RESULT or ForecastIndex.CUSTOM_RESULT.

Copy link
Author

Choose a reason for hiding this comment

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

updated this part to not differentiate AD and Forecasting.

@jackiehanyang jackiehanyang force-pushed the jackieForecasting18_3 branch 10 times, most recently from 2730df5 to d5ba7f5 Compare June 9, 2024 01:52
Signed-off-by: Jackie Han <[email protected]>
Signed-off-by: Jackie Han <[email protected]>
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