Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 4865E200BB6 for ; Fri, 4 Nov 2016 20:15:39 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 46DF5160AFE; Fri, 4 Nov 2016 19:15:39 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 8D87C160AEA for ; Fri, 4 Nov 2016 20:15:38 +0100 (CET) Received: (qmail 91198 invoked by uid 500); 4 Nov 2016 19:15:37 -0000 Mailing-List: contact commits-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flink.apache.org Delivered-To: mailing list commits@flink.apache.org Received: (qmail 91189 invoked by uid 99); 4 Nov 2016 19:15:37 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Nov 2016 19:15:37 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A79F3E04EE; Fri, 4 Nov 2016 19:15:37 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mxm@apache.org To: commits@flink.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: flink git commit: [FLINK-4998][yarn] fail if too many task slots are configured Date: Fri, 4 Nov 2016 19:15:37 +0000 (UTC) archived-at: Fri, 04 Nov 2016 19:15:39 -0000 Repository: flink Updated Branches: refs/heads/release-1.1 42334de84 -> fe2c4ba6a [FLINK-4998][yarn] fail if too many task slots are configured This fails the deployment of the Yarn application if the number of task slots are configured to be larger than the maximum virtual cores of the Yarn cluster. This closes #2741. Project: http://git-wip-us.apache.org/repos/asf/flink/repo Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/fe2c4ba6 Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/fe2c4ba6 Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/fe2c4ba6 Branch: refs/heads/release-1.1 Commit: fe2c4ba6a8dbbe5bde75c1dd816ae5d2004910e0 Parents: 42334de Author: Maximilian Michels Authored: Thu Oct 27 16:37:56 2016 +0100 Committer: Maximilian Michels Committed: Fri Nov 4 20:14:22 2016 +0100 ---------------------------------------------------------------------- .../yarn/AbstractYarnClusterDescriptor.java | 9 +++ .../flink/yarn/YarnClusterDescriptorTest.java | 69 ++++++++++++++++++++ 2 files changed, 78 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flink/blob/fe2c4ba6/flink-yarn/src/main/java/org/apache/flink/yarn/AbstractYarnClusterDescriptor.java ---------------------------------------------------------------------- diff --git a/flink-yarn/src/main/java/org/apache/flink/yarn/AbstractYarnClusterDescriptor.java b/flink-yarn/src/main/java/org/apache/flink/yarn/AbstractYarnClusterDescriptor.java index 728eae3..000b2c1 100644 --- a/flink-yarn/src/main/java/org/apache/flink/yarn/AbstractYarnClusterDescriptor.java +++ b/flink-yarn/src/main/java/org/apache/flink/yarn/AbstractYarnClusterDescriptor.java @@ -22,6 +22,7 @@ import org.apache.flink.client.CliFrontend; import org.apache.flink.client.deployment.ClusterDescriptor; import org.apache.flink.configuration.ConfigConstants; import org.apache.flink.configuration.GlobalConfiguration; +import org.apache.flink.configuration.IllegalConfigurationException; import org.apache.flink.runtime.akka.AkkaUtils; import org.apache.flink.runtime.jobmanager.RecoveryMode; import org.apache.hadoop.conf.Configuration; @@ -302,6 +303,14 @@ public abstract class AbstractYarnClusterDescriptor implements ClusterDescriptor throw new YarnDeploymentException("Flink configuration object has not been set"); } + int numYarnVcores = conf.getInt(YarnConfiguration.NM_VCORES, YarnConfiguration.DEFAULT_NM_VCORES); + // don't configure more than the maximum configured number of vcores + if (slots > numYarnVcores) { + throw new IllegalConfigurationException( + String.format("The number of task slots per node was configured with %d" + + " but Yarn only has %d virtual cores available.", slots, numYarnVcores)); + } + // check if required Hadoop environment variables are set. If not, warn user if(System.getenv("HADOOP_CONF_DIR") == null && System.getenv("YARN_CONF_DIR") == null) { http://git-wip-us.apache.org/repos/asf/flink/blob/fe2c4ba6/flink-yarn/src/test/java/org/apache/flink/yarn/YarnClusterDescriptorTest.java ---------------------------------------------------------------------- diff --git a/flink-yarn/src/test/java/org/apache/flink/yarn/YarnClusterDescriptorTest.java b/flink-yarn/src/test/java/org/apache/flink/yarn/YarnClusterDescriptorTest.java new file mode 100644 index 0000000..17ce7be --- /dev/null +++ b/flink-yarn/src/test/java/org/apache/flink/yarn/YarnClusterDescriptorTest.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.flink.yarn; + +import org.apache.flink.configuration.Configuration; +import org.apache.flink.configuration.IllegalConfigurationException; +import org.apache.hadoop.fs.Path; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import java.io.File; +import java.io.IOException; + +public class YarnClusterDescriptorTest { + + @Rule + public TemporaryFolder temporaryFolder = new TemporaryFolder(); + + private File flinkJar; + private File flinkConf; + + @Before + public void beforeTest() throws IOException { + temporaryFolder.create(); + flinkJar = temporaryFolder.newFile("flink.jar"); + flinkConf = temporaryFolder.newFile("flink-conf.yaml"); + } + + @Test + public void testFailIfTaskSlotsHigherThanMaxVcores() { + + + YarnClusterDescriptor clusterDescriptor = new YarnClusterDescriptor(); + + clusterDescriptor.setLocalJarPath(new Path(flinkJar.getPath())); + clusterDescriptor.setFlinkConfiguration(new Configuration()); + clusterDescriptor.setConfigurationDirectory(temporaryFolder.getRoot().getAbsolutePath()); + clusterDescriptor.setConfigurationFilePath(new Path(flinkConf.getPath())); + + // configure slots too high + clusterDescriptor.setTaskManagerSlots(Integer.MAX_VALUE); + + try { + clusterDescriptor.deploy(); + } catch (Exception e) { + Assert.assertTrue(e.getCause() instanceof IllegalConfigurationException); + } + } + + +}