Skip to content

Commit

Permalink
Remove user data from logs when not in debug/trace mode (opensearch-p…
Browse files Browse the repository at this point in the history
…roject#17007)

* Remove user data from logs when not in debug/trace mode

Signed-off-by: Mohit Godwani <mgodwan@amazon.com>
  • Loading branch information
mgodwan authored Jan 16, 2025
1 parent 34ef146 commit 13159c1
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

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

if (operation != UpdateOpType.CREATE && operation != UpdateOpType.NONE) {
// Only valid options for an upsert script are "create" (the default) or "none", meaning abort upsert
logger.warn("Invalid upsert operation [{}] for script [{}], doing nothing...", operation, script.getIdOrCode());
if (logger.isDebugEnabled() || ScriptType.STORED.equals(script.getType())) {
logger.warn("Invalid upsert operation [{}] for script [{}], doing nothing...", operation, script.getIdOrCode());
} else {
logger.warn("Invalid upsert operation [{}] for given script", operation);
}
operation = UpdateOpType.NONE;
}

Expand Down

0 comments on commit 13159c1

Please sign in to comment.