vsantwana commented on code in PR #983:
URL:
https://github.com/apache/flink-kubernetes-operator/pull/983#discussion_r2108275549
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/observer/JobStatusObserver.java:
##########
@@ -132,8 +134,50 @@ protected void
observeJobManagerExceptions(FlinkResourceContext<R> ctx) {
}
var exceptionHistory = history.getExceptionHistory();
- List<JobExceptionsInfoWithHistory.RootExceptionInfo> exceptions =
- exceptionHistory.getEntries();
+ var exceptions = exceptionHistory.getEntries();
+
+ String currentJobId = jobStatus.getJobId();
+ var cacheEntry = ctx.getExceptionCacheEntry();
+
+ if (!cacheEntry.isInitialized()) {
+
+ Instant lastExceptionTs;
+ if (exceptions == null || exceptions.isEmpty()) {
+ // If the job doesn't have any exceptions set to MIN as we
always have to record
+ // the next
+ lastExceptionTs = Instant.MIN;
+ } else {
+ var k8sExpirationTs =
Instant.now().minus(MAX_K8S_EVENT_AGE);
+ var maxJobExceptionTs =
+ exceptions.stream()
+ .map(e ->
Instant.ofEpochMilli(e.getTimestamp()))
+ .max(Comparator.naturalOrder())
+ .orElseThrow();
+
+ if (maxJobExceptionTs.isBefore(k8sExpirationTs)) {
+ // If the last job exception was a long time ago, then
there is no point in
+ // checking in k8s.
+ lastExceptionTs = maxJobExceptionTs;
+ } else {
+ // If there were recent exceptions, we check the
triggered events from kube
+ // to make sure we don't double trigger
+ lastExceptionTs =
+ EventUtils.findLastJobExceptionTsFromK8s(
+ ctx.getKubernetesClient(),
resource)
+
.orElse(Instant.now().minus(MAX_K8S_EVENT_AGE));
Review Comment:
```suggestion
.orElse(Instant.now().minus(k8sExpirationTs));
```
--
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]