This is an automated email from the ASF dual-hosted git repository.
fanrui pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/flink-kubernetes-operator.git
The following commit(s) were added to refs/heads/main by this push:
new f67cba9c [FLINK-34021][autoscaler] Print jobKey in the Autoscaler
standalone log
f67cba9c is described below
commit f67cba9c8269ddd4e27fcdc40cfd8a293ae665de
Author: Rui Fan <[email protected]>
AuthorDate: Mon Jan 8 22:59:06 2024 +0800
[FLINK-34021][autoscaler] Print jobKey in the Autoscaler standalone log
---
.../flink/autoscaler/standalone/StandaloneAutoscalerExecutor.java | 4 ++++
flink-autoscaler-standalone/src/main/resources/log4j2.properties | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git
a/flink-autoscaler-standalone/src/main/java/org/apache/flink/autoscaler/standalone/StandaloneAutoscalerExecutor.java
b/flink-autoscaler-standalone/src/main/java/org/apache/flink/autoscaler/standalone/StandaloneAutoscalerExecutor.java
index 286c78ca..74109ac3 100644
---
a/flink-autoscaler-standalone/src/main/java/org/apache/flink/autoscaler/standalone/StandaloneAutoscalerExecutor.java
+++
b/flink-autoscaler-standalone/src/main/java/org/apache/flink/autoscaler/standalone/StandaloneAutoscalerExecutor.java
@@ -28,6 +28,7 @@ import
org.apache.flink.shaded.guava30.com.google.common.util.concurrent.ThreadF
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
import javax.annotation.Nonnull;
@@ -136,6 +137,7 @@ public class StandaloneAutoscalerExecutor<KEY, Context
extends JobAutoScalerCont
@VisibleForTesting
protected void scalingSingleJob(Context jobContext) {
try {
+ MDC.put("job.key", jobContext.getJobKey().toString());
autoScaler.scale(jobContext);
} catch (Throwable e) {
LOG.error("Error while scaling job", e);
@@ -146,6 +148,8 @@ public class StandaloneAutoscalerExecutor<KEY, Context
extends JobAutoScalerCont
e.getMessage(),
null,
null);
+ } finally {
+ MDC.clear();
}
}
}
diff --git a/flink-autoscaler-standalone/src/main/resources/log4j2.properties
b/flink-autoscaler-standalone/src/main/resources/log4j2.properties
index 4a6ab832..8663a2be 100644
--- a/flink-autoscaler-standalone/src/main/resources/log4j2.properties
+++ b/flink-autoscaler-standalone/src/main/resources/log4j2.properties
@@ -23,5 +23,5 @@ rootLogger.appenderRef.console.ref = ConsoleAppender
appender.console.name = ConsoleAppender
appender.console.type = CONSOLE
appender.console.layout.type = PatternLayout
-appender.console.layout.pattern = %style{%d}{yellow} %style{%-30c{1.}}{cyan}
%highlight{[%-5level] [%X{resource.namespace}.%X{resource.name}]
%msg%n%throwable}
+appender.console.layout.pattern = %style{%d}{yellow} %style{%-30c{1.}}{cyan}
%highlight{[%-5level] [%X{job.key}] %msg%n%throwable}