You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "1996fanrui (via GitHub)" <gi...@apache.org> on 2024/03/28 06:11:18 UTC

[PR] [FLINK-34957][autoscaler] Event handler records the exception stack trace when exception message is null [flink-kubernetes-operator]

1996fanrui opened a new pull request, #808:
URL: https://github.com/apache/flink-kubernetes-operator/pull/808

   ## What is the purpose of the change
   
   DBC Autoscaler event handler doesn't allow the event message is null, but the message may be null when we handle the exception.
   
   We consider the exception message as the event message, but the exception message may be null, such as: TimeoutException. (It has been shown in following picture.)
   
   Also, ecording a event without any message is meaningless. It doesn't have any benefit for troubleshooting.
   
   
   
   ## Brief change log
   
   - [FLINK-34957][autoscaler] Event handler records the exception stack trace when exception message is null
     - Consider the exception message as the event message when exception message isn't null
     - The whole Exception as the event message if exception message is null.
   
   ## Verifying this change
   
   Test manually, it works well. We can see the detailed exception from the `LoggingEventHandler`.
   
   <img width="1630" alt="image" src="https://github.com/apache/flink-kubernetes-operator/assets/38427477/ff4ed621-241e-43f5-a4a2-b4fb322f07ea">
   
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency):  no
     - The public API, i.e., is any changes to the `CustomResourceDescriptors`: no
     - Core observer or reconciler logic that is regularly executed: no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? no
   
   


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-34957][autoscaler] Event handler records the exception stack trace when exception message is null [flink-kubernetes-operator]

Posted by "1996fanrui (via GitHub)" <gi...@apache.org>.
1996fanrui commented on code in PR #808:
URL: https://github.com/apache/flink-kubernetes-operator/pull/808#discussion_r1542554907


##########
flink-autoscaler/src/main/java/org/apache/flink/autoscaler/event/AutoScalerEventHandler.java:
##########
@@ -63,6 +65,19 @@ void handleEvent(
             @Nullable String messageKey,
             @Nullable Duration interval);
 
+    /**
+     * Handle exception, and the exception event is warning type and don't deduplicate by default.
+     */
+    default void handleException(Context context, String reason, Throwable e) {
+        var message = e.getMessage();
+        if (message == null) {
+            var stream = new ByteArrayOutputStream();
+            e.printStackTrace(new PrintStream(stream));
+            message = stream.toString();

Review Comment:
   Thanks @gyfora for the quick review and good suggestion!
   
   > Can be replaced with ExceptionUtils.getStackTrace(e) from apache commons or ExceptionUtis.stringifyException from flink utils
   
   Done~
   
   > we should also set some reasonable (relatively small) limit on the string size here otherwise we might get an error when inserting the Kube event / db column
   
   I saw the default value of `kubernetes.operator.exception.stacktrace.max.length` is 2048, so I use it here.
   
   And I didn't extract an autoscaler option for it unless it's needed in the future.



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-34957][autoscaler] Event handler records the exception stack trace when exception message is null [flink-kubernetes-operator]

Posted by "gyfora (via GitHub)" <gi...@apache.org>.
gyfora commented on code in PR #808:
URL: https://github.com/apache/flink-kubernetes-operator/pull/808#discussion_r1542518890


##########
flink-autoscaler/src/main/java/org/apache/flink/autoscaler/event/AutoScalerEventHandler.java:
##########
@@ -63,6 +65,19 @@ void handleEvent(
             @Nullable String messageKey,
             @Nullable Duration interval);
 
+    /**
+     * Handle exception, and the exception event is warning type and don't deduplicate by default.
+     */
+    default void handleException(Context context, String reason, Throwable e) {
+        var message = e.getMessage();
+        if (message == null) {
+            var stream = new ByteArrayOutputStream();
+            e.printStackTrace(new PrintStream(stream));
+            message = stream.toString();

Review Comment:
   Can be replaced with `ExceptionUtils.getStackTrace(e)` from apache commons  or ExceptionUtis.stringifyException from flink utils



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-34957][autoscaler] Event handler records the exception stack trace when exception message is null [flink-kubernetes-operator]

Posted by "1996fanrui (via GitHub)" <gi...@apache.org>.
1996fanrui merged PR #808:
URL: https://github.com/apache/flink-kubernetes-operator/pull/808


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-34957][autoscaler] Event handler records the exception stack trace when exception message is null [flink-kubernetes-operator]

Posted by "gyfora (via GitHub)" <gi...@apache.org>.
gyfora commented on code in PR #808:
URL: https://github.com/apache/flink-kubernetes-operator/pull/808#discussion_r1542520539


##########
flink-autoscaler/src/main/java/org/apache/flink/autoscaler/event/AutoScalerEventHandler.java:
##########
@@ -63,6 +65,19 @@ void handleEvent(
             @Nullable String messageKey,
             @Nullable Duration interval);
 
+    /**
+     * Handle exception, and the exception event is warning type and don't deduplicate by default.
+     */
+    default void handleException(Context context, String reason, Throwable e) {
+        var message = e.getMessage();
+        if (message == null) {
+            var stream = new ByteArrayOutputStream();
+            e.printStackTrace(new PrintStream(stream));
+            message = stream.toString();

Review Comment:
   we should also set some reasonable (relatively small) limit on the string size here otherwise we might get an error when inserting the Kube event / db column



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org