Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@

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())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why check for stored script here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of stored script, id gets logged which should be fine as it shouldn't expose user data and continues to help with debugging. For inline scripts in request, we may end up logging the entire user provided script here. Hence, kept this check to ensure some debuggability,

logger.warn("Invalid upsert operation [{}] for script [{}], doing nothing...", operation, script.getIdOrCode());

Check warning on line 133 in server/src/main/java/org/opensearch/action/update/UpdateHelper.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L133 was not covered by tests
} else {
logger.warn("Invalid upsert operation [{}] for given script", operation);

Check warning on line 135 in server/src/main/java/org/opensearch/action/update/UpdateHelper.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L135 was not covered by tests
}
operation = UpdateOpType.NONE;
}

Expand Down
Loading