From 0d652605e590d94ebe83a8a67216f261172cbea3 Mon Sep 17 00:00:00 2001 From: Heemin Kim Date: Wed, 17 May 2023 10:50:44 -0700 Subject: [PATCH] Change index setting from read_only_allow_delete to write (#311) read_only_allow_delete does not block write to an index. The disk-based shard allocator may add and remove this block automatically. Therefore, use index.blocks.write instead. Signed-off-by: Heemin Kim --- .../geospatial/ip2geo/common/GeoIpDataFacade.java | 8 ++------ .../geospatial/ip2geo/common/GeoIpDataFacadeTests.java | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/opensearch/geospatial/ip2geo/common/GeoIpDataFacade.java b/src/main/java/org/opensearch/geospatial/ip2geo/common/GeoIpDataFacade.java index 5584f5eb..a9ffa43d 100644 --- a/src/main/java/org/opensearch/geospatial/ip2geo/common/GeoIpDataFacade.java +++ b/src/main/java/org/opensearch/geospatial/ip2geo/common/GeoIpDataFacade.java @@ -70,10 +70,7 @@ public class GeoIpDataFacade { private static final Tuple INDEX_SETTING_REFRESH_INTERVAL = new Tuple<>("index.refresh_interval", -1); private static final Tuple INDEX_SETTING_AUTO_EXPAND_REPLICAS = new Tuple<>("index.auto_expand_replicas", "0-all"); private static final Tuple INDEX_SETTING_HIDDEN = new Tuple<>("index.hidden", true); - private static final Tuple INDEX_SETTING_READ_ONLY_ALLOW_DELETE = new Tuple<>( - "index.blocks.read_only_allow_delete", - true - ); + private static final Tuple INDEX_SETTING_BLOCKS_WRITE = new Tuple<>("index.blocks.write", true); private final ClusterService clusterService; private final ClusterSettings clusterSettings; private final Client client; @@ -116,8 +113,7 @@ private void freezeIndex(final String indexName) { client.admin().indices().prepareRefresh(indexName).execute().actionGet(timeout); client.admin().indices().prepareForceMerge(indexName).setMaxNumSegments(1).execute().actionGet(timeout); Map settings = new HashMap<>(); - settings.put(INDEX_SETTING_READ_ONLY_ALLOW_DELETE.v1(), INDEX_SETTING_READ_ONLY_ALLOW_DELETE.v2()); - settings.put(INDEX_SETTING_NUM_OF_REPLICAS.v1(), null); + settings.put(INDEX_SETTING_BLOCKS_WRITE.v1(), INDEX_SETTING_BLOCKS_WRITE.v2()); settings.put(INDEX_SETTING_AUTO_EXPAND_REPLICAS.v1(), INDEX_SETTING_AUTO_EXPAND_REPLICAS.v2()); client.admin() .indices() diff --git a/src/test/java/org/opensearch/geospatial/ip2geo/common/GeoIpDataFacadeTests.java b/src/test/java/org/opensearch/geospatial/ip2geo/common/GeoIpDataFacadeTests.java index 19ee2bc7..b11851a9 100644 --- a/src/test/java/org/opensearch/geospatial/ip2geo/common/GeoIpDataFacadeTests.java +++ b/src/test/java/org/opensearch/geospatial/ip2geo/common/GeoIpDataFacadeTests.java @@ -210,7 +210,7 @@ public void testPutGeoIpData_whenValidInput_thenSucceed() { UpdateSettingsRequest request = (UpdateSettingsRequest) actionRequest; assertEquals(1, request.indices().length); assertEquals(index, request.indices()[0]); - assertEquals(true, request.settings().getAsBoolean("index.blocks.read_only_allow_delete", false)); + assertEquals(true, request.settings().getAsBoolean("index.blocks.write", false)); assertNull(request.settings().get("index.num_of_replica")); assertEquals("0-all", request.settings().get("index.auto_expand_replicas")); return null;