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


##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/config/FlinkOperatorConfiguration.java:
##########
@@ -81,6 +83,8 @@ public class FlinkOperatorConfiguration {
     Duration slowRequestThreshold;
     int reportedExceptionEventsMaxCount;
     int reportedExceptionEventsMaxStackTraceLength;
+    @Nullable Integer reportedExceptionEventsMaxStackTraceLines;

Review Comment:
   Why not to use `int` here instead of `@Nullable Integer`?



##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/config/FlinkOperatorConfiguration.java:
##########
@@ -210,7 +214,17 @@ public static FlinkOperatorConfiguration 
fromConfiguration(Configuration operato
                 
operatorConfig.get(KubernetesOperatorConfigOptions.OPERATOR_EVENT_EXCEPTION_LIMIT);
         int reportedExceptionEventsMaxStackTraceLength =
                 operatorConfig.get(
-                        
KubernetesOperatorConfigOptions.OPERATOR_EVENT_EXCEPTION_STACKTRACE_LINES);
+                        KubernetesOperatorConfigOptions
+                                
.OPERATOR_EVENT_EXCEPTION_STACKTRACE_MAX_LENGTH);
+        Integer reportedExceptionEventsMaxStackTraceLines =
+                operatorConfig
+                        .getOptional(
+                                KubernetesOperatorConfigOptions
+                                        
.OPERATOR_EVENT_EXCEPTION_STACKTRACE_LINES)
+                        .orElse(null);

Review Comment:
   There is no need to use getOptional here. The `get` call already does this. 
So the code here can simply be the following:
   ```suggestion
           Integer reportedExceptionEventsMaxStackTraceLines =
                   operatorConfig
                           .get(
                                   KubernetesOperatorConfigOptions
                                           
.OPERATOR_EVENT_EXCEPTION_STACKTRACE_LINES);
   ```



##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/observer/JobStatusObserver.java:
##########
@@ -123,12 +130,17 @@ protected void 
observeJobManagerExceptions(FlinkResourceContext<R> ctx) {
 
         try {
             var jobId = JobID.fromHexString(jobStatus.getJobId());
-            // TODO: Ideally the best way to restrict the number of events is 
to use the query param
-            // `maxExceptions`
-            //  but the JobExceptionsMessageParameters does not expose the 
parameters and nor does
-            // it have setters.
+            int maxEvents = 
operatorConfig.getReportedExceptionEventsMaxCount();
+            // One more entry than can be reported, so that a truncated 
history is still detected
+            int maxExceptions = (int) Math.min(Integer.MAX_VALUE, Math.max(0L, 
maxEvents) + 1);

Review Comment:
   Good addition here for the unexpected values. Can you also add test coverage 
for these cases?



-- 
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