Skip to content

Commit 9119d73

Browse files
committed
[FLINK-34957][autoscaler] Event handler records the exception stack trace when exception message is null
1 parent 96f8b20 commit 9119d73

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

flink-autoscaler-standalone/src/main/java/org/apache/flink/autoscaler/standalone/StandaloneAutoscalerExecutor.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,7 @@ protected void scalingSingleJob(Context jobContext) {
141141
autoScaler.scale(jobContext);
142142
} catch (Throwable e) {
143143
LOG.error("Error while scaling job", e);
144-
eventHandler.handleEvent(
145-
jobContext,
146-
AutoScalerEventHandler.Type.Warning,
147-
AUTOSCALER_ERROR,
148-
e.getMessage(),
149-
null,
150-
null);
144+
eventHandler.handleException(jobContext, AUTOSCALER_ERROR, e);
151145
} finally {
152146
MDC.clear();
153147
}

flink-autoscaler/src/main/java/org/apache/flink/autoscaler/JobAutoScalerImpl.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,7 @@ private void runScalingLogic(Context ctx, AutoscalerFlinkMetrics autoscalerMetri
228228
private void onError(Context ctx, AutoscalerFlinkMetrics autoscalerMetrics, Throwable e) {
229229
LOG.error("Error while scaling job", e);
230230
autoscalerMetrics.incrementError();
231-
eventHandler.handleEvent(
232-
ctx,
233-
AutoScalerEventHandler.Type.Warning,
234-
AUTOSCALER_ERROR,
235-
e.getMessage(),
236-
null,
237-
null);
231+
eventHandler.handleException(ctx, AUTOSCALER_ERROR, e);
238232
}
239233

240234
private AutoscalerFlinkMetrics getOrInitAutoscalerFlinkMetrics(Context ctx) {

flink-autoscaler/src/main/java/org/apache/flink/autoscaler/event/AutoScalerEventHandler.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
import org.apache.flink.autoscaler.ScalingSummary;
2323
import org.apache.flink.runtime.jobgraph.JobVertexID;
2424

25+
import org.apache.commons.lang3.StringUtils;
26+
import org.apache.commons.lang3.exception.ExceptionUtils;
27+
2528
import javax.annotation.Nullable;
2629

2730
import java.time.Duration;
@@ -63,6 +66,17 @@ void handleEvent(
6366
@Nullable String messageKey,
6467
@Nullable Duration interval);
6568

69+
/**
70+
* Handle exception, and the exception event is warning type and don't deduplicate by default.
71+
*/
72+
default void handleException(Context context, String reason, Throwable e) {
73+
var message = e.getMessage();
74+
if (message == null) {
75+
message = StringUtils.abbreviate(ExceptionUtils.getStackTrace(e), 2048);
76+
}
77+
handleEvent(context, Type.Warning, reason, message, null, null);
78+
}
79+
6680
/**
6781
* Handle scaling reports.
6882
*

0 commit comments

Comments
 (0)