-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
INFO logging of snapshot restore and completion #88257
INFO logging of snapshot restore and completion #88257
Conversation
But DEBUG (silent) logging of snapshot restore/completion when done in the context of CCR or searchable snapshots. Fixes elastic#86610
docs/reference/snapshot-restore/apis/restore-snapshot-api.asciidoc
Outdated
Show resolved
Hide resolved
@@ -1051,6 +1053,7 @@ public ClusterState execute(ClusterState currentState) { | |||
boolean changed = false; | |||
for (RestoreInProgress.Entry entry : currentState.custom(RestoreInProgress.TYPE, RestoreInProgress.EMPTY)) { | |||
if (entry.state().completed()) { | |||
logger.log(entry.silent() ? Level.DEBUG : Level.INFO, "restore of snapshot [{}] completed", entry.snapshot()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fcofdez suggested to me this is a nice place to log the completion of a snapshot restore. This meant passing the silent property from the RestoreSnapshotRequest
to RestoreInProgress.Entry
so that we can read the silent parameter here.
Hi. Adding @DaveCTurner as reviewer (since he created the issue) and @original-brownbear as another reviewer (since you have experience with snapshot restores AFAIK). I manually tested this in this way:
Feel free to tell me:
|
Pinging @elastic/es-distributed (Team:Distributed) |
Hi @kingherc, I've created a changelog YAML for you. |
OK, I understand I should have added you as reviewers after the CI passes -- will keep that in mind. After conversing a bit, I also understand that in order to fix the CI bwc failures, I should (a) not expose the silent parameter in XContent, and (b) add |
++ yes we shouldn't see this parameter in anything user-facing (particularly this means neither in docs nor XContent1) and the wire-format change needs version guards. When receiving a transport message from an older node I suggest just treating the missing Footnotes
|
Hi @original-brownbear and @DaveCTurner , CI passed. Feel free to review. |
...in/java/org/elasticsearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I left a couple of small suggestions.
I'd like to have a test which asserts that we do actually report the log message we're adding at the right level. I think you can add a test case in RestoreSnapshotIT
for that.
...in/java/org/elasticsearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java
Outdated
Show resolved
Hide resolved
...in/java/org/elasticsearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java
Outdated
Show resolved
Hide resolved
...in/java/org/elasticsearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java
Outdated
Show resolved
Hide resolved
.../org/elasticsearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequestBuilder.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/cluster/RestoreInProgress.java
Outdated
Show resolved
Hide resolved
@DaveCTurner incorporated your feedback. Feel free to review. @original-brownbear feel free to also review if you'd like. Thanks! |
Gentle reminder for review @original-brownbear , @DaveCTurner |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay here @kingherc, this all looks good although I've one question about the test you added.
mockLogAppender.addExpectation(new MockLogAppender.LoggingExpectation() { | ||
String startMessageSnapshot; | ||
Object startMessageIndicesList; | ||
String completionMessageSnapshot; | ||
|
||
@Override | ||
public void match(LogEvent event) { | ||
final String message = event.getMessage().getFormattedMessage(); | ||
if (message.startsWith("started restore of snapshot")) { | ||
startMessageSnapshot = event.getMessage().getParameters()[0].toString(); | ||
startMessageIndicesList = event.getMessage().getParameters()[1]; | ||
} else if (message.startsWith("completed restore of snapshot")) { | ||
completionMessageSnapshot = event.getMessage().getParameters()[0].toString(); | ||
} | ||
} | ||
|
||
@Override | ||
public void assertMatched() { | ||
assertThat(startMessageSnapshot, startsWith(snapshotName)); | ||
assertEquals(Arrays.asList(indexName), startMessageIndicesList); | ||
assertThat(completionMessageSnapshot, startsWith(snapshotName)); | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be clearer to write this as two regular SeenEventExpectation
expectations with the actual message we expect (maybe with some *
wildcards) instead of doing this. But maybe I've missed some subtlety about why we're doing it this way.
Done this way I think the fields would need to be volatile
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* upstream/master: (38 commits) Simplify map copying (elastic#88432) Make DiffableUtils.diff implementation agnostic (elastic#88403) Ingest: Start separating Metadata from IngestSourceAndMetadata (elastic#88401) Move runtime fields base scripts out of scripting fields api package. (elastic#88488) Enable TRACE Logging for test and increase timeout (elastic#88477) Mute ReactiveStorageIT#testScaleDuringSplitOrClone (elastic#88480) Track the count of failed invocations since last successful policy snapshot (elastic#88398) Avoid noisy exceptions on data nodes when aborting snapshots (elastic#88476) Fix ReactiveStorageDeciderServiceTests testNodeSizeForDataBelowLowWatermark (elastic#88452) INFO logging of snapshot restore and completion (elastic#88257) unmute test (elastic#88454) Updatable API keys - noop check (elastic#88346) Corrected an incomplete sentence. (elastic#86542) Use consistent shard map type in IndexService (elastic#88465) Stop registering TestGeoShapeFieldMapperPlugin in ESIntegTestCase (elastic#88460) TSDB: RollupShardIndexer logging improvements (elastic#88416) Audit API key ID when create or grant API keys (elastic#88456) Bound random negative size test in SearchSourceBuilderTests#testNegativeSizeErrors (elastic#88457) Updatable API keys - logging audit trail event (elastic#88276) Polish reworked LoggedExec task (elastic#88424) ... # Conflicts: # x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/RollupShardIndexer.java
But DEBUG (silent) logging of snapshot restore/completion when
done in the context of CCR or searchable snapshots.
Fixes #86610