Copilot commented on code in PR #1260:
URL:
https://github.com/apache/flink-kubernetes-operator/pull/1260#discussion_r4707520257
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/observer/JobStatusObserver.java:
##########
@@ -235,35 +267,69 @@ private void emitJobManagerExceptionEvent(
.forEach((k, v) -> annotations.put("failure-label-" + k,
v));
}
- StringBuilder eventMessage = new StringBuilder();
+ var operatorConfig = ctx.getOperatorConfig();
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,
+
operatorConfig.getReportedExceptionEventsMaxStackTraceLength(),
+
operatorConfig.getReportedExceptionEventsMaxStackTraceLines());
String identityKey =
- "jobmanager-exception-"
- +
Integer.toHexString(Objects.hash(eventMessage.toString()));
+ "jobmanager-exception-" +
Integer.toHexString(Objects.hash(eventMessage));
Review Comment:
Equal-length stack traces with the same retained prefix now share an event
key even when their omitted text differs. Because entries are emitted newest
first, an older collision overwrites the newer exception timestamp and can
cause duplicate reporting after an operator restart. Hash the original stack
trace for identity and truncate only the displayed message.
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/service/AbstractFlinkService.java:
##########
@@ -921,17 +924,36 @@ public RestClusterClient<String>
getClusterClient(Configuration conf) throws Exc
@Override
public JobExceptionsInfoWithHistory getJobExceptions(
- AbstractFlinkResource resource, JobID jobId, Configuration
observeConfig)
- throws IOException {
+ AbstractFlinkResource resource,
+ JobID jobId,
+ int maxExceptions,
+ MemorySize maxResponseSize,
+ Configuration observeConfig)
+ throws Exception {
JobExceptionsHeaders jobExceptionsHeaders =
JobExceptionsHeaders.getInstance();
JobExceptionsMessageParameters params = new
JobExceptionsMessageParameters();
params.jobPathParameter.resolve(jobId);
-
- try (var clusterClient = getClusterClient(observeConfig)) {
+ // The upper limit parameter field is private before Flink 2.4
(FLINK-39711)
+ params.getQueryParameters().stream()
+ .filter(UpperLimitExceptionParameter.class::isInstance)
+ .map(UpperLimitExceptionParameter.class::cast)
+ .forEach(parameter ->
parameter.resolve(List.of(maxExceptions)));
+
+ // The REST client rejects a larger response before reading its body,
and needs a limit of
+ // at least one byte
+ var conf = new Configuration(observeConfig);
+ conf.set(
+ RestOptions.CLIENT_MAX_CONTENT_LENGTH,
+ (int) Math.min(Integer.MAX_VALUE, Math.max(1L,
maxResponseSize.getBytes())));
Review Comment:
This unconditionally replaces an explicitly configured lower
`RestOptions.CLIENT_MAX_CONTENT_LENGTH`, so a 1 MiB client cap becomes 10 MiB
under the new default for exception-history requests. Preserve the stricter
explicit limit and report the effective cap in the warning, rather than
silently relaxing the existing memory safeguard.
--
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]