Skip to content
Closed
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: 6 additions & 0 deletions docs/changelog/121554.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 121554
summary: Do not set source index to verified read-only as will be ignored by future
runs
area: Data streams
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.metadata.MappingMetadata;
import org.elasticsearch.cluster.metadata.MetadataIndexStateService;
import org.elasticsearch.cluster.metadata.Template;
import org.elasticsearch.common.compress.CompressedXContent;
import org.elasticsearch.common.settings.Settings;
Expand Down Expand Up @@ -76,6 +77,21 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
return List.of(MigratePlugin.class, ReindexPlugin.class, MockTransportService.TestPlugin.class, DataStreamsPlugin.class);
}

public void testSourceNotVerifiedReadOnly() throws Exception {
// empty source index
var sourceIndex = randomAlphaOfLength(20).toLowerCase(Locale.ROOT);
indicesAdmin().create(new CreateIndexRequest(sourceIndex)).get();

// call reindex
client().execute(ReindexDataStreamIndexAction.INSTANCE, new ReindexDataStreamIndexAction.Request(sourceIndex)).actionGet();

var settingsResponse = indicesAdmin().getSettings(new GetSettingsRequest().indices(sourceIndex)).actionGet();
assertTrue(Boolean.parseBoolean(settingsResponse.getSetting(sourceIndex, IndexMetadata.SETTING_BLOCKS_WRITE)));
assertFalse(
Boolean.parseBoolean(settingsResponse.getSetting(sourceIndex, MetadataIndexStateService.VERIFIED_READ_ONLY_SETTING.getKey()))
);
}

public void testDestIndexDeletedIfExists() throws Exception {
// empty source index
var sourceIndex = randomAlphaOfLength(20).toLowerCase(Locale.ROOT);
Expand Down Expand Up @@ -468,13 +484,4 @@ private static void indexDocs(String index, int numDocs) {
private static String formatInstant(Instant instant) {
return DateFormatter.forPattern(FormatNames.STRICT_DATE_OPTIONAL_TIME.getName()).format(instant);
}

private static String getIndexUUID(String index) {
return indicesAdmin().getIndex(new GetIndexRequest(TEST_REQUEST_TIMEOUT).indices(index))
.actionGet()
.getSettings()
.get(index)
.get(IndexMetadata.SETTING_INDEX_UUID);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ private void addBlockToIndex(
TaskId parentTaskId
) {
AddIndexBlockRequest addIndexBlockRequest = new AddIndexBlockRequest(block, index);
addIndexBlockRequest.markVerified(false);
addIndexBlockRequest.setParentTask(parentTaskId);
client.admin().indices().execute(TransportAddIndexBlockAction.TYPE, addIndexBlockRequest, listener);
}
Expand Down