1996fanrui commented on code in PR #759: URL: https://github.com/apache/flink-kubernetes-operator/pull/759#discussion_r1470619716
########## flink-autoscaler/src/main/java/org/apache/flink/autoscaler/ScalingMetricCollector.java: ########## @@ -181,9 +186,12 @@ private static Instant getWindowFullTime( } @VisibleForTesting - protected Instant getJobUpdateTs(JobDetailsInfo jobDetailsInfo) { - return Instant.ofEpochMilli( - jobDetailsInfo.getTimestamps().values().stream().max(Long::compare).get()); + protected Instant getJobSwitchToRunningTs(JobDetailsInfo jobDetailsInfo) { + final Map<JobStatus, Long> timestamps = jobDetailsInfo.getTimestamps(); + + final Long runningTs = timestamps.get(JobStatus.RUNNING); + checkState(runningTs != null, "Unable to find when the job was switched to RUNNING."); Review Comment: Yeah, I see this code only be called when the job is running. I updated it for 2 reasons: 1. This job may be failed during scaling. And `jobDetailsInfo` is fetched by rest api, the latest status may be not RUNNING. 2. As you mentioned, it will more robust if we have some refactors 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-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org