From 16eb613cf5d5be9d48a9766e1174d1ad2a94eccd Mon Sep 17 00:00:00 2001 From: Mohit Godwani Date: Mon, 13 Jan 2025 10:55:59 +0530 Subject: [PATCH 1/3] Remove user data from logs when not in debug/trace mode Signed-off-by: Mohit Godwani --- .../support/replication/ReplicationOperation.java | 10 +--------- .../replication/TransportReplicationAction.java | 2 +- .../org/opensearch/action/update/UpdateHelper.java | 7 ++++++- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/server/src/main/java/org/opensearch/action/support/replication/ReplicationOperation.java b/server/src/main/java/org/opensearch/action/support/replication/ReplicationOperation.java index 9f69d41d83f5b..12d3502184ac4 100644 --- a/server/src/main/java/org/opensearch/action/support/replication/ReplicationOperation.java +++ b/server/src/main/java/org/opensearch/action/support/replication/ReplicationOperation.java @@ -141,15 +141,7 @@ public void execute() throws Exception { final ShardRouting primaryRouting = primary.routingEntry(); final ShardId primaryId = primaryRouting.shardId(); if (activeShardCountFailure != null) { - finishAsFailed( - new UnavailableShardsException( - primaryId, - "{} Timeout: [{}], request: [{}]", - activeShardCountFailure, - request.timeout(), - request - ) - ); + finishAsFailed(new UnavailableShardsException(primaryId, "{} Timeout: [{}]", activeShardCountFailure, request.timeout())); return; } diff --git a/server/src/main/java/org/opensearch/action/support/replication/TransportReplicationAction.java b/server/src/main/java/org/opensearch/action/support/replication/TransportReplicationAction.java index 49a96603f6802..637a7a31d78cc 100644 --- a/server/src/main/java/org/opensearch/action/support/replication/TransportReplicationAction.java +++ b/server/src/main/java/org/opensearch/action/support/replication/TransportReplicationAction.java @@ -1246,7 +1246,7 @@ void finishOnSuccess(Response response) { } void retryBecauseUnavailable(ShardId shardId, String message) { - retry(new UnavailableShardsException(shardId, "{} Timeout: [{}], request: [{}]", message, request.timeout(), request)); + retry(new UnavailableShardsException(shardId, "{} Timeout: [{}]", message, request.timeout())); } } diff --git a/server/src/main/java/org/opensearch/action/update/UpdateHelper.java b/server/src/main/java/org/opensearch/action/update/UpdateHelper.java index 19c32f9336df8..c02ec1fbb9cf0 100644 --- a/server/src/main/java/org/opensearch/action/update/UpdateHelper.java +++ b/server/src/main/java/org/opensearch/action/update/UpdateHelper.java @@ -58,6 +58,7 @@ import org.opensearch.index.shard.IndexShard; import org.opensearch.script.Script; import org.opensearch.script.ScriptService; +import org.opensearch.script.ScriptType; import org.opensearch.script.UpdateScript; import org.opensearch.search.lookup.SourceLookup; @@ -128,7 +129,11 @@ Tuple> executeScriptedUpsert(Map Date: Tue, 14 Jan 2025 01:31:51 +0530 Subject: [PATCH 2/3] Fix test Signed-off-by: Mohit Godwani --- .../org/opensearch/action/support/WaitActiveShardCountIT.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/action/support/WaitActiveShardCountIT.java b/server/src/internalClusterTest/java/org/opensearch/action/support/WaitActiveShardCountIT.java index 08cffac8aac5d..c4ffbccf0ab99 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/support/WaitActiveShardCountIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/support/WaitActiveShardCountIT.java @@ -76,7 +76,7 @@ public void testReplicationWaitsForActiveShardCount() throws Exception { assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE)); assertThat( e.getMessage(), - startsWith("[test][0] Not enough active copies to meet shard count of [2] (have 1, needed 2). Timeout: [100ms], request:") + startsWith("[test][0] Not enough active copies to meet shard count of [2] (have 1, needed 2). Timeout: [100ms]") ); // but really, all is well } @@ -120,7 +120,7 @@ public void testReplicationWaitsForActiveShardCount() throws Exception { startsWith( "[test][0] Not enough active copies to meet shard count of [" + ActiveShardCount.ALL - + "] (have 2, needed 3). Timeout: [100ms], request:" + + "] (have 2, needed 3). Timeout: [100ms]" ) ); // but really, all is well From 6fbe5fa5dff4e77b469b2da2c8321619404cd254 Mon Sep 17 00:00:00 2001 From: Mohit Godwani Date: Tue, 14 Jan 2025 02:22:03 +0530 Subject: [PATCH 3/3] Fix test Signed-off-by: Mohit Godwani --- .../test/delete_by_query/50_wait_for_active_shards.yml | 2 +- .../rest-api-spec/test/reindex/60_wait_for_active_shards.yml | 2 +- .../rest-api-spec/test/update_by_query/50_consistency.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/reindex/src/yamlRestTest/resources/rest-api-spec/test/delete_by_query/50_wait_for_active_shards.yml b/modules/reindex/src/yamlRestTest/resources/rest-api-spec/test/delete_by_query/50_wait_for_active_shards.yml index ea8ed4df3e748..39cf36847f25d 100644 --- a/modules/reindex/src/yamlRestTest/resources/rest-api-spec/test/delete_by_query/50_wait_for_active_shards.yml +++ b/modules/reindex/src/yamlRestTest/resources/rest-api-spec/test/delete_by_query/50_wait_for_active_shards.yml @@ -25,7 +25,7 @@ match_all: {} - match: - failures.0.cause.reason: /Not.enough.active.copies.to.meet.shard.count.of.\[4\].\(have.1,.needed.4\)..Timeout\:.\[1s\],.request:.+/ + failures.0.cause.reason: /Not.enough.active.copies.to.meet.shard.count.of.\[4\].\(have.1,.needed.4\)..Timeout\:.\[1s\]/ - do: indices.refresh: {} diff --git a/modules/reindex/src/yamlRestTest/resources/rest-api-spec/test/reindex/60_wait_for_active_shards.yml b/modules/reindex/src/yamlRestTest/resources/rest-api-spec/test/reindex/60_wait_for_active_shards.yml index 3498e555d2879..a580c55a95130 100644 --- a/modules/reindex/src/yamlRestTest/resources/rest-api-spec/test/reindex/60_wait_for_active_shards.yml +++ b/modules/reindex/src/yamlRestTest/resources/rest-api-spec/test/reindex/60_wait_for_active_shards.yml @@ -25,7 +25,7 @@ dest: index: dest - match: - failures.0.cause.reason: /Not.enough.active.copies.to.meet.shard.count.of.\[4\].\(have.1,.needed.4\)\..Timeout\:.\[1s\],.request:.+/ + failures.0.cause.reason: /Not.enough.active.copies.to.meet.shard.count.of.\[4\].\(have.1,.needed.4\)\..Timeout\:.\[1s\]/ - do: reindex: diff --git a/modules/reindex/src/yamlRestTest/resources/rest-api-spec/test/update_by_query/50_consistency.yml b/modules/reindex/src/yamlRestTest/resources/rest-api-spec/test/update_by_query/50_consistency.yml index 4a067580b54d3..e97eacc3c9c25 100644 --- a/modules/reindex/src/yamlRestTest/resources/rest-api-spec/test/update_by_query/50_consistency.yml +++ b/modules/reindex/src/yamlRestTest/resources/rest-api-spec/test/update_by_query/50_consistency.yml @@ -21,7 +21,7 @@ wait_for_active_shards: 4 timeout: 1s - match: - failures.0.cause.reason: /Not.enough.active.copies.to.meet.shard.count.of.\[4\].\(have.1,.needed.4\)..Timeout\:.\[1s\],.request:.+/ + failures.0.cause.reason: /Not.enough.active.copies.to.meet.shard.count.of.\[4\].\(have.1,.needed.4\)..Timeout\:.\[1s\]/ - do: update_by_query: