diff --git a/docs/changelog/136709.yaml b/docs/changelog/136709.yaml new file mode 100644 index 0000000000000..d15b4a9489a0b --- /dev/null +++ b/docs/changelog/136709.yaml @@ -0,0 +1,5 @@ +pr: 136709 +summary: Fix log formatting in `SnapshotLifecycleTask` +area: ILM+SLM +type: bug +issues: [] diff --git a/x-pack/plugin/slm/src/main/java/org/elasticsearch/xpack/slm/SnapshotLifecycleTask.java b/x-pack/plugin/slm/src/main/java/org/elasticsearch/xpack/slm/SnapshotLifecycleTask.java index 7e71c04f06391..739f58becb89c 100644 --- a/x-pack/plugin/slm/src/main/java/org/elasticsearch/xpack/slm/SnapshotLifecycleTask.java +++ b/x-pack/plugin/slm/src/main/java/org/elasticsearch/xpack/slm/SnapshotLifecycleTask.java @@ -265,8 +265,9 @@ public void onFailure(Exception e) { @Override public void onFailure(Exception e) { SnapshotHistoryStore.logErrorOrWarning( + logger, clusterService.state(), - () -> format("failed to create snapshot for snapshot lifecycle policy [{}]", policyMetadata.getPolicy().getId()), + () -> format("failed to create snapshot for snapshot lifecycle policy [%s]", policyMetadata.getPolicy().getId()), e ); final long timestamp = Instant.now().toEpochMilli(); diff --git a/x-pack/plugin/slm/src/main/java/org/elasticsearch/xpack/slm/history/SnapshotHistoryStore.java b/x-pack/plugin/slm/src/main/java/org/elasticsearch/xpack/slm/history/SnapshotHistoryStore.java index e004bdb5a9676..1302119005c4e 100644 --- a/x-pack/plugin/slm/src/main/java/org/elasticsearch/xpack/slm/history/SnapshotHistoryStore.java +++ b/x-pack/plugin/slm/src/main/java/org/elasticsearch/xpack/slm/history/SnapshotHistoryStore.java @@ -88,6 +88,7 @@ public void putAsync(SnapshotHistoryItem item) { ); }, exception -> logErrorOrWarning( + logger, clusterService.state(), () -> format("failed to index snapshot history item in data stream [%s]: [%s]", SLM_HISTORY_DATA_STREAM, item), exception @@ -95,6 +96,7 @@ public void putAsync(SnapshotHistoryItem item) { )); } catch (IOException exception) { logErrorOrWarning( + logger, clusterService.state(), () -> format("failed to index snapshot history item in data stream [%s]: [%s]", SLM_HISTORY_DATA_STREAM, item), exception @@ -103,7 +105,7 @@ public void putAsync(SnapshotHistoryItem item) { } // On node shutdown, some operations are expected to fail, we log a warning instead of error during node shutdown for those exceptions - public static void logErrorOrWarning(ClusterState clusterState, Supplier failureMsgSupplier, Exception exception) { + public static void logErrorOrWarning(Logger logger, ClusterState clusterState, Supplier failureMsgSupplier, Exception exception) { if (PluginShutdownService.isLocalNodeShutdown(clusterState)) { logger.warn(failureMsgSupplier, exception); } else {