Skip to content

Commit 13159c1

Browse files
authored
Remove user data from logs when not in debug/trace mode (opensearch-project#17007)
* Remove user data from logs when not in debug/trace mode Signed-off-by: Mohit Godwani <mgodwan@amazon.com>
1 parent 34ef146 commit 13159c1

File tree

7 files changed

+13
-16
lines changed

7 files changed

+13
-16
lines changed

modules/reindex/src/yamlRestTest/resources/rest-api-spec/test/delete_by_query/50_wait_for_active_shards.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
match_all: {}
2626

2727
- match:
28-
failures.0.cause.reason: /Not.enough.active.copies.to.meet.shard.count.of.\[4\].\(have.1,.needed.4\)..Timeout\:.\[1s\],.request:.+/
28+
failures.0.cause.reason: /Not.enough.active.copies.to.meet.shard.count.of.\[4\].\(have.1,.needed.4\)..Timeout\:.\[1s\]/
2929

3030
- do:
3131
indices.refresh: {}

modules/reindex/src/yamlRestTest/resources/rest-api-spec/test/reindex/60_wait_for_active_shards.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
dest:
2626
index: dest
2727
- match:
28-
failures.0.cause.reason: /Not.enough.active.copies.to.meet.shard.count.of.\[4\].\(have.1,.needed.4\)\..Timeout\:.\[1s\],.request:.+/
28+
failures.0.cause.reason: /Not.enough.active.copies.to.meet.shard.count.of.\[4\].\(have.1,.needed.4\)\..Timeout\:.\[1s\]/
2929

3030
- do:
3131
reindex:

modules/reindex/src/yamlRestTest/resources/rest-api-spec/test/update_by_query/50_consistency.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
wait_for_active_shards: 4
2222
timeout: 1s
2323
- match:
24-
failures.0.cause.reason: /Not.enough.active.copies.to.meet.shard.count.of.\[4\].\(have.1,.needed.4\)..Timeout\:.\[1s\],.request:.+/
24+
failures.0.cause.reason: /Not.enough.active.copies.to.meet.shard.count.of.\[4\].\(have.1,.needed.4\)..Timeout\:.\[1s\]/
2525

2626
- do:
2727
update_by_query:

server/src/internalClusterTest/java/org/opensearch/action/support/WaitActiveShardCountIT.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void testReplicationWaitsForActiveShardCount() throws Exception {
7676
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
7777
assertThat(
7878
e.getMessage(),
79-
startsWith("[test][0] Not enough active copies to meet shard count of [2] (have 1, needed 2). Timeout: [100ms], request:")
79+
startsWith("[test][0] Not enough active copies to meet shard count of [2] (have 1, needed 2). Timeout: [100ms]")
8080
);
8181
// but really, all is well
8282
}
@@ -120,7 +120,7 @@ public void testReplicationWaitsForActiveShardCount() throws Exception {
120120
startsWith(
121121
"[test][0] Not enough active copies to meet shard count of ["
122122
+ ActiveShardCount.ALL
123-
+ "] (have 2, needed 3). Timeout: [100ms], request:"
123+
+ "] (have 2, needed 3). Timeout: [100ms]"
124124
)
125125
);
126126
// but really, all is well

server/src/main/java/org/opensearch/action/support/replication/ReplicationOperation.java

+1-9
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,7 @@ public void execute() throws Exception {
141141
final ShardRouting primaryRouting = primary.routingEntry();
142142
final ShardId primaryId = primaryRouting.shardId();
143143
if (activeShardCountFailure != null) {
144-
finishAsFailed(
145-
new UnavailableShardsException(
146-
primaryId,
147-
"{} Timeout: [{}], request: [{}]",
148-
activeShardCountFailure,
149-
request.timeout(),
150-
request
151-
)
152-
);
144+
finishAsFailed(new UnavailableShardsException(primaryId, "{} Timeout: [{}]", activeShardCountFailure, request.timeout()));
153145
return;
154146
}
155147

server/src/main/java/org/opensearch/action/support/replication/TransportReplicationAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,7 @@ void finishOnSuccess(Response response) {
12461246
}
12471247

12481248
void retryBecauseUnavailable(ShardId shardId, String message) {
1249-
retry(new UnavailableShardsException(shardId, "{} Timeout: [{}], request: [{}]", message, request.timeout(), request));
1249+
retry(new UnavailableShardsException(shardId, "{} Timeout: [{}]", message, request.timeout()));
12501250
}
12511251
}
12521252

server/src/main/java/org/opensearch/action/update/UpdateHelper.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import org.opensearch.index.shard.IndexShard;
5959
import org.opensearch.script.Script;
6060
import org.opensearch.script.ScriptService;
61+
import org.opensearch.script.ScriptType;
6162
import org.opensearch.script.UpdateScript;
6263
import org.opensearch.search.lookup.SourceLookup;
6364

@@ -128,7 +129,11 @@ Tuple<UpdateOpType, Map<String, Object>> executeScriptedUpsert(Map<String, Objec
128129

129130
if (operation != UpdateOpType.CREATE && operation != UpdateOpType.NONE) {
130131
// Only valid options for an upsert script are "create" (the default) or "none", meaning abort upsert
131-
logger.warn("Invalid upsert operation [{}] for script [{}], doing nothing...", operation, script.getIdOrCode());
132+
if (logger.isDebugEnabled() || ScriptType.STORED.equals(script.getType())) {
133+
logger.warn("Invalid upsert operation [{}] for script [{}], doing nothing...", operation, script.getIdOrCode());
134+
} else {
135+
logger.warn("Invalid upsert operation [{}] for given script", operation);
136+
}
132137
operation = UpdateOpType.NONE;
133138
}
134139

0 commit comments

Comments
 (0)