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

Revert "x-pack/plugin/core: make automatic rollovers lazy" #104734

Merged
merged 3 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions docs/changelog/104597.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,25 @@

package org.elasticsearch.xpack.core.template;

import org.elasticsearch.action.DocWriteRequest;
import org.elasticsearch.action.DocWriteResponse;
import org.elasticsearch.action.datastreams.CreateDataStreamAction;
import org.elasticsearch.action.datastreams.GetDataStreamAction;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.internal.Client;
import org.elasticsearch.cluster.ClusterChangedEvent;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.DataStream;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.datastreams.DataStreamsPlugin;
import org.elasticsearch.index.mapper.DateFieldMapper;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.xcontent.XContentType;
import org.junit.Before;

import java.util.Collection;
import java.util.List;
import java.util.Locale;

import static org.elasticsearch.cluster.metadata.MetadataIndexTemplateService.DEFAULT_TIMESTAMP_FIELD;
import static org.elasticsearch.xpack.core.template.RolloverEnabledTestTemplateRegistry.TEST_INDEX_PATTERN;
import static org.elasticsearch.xpack.core.template.RolloverEnabledTestTemplateRegistry.TEST_INDEX_TEMPLATE_ID;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;

@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0, numClientNodes = 0)
Expand Down Expand Up @@ -75,29 +67,16 @@ public void testRollover() throws Exception {
assertNumberOfBackingIndices(1);
registry.incrementVersion();
registry.clusterChanged(new ClusterChangedEvent(IndexTemplateRegistryRolloverIT.class.getName(), clusterService.state(), state));
assertBusy(() -> assertTrue(getDataStream().rolloverOnWrite()));
assertNumberOfBackingIndices(1);

String timestampValue = DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER.formatMillis(System.currentTimeMillis());
DocWriteResponse docWriteResponse = client().index(
new IndexRequest(dsName).opType(DocWriteRequest.OpType.CREATE)
.source(String.format(Locale.ROOT, "{\"%s\":\"%s\"}", DEFAULT_TIMESTAMP_FIELD, timestampValue), XContentType.JSON)
).actionGet();
assertThat(docWriteResponse.status().getStatus(), equalTo(201));
assertBusy(() -> assertNumberOfBackingIndices(2));
}

private void assertNumberOfBackingIndices(final int expected) {
DataStream dataStream = getDataStream();
assertThat(dataStream.getIndices(), hasSize(expected));
assertThat(dataStream.getWriteIndex().getName(), endsWith(String.valueOf(expected)));
}

private DataStream getDataStream() {
GetDataStreamAction.Request getDataStreamRequest = new GetDataStreamAction.Request(new String[] { TEST_INDEX_PATTERN });
GetDataStreamAction.Response getDataStreamResponse = client.execute(GetDataStreamAction.INSTANCE, getDataStreamRequest).actionGet();
List<GetDataStreamAction.Response.DataStreamInfo> dataStreams = getDataStreamResponse.getDataStreams();
assertThat(dataStreams, hasSize(1));
return dataStreams.get(0).getDataStream();
DataStream dataStream = dataStreams.get(0).getDataStream();
assertThat(dataStream.getIndices(), hasSize(expected));
assertThat(dataStream.getWriteIndex().getName(), endsWith(String.valueOf(expected)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -808,13 +808,12 @@ public void onFailure(Exception e) {
);
for (String rolloverTarget : rolloverTargets) {
logger.info(
"rolling over data stream [{}] lazily as a followup to the upgrade of the [{}] index template [{}]",
"rolling over data stream [{}] as a followup to the upgrade of the [{}] index template [{}]",
rolloverTarget,
getOrigin(),
templateName
);
RolloverRequest request = new RolloverRequest(rolloverTarget, null);
request.lazy(true);
request.masterNodeTimeout(TimeValue.timeValueMinutes(1));
executeAsyncWithOrigin(
client.threadPool().getThreadContext(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@ public void testAutomaticRollover() throws Exception {
rolloverCounter.incrementAndGet();
RolloverRequest rolloverRequest = ((RolloverRequest) request);
assertThat(rolloverRequest.getRolloverTarget(), startsWith("logs-my_app-"));
assertThat(rolloverRequest.isLazy(), equalTo(true));
} else if (action == TransportPutComposableIndexTemplateAction.TYPE) {
putIndexTemplateCounter.incrementAndGet();
}
Expand Down
Loading