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


##########
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:
   The event message is capped now, but `emitJobManagerExceptionEvent` still 
copies `task-name` and `failure-label-*` into annotations, and 
`K8sAnnotationsSanitizer` does not limit value length. Both come from the job, 
so they can be as large as the message was. Could they 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