Skip to content

Commit f69492f

Browse files
committed
set source index to read-only, but not verified
1 parent 92d1d31 commit f69492f

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

x-pack/plugin/migrate/src/internalClusterTest/java/org/elasticsearch/xpack/migrate/action/ReindexDatastreamIndexTransportActionIT.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
2828
import org.elasticsearch.cluster.metadata.IndexMetadata;
2929
import org.elasticsearch.cluster.metadata.MappingMetadata;
30+
import org.elasticsearch.cluster.metadata.MetadataIndexStateService;
3031
import org.elasticsearch.cluster.metadata.Template;
3132
import org.elasticsearch.common.compress.CompressedXContent;
3233
import org.elasticsearch.common.settings.Settings;
@@ -76,6 +77,21 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
7677
return List.of(MigratePlugin.class, ReindexPlugin.class, MockTransportService.TestPlugin.class, DataStreamsPlugin.class);
7778
}
7879

80+
public void testSourceNotVerifiedReadOnly() throws Exception {
81+
// empty source index
82+
var sourceIndex = randomAlphaOfLength(20).toLowerCase(Locale.ROOT);
83+
indicesAdmin().create(new CreateIndexRequest(sourceIndex)).get();
84+
85+
// call reindex
86+
client().execute(ReindexDataStreamIndexAction.INSTANCE, new ReindexDataStreamIndexAction.Request(sourceIndex)).actionGet();
87+
88+
var settingsResponse = indicesAdmin().getSettings(new GetSettingsRequest().indices(sourceIndex)).actionGet();
89+
assertTrue(Boolean.parseBoolean(settingsResponse.getSetting(sourceIndex, IndexMetadata.SETTING_BLOCKS_WRITE)));
90+
assertFalse(
91+
Boolean.parseBoolean(settingsResponse.getSetting(sourceIndex, MetadataIndexStateService.VERIFIED_READ_ONLY_SETTING.getKey()))
92+
);
93+
}
94+
7995
public void testDestIndexDeletedIfExists() throws Exception {
8096
// empty source index
8197
var sourceIndex = randomAlphaOfLength(20).toLowerCase(Locale.ROOT);
@@ -468,13 +484,4 @@ private static void indexDocs(String index, int numDocs) {
468484
private static String formatInstant(Instant instant) {
469485
return DateFormatter.forPattern(FormatNames.STRICT_DATE_OPTIONAL_TIME.getName()).format(instant);
470486
}
471-
472-
private static String getIndexUUID(String index) {
473-
return indicesAdmin().getIndex(new GetIndexRequest(TEST_REQUEST_TIMEOUT).indices(index))
474-
.actionGet()
475-
.getSettings()
476-
.get(index)
477-
.get(IndexMetadata.SETTING_INDEX_UUID);
478-
}
479-
480487
}

x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/action/ReindexDataStreamIndexTransportAction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ private void addBlockToIndex(
342342
TaskId parentTaskId
343343
) {
344344
AddIndexBlockRequest addIndexBlockRequest = new AddIndexBlockRequest(block, index);
345+
addIndexBlockRequest.markVerified(false);
345346
addIndexBlockRequest.setParentTask(parentTaskId);
346347
client.admin().indices().execute(TransportAddIndexBlockAction.TYPE, addIndexBlockRequest, listener);
347348
}

0 commit comments

Comments
 (0)