You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ha...@apache.org on 2023/12/14 01:50:53 UTC

(flink) branch master updated: [FLINK-33723][checkpoint] Disallow triggering incremental checkpoint explicitly from REST API (#23853)

This is an automated email from the ASF dual-hosted git repository.

hangxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/master by this push:
     new 07d159bfb09 [FLINK-33723][checkpoint] Disallow triggering incremental checkpoint explicitly from REST API (#23853)
07d159bfb09 is described below

commit 07d159bfb09f5a6afeb44ac7dacb1cc657e0b0bf
Author: Zakelly <za...@gmail.com>
AuthorDate: Sat Dec 2 01:15:24 2023 +0800

    [FLINK-33723][checkpoint] Disallow triggering incremental checkpoint explicitly from REST API (#23853)
---
 .../shortcodes/generated/rest_v1_dispatcher.html   |  2 +-
 docs/static/generated/rest_v1_dispatcher.yml       |  5 ++-
 .../job/checkpoints/CheckpointHandlers.java        | 11 ++++--
 .../checkpoints/CheckpointTriggerHeaders.java      |  4 +-
 .../job/checkpoints/CheckpointHandlersTest.java    | 43 ++++++++++++++++++++++
 5 files changed, 57 insertions(+), 8 deletions(-)

diff --git a/docs/layouts/shortcodes/generated/rest_v1_dispatcher.html b/docs/layouts/shortcodes/generated/rest_v1_dispatcher.html
index a96b18f5d51..654213a3d2f 100644
--- a/docs/layouts/shortcodes/generated/rest_v1_dispatcher.html
+++ b/docs/layouts/shortcodes/generated/rest_v1_dispatcher.html
@@ -1829,7 +1829,7 @@ Using 'curl' you can upload a jar via 'curl -X POST -H "Expect:" -F "jarfile=@pa
       <td class="text-left">Response code: <code>202 Accepted</code></td>
     </tr>
     <tr>
-      <td colspan="2">Triggers a checkpoint. This async operation would return a 'triggerid' for further query identifier.</td>
+      <td colspan="2">Triggers a checkpoint. The 'checkpointType' parameter does not support 'INCREMENTAL' option for now. See FLINK-33723. This async operation would return a 'triggerid' for further query identifier.</td>
     </tr>
     <tr>
       <td colspan="2">Path parameters</td>
diff --git a/docs/static/generated/rest_v1_dispatcher.yml b/docs/static/generated/rest_v1_dispatcher.yml
index 62d298241c1..8b0050266a8 100644
--- a/docs/static/generated/rest_v1_dispatcher.yml
+++ b/docs/static/generated/rest_v1_dispatcher.yml
@@ -491,8 +491,9 @@ paths:
               schema:
                 $ref: '#/components/schemas/CheckpointingStatistics'
     post:
-      description: Triggers a checkpoint. This async operation would return a 'triggerid'
-        for further query identifier.
+      description: Triggers a checkpoint. The 'checkpointType' parameter does not
+        support 'INCREMENTAL' option for now. See FLINK-33723. This async operation
+        would return a 'triggerid' for further query identifier.
       operationId: triggerCheckpoint
       parameters:
       - name: jobid
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/job/checkpoints/CheckpointHandlers.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/job/checkpoints/CheckpointHandlers.java
index 871a2dfdabf..0f572ad9059 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/job/checkpoints/CheckpointHandlers.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/job/checkpoints/CheckpointHandlers.java
@@ -140,10 +140,13 @@ public class CheckpointHandlers {
                 throws RestHandlerException {
             final AsynchronousJobOperationKey operationKey = createOperationKey(request);
 
-            return gateway.triggerCheckpoint(
-                            operationKey,
-                            request.getRequestBody().getCheckpointType(),
-                            RpcUtils.INF_TIMEOUT)
+            CheckpointType checkpointType = request.getRequestBody().getCheckpointType();
+            if (checkpointType == CheckpointType.INCREMENTAL) {
+                throw new IllegalStateException(
+                        "Flink does not support triggering incremental checkpoint explicitly."
+                                + " See FLINK-33723.");
+            }
+            return gateway.triggerCheckpoint(operationKey, checkpointType, RpcUtils.INF_TIMEOUT)
                     .handle(
                             (acknowledge, throwable) -> {
                                 if (throwable == null) {
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/checkpoints/CheckpointTriggerHeaders.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/checkpoints/CheckpointTriggerHeaders.java
index 6592e67f06d..6845b5cfd6d 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/checkpoints/CheckpointTriggerHeaders.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/checkpoints/CheckpointTriggerHeaders.java
@@ -63,7 +63,9 @@ public class CheckpointTriggerHeaders
 
     @Override
     protected String getAsyncOperationDescription() {
-        return "Triggers a checkpoint.";
+        return "Triggers a checkpoint."
+                + " The 'checkpointType' parameter does not support 'INCREMENTAL' option for now."
+                + " See FLINK-33723.";
     }
 
     @Override
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/job/checkpoints/CheckpointHandlersTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/job/checkpoints/CheckpointHandlersTest.java
index 1d8ff996963..73857dd9520 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/job/checkpoints/CheckpointHandlersTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/job/checkpoints/CheckpointHandlersTest.java
@@ -58,6 +58,7 @@ import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.atomic.AtomicReference;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 /** Test for {@link CheckpointHandlers}. */
 class CheckpointHandlersTest {
@@ -190,6 +191,48 @@ class CheckpointHandlersTest {
         assertThat(checkpointTypeFuture.get()).isEqualTo(CheckpointType.DEFAULT);
     }
 
+    @Test
+    void testDisallowTriggeringIncrementalCheckpoint() throws Exception {
+        final OperationResult<Long> successfulResult =
+                OperationResult.success(COMPLETED_CHECKPOINT_ID);
+        final CompletableFuture<CheckpointType> checkpointTypeFuture = new CompletableFuture<>();
+
+        final AtomicReference<AsynchronousJobOperationKey> keyReference = new AtomicReference<>();
+        final TestingRestfulGateway testingRestfulGateway =
+                new TestingRestfulGateway.Builder()
+                        .setTriggerCheckpointFunction(
+                                (AsynchronousJobOperationKey key,
+                                        CheckpointType checkpointType) -> {
+                                    keyReference.set(key);
+                                    checkpointTypeFuture.complete(checkpointType);
+                                    return CompletableFuture.completedFuture(Acknowledge.get());
+                                })
+                        .setGetCheckpointStatusFunction(
+                                (AsynchronousJobOperationKey operationKey) -> {
+                                    if (operationKey.equals(keyReference.get())) {
+                                        return CompletableFuture.completedFuture(successfulResult);
+                                    }
+                                    throw new RuntimeException(
+                                            "Expected operation key "
+                                                    + keyReference.get()
+                                                    + ", but received "
+                                                    + operationKey);
+                                })
+                        .build();
+
+        final CheckpointType checkpointType = CheckpointType.INCREMENTAL;
+
+        assertThrows(
+                IllegalStateException.class,
+                () ->
+                        checkpointTriggerHandler
+                                .handleRequest(
+                                        triggerCheckpointRequest(checkpointType, null),
+                                        testingRestfulGateway)
+                                .get());
+        assertThat(checkpointTypeFuture.isDone()).isFalse();
+    }
+
     @Test
     void testCheckpointCompletedWithException() throws Exception {
         final OperationResult<Long> failedResult =