wangyang0918 commented on code in PR #200:
URL:
https://github.com/apache/flink-kubernetes-operator/pull/200#discussion_r871937334
##########
examples/basic-checkpoint-ha.yaml:
##########
@@ -21,11 +21,13 @@ kind: FlinkDeployment
metadata:
name: basic-checkpoint-ha-example
spec:
+ serviceAccount: flink
Review Comment:
Duplicated service account.
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/service/FlinkService.java:
##########
@@ -528,6 +538,71 @@ public void triggerSavepoint(
}
}
+ public Optional<Savepoint> getLastCheckpoint(JobID jobId, Configuration
conf) throws Exception {
+ try (RestClusterClient<String> clusterClient =
+ (RestClusterClient<String>) getClusterClient(conf)) {
+
+ var headers = CustomCheckpointingStatisticsHeaders.getInstance();
+ var params = headers.getUnresolvedMessageParameters();
+ params.jobPathParameter.resolve(jobId);
+
+ CompletableFuture<CheckpointHistoryWrapper> response =
+ clusterClient.sendRequest(headers, params,
EmptyRequestBody.getInstance());
+
+ var checkpoints =
+ response.get(
+ configManager
+ .getOperatorConfiguration()
+ .getFlinkClientTimeout()
+ .getSeconds(),
+ TimeUnit.SECONDS);
+
+ var latestCheckpointOpt =
+ checkpoints.getHistory().stream()
+ .filter(
+ cp ->
+ CheckpointStatsStatus.valueOf(
+ cp.get(
+
CheckpointStatistics
+
.FIELD_NAME_STATUS)
+ .asText())
+ ==
CheckpointStatsStatus.COMPLETED)
+ .filter(
+ cp ->
+ !cp.get(
+
CheckpointStatistics
+
.CompletedCheckpointStatistics
+
.FIELD_NAME_EXTERNAL_PATH)
+ .asText()
+ .equals(
+
NonPersistentMetadataCheckpointStorageLocation
+
.EXTERNAL_POINTER))
+ .max(
+ Comparator.comparingLong(
+ cp ->
+
cp.get(CheckpointStatistics.FIELD_NAME_ID)
+ .asLong()))
+ .map(
+ cp ->
+ new Savepoint(
Review Comment:
I am not pretty sure whether we could wrap the checkpoint as the `Savepoint`
and store in the `.status.SavepointInfo`. It is a little misleading since
savepoint is usually triggered by user manually and is consistent between Flink
major versions.
--
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]