You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by tr...@apache.org on 2018/10/07 09:42:08 UTC
[flink] 12/12: [FLINK-10406] Add meaningful message if no savepoint
location for cancel with savepoint
This is an automated email from the ASF dual-hosted git repository.
trohrmann pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
commit 6e04ad0b5dbe37e319eb20e111d7176645ccb1ea
Author: Till Rohrmann <tr...@apache.org>
AuthorDate: Sun Oct 7 00:23:31 2018 +0200
[FLINK-10406] Add meaningful message if no savepoint location for cancel with savepoint
The JobMaster now returns a meaningful exception messages if a job is canceled with savepoint
and neither a savepoint directory has been given nor a default location has been configured.
This closes #6765.
---
.../org/apache/flink/runtime/jobmaster/JobMaster.java | 8 ++++++++
.../jobmaster/JobMasterTriggerSavepointIT.java | 19 ++++++++++++++++++-
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
index 21e06af..31c6a97 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
@@ -23,6 +23,7 @@ import org.apache.flink.api.common.JobID;
import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.time.Time;
import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.configuration.CheckpointingOptions;
import org.apache.flink.core.io.InputSplit;
import org.apache.flink.core.io.InputSplitAssigner;
import org.apache.flink.queryablestate.KvStateID;
@@ -946,6 +947,13 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
if (checkpointCoordinator == null) {
return FutureUtils.completedExceptionally(new IllegalStateException(
String.format("Job %s is not a streaming job.", jobGraph.getJobID())));
+ } else if (targetDirectory == null && !checkpointCoordinator.getCheckpointStorage().hasDefaultSavepointLocation()) {
+ log.info("Trying to cancel job {} with savepoint, but no savepoint directory configured.", jobGraph.getJobID());
+
+ return FutureUtils.completedExceptionally(new IllegalStateException(
+ "No savepoint directory configured. You can either specify a directory " +
+ "while cancelling via -s :targetDirectory or configure a cluster-wide " +
+ "default via key '" + CheckpointingOptions.SAVEPOINT_DIRECTORY.key() + "'."));
}
if (cancelJob) {
diff --git a/flink-tests/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTriggerSavepointIT.java b/flink-tests/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTriggerSavepointIT.java
index 45a767d..95c357d 100644
--- a/flink-tests/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTriggerSavepointIT.java
+++ b/flink-tests/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTriggerSavepointIT.java
@@ -161,7 +161,24 @@ public class JobMasterTriggerSavepointIT extends AbstractTestBase {
// assert that checkpoints are continued to be triggered
triggerCheckpointLatch = new CountDownLatch(1);
- assertThat(triggerCheckpointLatch.await(60, TimeUnit.SECONDS), equalTo(true));
+ assertThat(triggerCheckpointLatch.await(60L, TimeUnit.SECONDS), equalTo(true));
+ }
+
+ /**
+ * Tests that cancel with savepoint without a properly configured savepoint
+ * directory, will fail with a meaningful exception message.
+ */
+ @Test
+ public void testCancelWithSavepointWithoutConfiguredSavepointDirectory() throws Exception {
+ setUpWithCheckpointInterval(10L);
+
+ try {
+ clusterClient.cancelWithSavepoint(jobGraph.getJobID(), null);
+ } catch (Exception e) {
+ if (!ExceptionUtils.findThrowableWithMessage(e, "savepoint directory").isPresent()) {
+ throw e;
+ }
+ }
}
private void waitForJob() throws Exception {