peter-toth commented on code in PR #514:
URL: 
https://github.com/apache/spark-kubernetes-operator/pull/514#discussion_r2845643638


##########
spark-operator-api/src/main/java/org/apache/spark/k8s/operator/status/AttemptInfo.java:
##########
@@ -40,13 +53,41 @@
 public class AttemptInfo {
   @Getter @Builder.Default protected final long id = 0L;
   @Getter @Setter protected long restartCounter;
+  @Getter @Setter protected long failureRestartCounter;
+  @Getter @Setter protected long schedulingFailureRestartCounter;
 
   /**
    * Creates a new AttemptInfo object representing the next attempt.
-   *
-   * @return A new AttemptInfo with an incremented ID.
    */
-  public AttemptInfo createNextAttemptInfo(boolean resetRestartCounter) {
-    return new AttemptInfo(id + 1L, resetRestartCounter ? 1L : restartCounter 
+ 1);
+  public AttemptInfo createNextAttemptInfo(
+      boolean resetRestartCounter, ApplicationStateSummary 
currentStateSummary) {
+    long newRestartCounter = resetRestartCounter ? 1L : restartCounter + 1;
+    long newFailureCounter;
+    long newSchedulingFailureCounter;
+
+    if (resetRestartCounter) {
+      // Reset all counters when restart counter is reset
+      newRestartCounter = 1L;

Review Comment:
   I wonder if it would make sense to merge this `if ... else if ...` logic 
with the logic in `terminateOrRestart()`?
   I mean, you are calculating `exceededLimit` / `stateMessage` based on 
`ApplicationStateSummary` there, and you are kind of calculating the new 
counters based on `ApplicationStateSummary` here in 
`AttemptInfo.createNextAttemptInfo()`. But `createNextAttemptInfo()` gets 
invoked only from `terminateOrRestart()`, so would it make sense to drop 
`createNextAttemptInfo()` entirelly, calculate everyting in 
`terminateOrRestart()` and keep `AttemptInfo` as a simple data class?



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to