spuru9 commented on code in PR #1260:
URL: 
https://github.com/apache/flink-kubernetes-operator/pull/1260#discussion_r4720841905


##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/observer/JobStatusObserver.java:
##########
@@ -231,35 +274,50 @@ private void emitJobManagerExceptionEvent(
                     .forEach((k, v) -> annotations.put("failure-label-" + k, 
v));
         }
 
-        StringBuilder eventMessage = new StringBuilder();
         String stacktrace = exception.getStacktrace();
-        if (stacktrace != null && !stacktrace.isBlank()) {
-            String[] lines = stacktrace.split("\n");
-            for (int i = 0; i < Math.min(maxStackTraceLines, lines.length); 
i++) {
-                eventMessage.append(lines[i]).append("\n");
-            }
-            if (lines.length > maxStackTraceLines) {
-                eventMessage
-                        .append("... (")
-                        .append(lines.length - maxStackTraceLines)
-                        .append(" more lines)");
-            }
-        }
-
+        String eventMessage =
+                stacktrace == null || stacktrace.isBlank()
+                        ? ""
+                        : truncateExceptionText(
+                                stacktrace,
+                                ctx.getOperatorConfig()
+                                        
.getReportedExceptionEventsMaxStackTraceLength());
+
+        // The full stack trace tells apart exceptions that only differ in the 
truncated text
         String identityKey =
-                "jobmanager-exception-"
-                        + 
Integer.toHexString(Objects.hash(eventMessage.toString()));
+                "jobmanager-exception-" + 
Integer.toHexString(Objects.hash(stacktrace));
         eventRecorder.triggerEventWithAnnotations(
                 ctx.getResource(),
                 EventRecorder.Type.Warning,
                 EventRecorder.Reason.JobException,
-                eventMessage.toString().trim(),
+                eventMessage.trim(),
                 EventRecorder.Component.Job,
                 identityKey,
                 ctx.getKubernetesClient(),
                 K8sAnnotationsSanitizer.sanitizeAnnotations(annotations));

Review Comment:
   Good catch, the task name and failure labels now get the same cap.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to