Search in sources :

Example 1 with ClusterDeploymentException

use of org.apache.flink.client.deployment.ClusterDeploymentException in project flink by apache.

the class KubernetesClusterDescriptor method deployApplicationCluster.

@Override
public ClusterClientProvider<String> deployApplicationCluster(final ClusterSpecification clusterSpecification, final ApplicationConfiguration applicationConfiguration) throws ClusterDeploymentException {
    if (client.getService(KubernetesService.ServiceType.REST_SERVICE, clusterId).isPresent()) {
        throw new ClusterDeploymentException("The Flink cluster " + clusterId + " already exists.");
    }
    checkNotNull(clusterSpecification);
    checkNotNull(applicationConfiguration);
    final KubernetesDeploymentTarget deploymentTarget = KubernetesDeploymentTarget.fromConfig(flinkConfig);
    if (KubernetesDeploymentTarget.APPLICATION != deploymentTarget) {
        throw new ClusterDeploymentException("Couldn't deploy Kubernetes Application Cluster." + " Expected deployment.target=" + KubernetesDeploymentTarget.APPLICATION.getName() + " but actual one was \"" + deploymentTarget + "\"");
    }
    applicationConfiguration.applyToConfiguration(flinkConfig);
    // No need to do pipelineJars validation if it is a PyFlink job.
    if (!(PackagedProgramUtils.isPython(applicationConfiguration.getApplicationClassName()) || PackagedProgramUtils.isPython(applicationConfiguration.getProgramArguments()))) {
        final List<File> pipelineJars = KubernetesUtils.checkJarFileForApplicationMode(flinkConfig);
        Preconditions.checkArgument(pipelineJars.size() == 1, "Should only have one jar");
    }
    final ClusterClientProvider<String> clusterClientProvider = deployClusterInternal(KubernetesApplicationClusterEntrypoint.class.getName(), clusterSpecification, false);
    try (ClusterClient<String> clusterClient = clusterClientProvider.getClusterClient()) {
        LOG.info("Create flink application cluster {} successfully, JobManager Web Interface: {}", clusterId, clusterClient.getWebInterfaceURL());
    }
    return clusterClientProvider;
}
Also used : ClusterDeploymentException(org.apache.flink.client.deployment.ClusterDeploymentException) KubernetesApplicationClusterEntrypoint(org.apache.flink.kubernetes.entrypoint.KubernetesApplicationClusterEntrypoint) KubernetesDeploymentTarget(org.apache.flink.kubernetes.configuration.KubernetesDeploymentTarget) File(java.io.File)

Example 2 with ClusterDeploymentException

use of org.apache.flink.client.deployment.ClusterDeploymentException in project flink by apache.

the class YarnClusterDescriptor method deployApplicationCluster.

@Override
public ClusterClientProvider<ApplicationId> deployApplicationCluster(final ClusterSpecification clusterSpecification, final ApplicationConfiguration applicationConfiguration) throws ClusterDeploymentException {
    checkNotNull(clusterSpecification);
    checkNotNull(applicationConfiguration);
    final YarnDeploymentTarget deploymentTarget = YarnDeploymentTarget.fromConfig(flinkConfiguration);
    if (YarnDeploymentTarget.APPLICATION != deploymentTarget) {
        throw new ClusterDeploymentException("Couldn't deploy Yarn Application Cluster." + " Expected deployment.target=" + YarnDeploymentTarget.APPLICATION.getName() + " but actual one was \"" + deploymentTarget.getName() + "\"");
    }
    applicationConfiguration.applyToConfiguration(flinkConfiguration);
    final List<String> pipelineJars = flinkConfiguration.getOptional(PipelineOptions.JARS).orElse(Collections.emptyList());
    Preconditions.checkArgument(pipelineJars.size() == 1, "Should only have one jar");
    try {
        return deployInternal(clusterSpecification, "Flink Application Cluster", YarnApplicationClusterEntryPoint.class.getName(), null, false);
    } catch (Exception e) {
        throw new ClusterDeploymentException("Couldn't deploy Yarn Application Cluster", e);
    }
}
Also used : ClusterDeploymentException(org.apache.flink.client.deployment.ClusterDeploymentException) YarnApplicationClusterEntryPoint(org.apache.flink.yarn.entrypoint.YarnApplicationClusterEntryPoint) YarnDeploymentTarget(org.apache.flink.yarn.configuration.YarnDeploymentTarget) InvocationTargetException(java.lang.reflect.InvocationTargetException) FlinkException(org.apache.flink.util.FlinkException) IOException(java.io.IOException) ClusterDeploymentException(org.apache.flink.client.deployment.ClusterDeploymentException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) ClusterRetrieveException(org.apache.flink.client.deployment.ClusterRetrieveException)

Example 3 with ClusterDeploymentException

use of org.apache.flink.client.deployment.ClusterDeploymentException in project flink by apache.

the class KubernetesClusterDescriptor method deployClusterInternal.

private ClusterClientProvider<String> deployClusterInternal(String entryPoint, ClusterSpecification clusterSpecification, boolean detached) throws ClusterDeploymentException {
    final ClusterEntrypoint.ExecutionMode executionMode = detached ? ClusterEntrypoint.ExecutionMode.DETACHED : ClusterEntrypoint.ExecutionMode.NORMAL;
    flinkConfig.setString(ClusterEntrypoint.INTERNAL_CLUSTER_EXECUTION_MODE, executionMode.toString());
    flinkConfig.setString(KubernetesConfigOptionsInternal.ENTRY_POINT_CLASS, entryPoint);
    // Rpc, blob, rest, taskManagerRpc ports need to be exposed, so update them to fixed values.
    KubernetesUtils.checkAndUpdatePortConfigOption(flinkConfig, BlobServerOptions.PORT, Constants.BLOB_SERVER_PORT);
    KubernetesUtils.checkAndUpdatePortConfigOption(flinkConfig, TaskManagerOptions.RPC_PORT, Constants.TASK_MANAGER_RPC_PORT);
    KubernetesUtils.checkAndUpdatePortConfigOption(flinkConfig, RestOptions.BIND_PORT, Constants.REST_PORT);
    if (HighAvailabilityMode.isHighAvailabilityModeActivated(flinkConfig)) {
        flinkConfig.setString(HighAvailabilityOptions.HA_CLUSTER_ID, clusterId);
        KubernetesUtils.checkAndUpdatePortConfigOption(flinkConfig, HighAvailabilityOptions.HA_JOB_MANAGER_PORT_RANGE, flinkConfig.get(JobManagerOptions.PORT));
    }
    try {
        final KubernetesJobManagerParameters kubernetesJobManagerParameters = new KubernetesJobManagerParameters(flinkConfig, clusterSpecification);
        final FlinkPod podTemplate = kubernetesJobManagerParameters.getPodTemplateFilePath().map(file -> KubernetesUtils.loadPodFromTemplateFile(client, file, Constants.MAIN_CONTAINER_NAME)).orElse(new FlinkPod.Builder().build());
        final KubernetesJobManagerSpecification kubernetesJobManagerSpec = KubernetesJobManagerFactory.buildKubernetesJobManagerSpecification(podTemplate, kubernetesJobManagerParameters);
        client.createJobManagerComponent(kubernetesJobManagerSpec);
        return createClusterClientProvider(clusterId);
    } catch (Exception e) {
        try {
            LOG.warn("Failed to create the Kubernetes cluster \"{}\", try to clean up the residual resources.", clusterId);
            client.stopAndCleanupCluster(clusterId);
        } catch (Exception e1) {
            LOG.info("Failed to stop and clean up the Kubernetes cluster \"{}\".", clusterId, e1);
        }
        throw new ClusterDeploymentException("Could not create Kubernetes cluster \"" + clusterId + "\".", e);
    }
}
Also used : FlinkException(org.apache.flink.util.FlinkException) ClusterSpecification(org.apache.flink.client.deployment.ClusterSpecification) JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) LoggerFactory(org.slf4j.LoggerFactory) KubernetesConfigOptionsInternal(org.apache.flink.kubernetes.configuration.KubernetesConfigOptionsInternal) KubernetesService(org.apache.flink.kubernetes.kubeclient.resources.KubernetesService) RestClusterClient(org.apache.flink.client.program.rest.RestClusterClient) ApplicationConfiguration(org.apache.flink.client.deployment.application.ApplicationConfiguration) TaskManagerOptions(org.apache.flink.configuration.TaskManagerOptions) RestOptions(org.apache.flink.configuration.RestOptions) Endpoint(org.apache.flink.kubernetes.kubeclient.Endpoint) StandaloneClientHAServices(org.apache.flink.runtime.highavailability.nonha.standalone.StandaloneClientHAServices) Preconditions.checkNotNull(org.apache.flink.util.Preconditions.checkNotNull) ClusterRetrieveException(org.apache.flink.client.deployment.ClusterRetrieveException) KubernetesJobManagerParameters(org.apache.flink.kubernetes.kubeclient.parameters.KubernetesJobManagerParameters) HighAvailabilityMode(org.apache.flink.runtime.jobmanager.HighAvailabilityMode) KubernetesDeploymentTarget(org.apache.flink.kubernetes.configuration.KubernetesDeploymentTarget) PackagedProgramUtils(org.apache.flink.client.program.PackagedProgramUtils) BlobServerOptions(org.apache.flink.configuration.BlobServerOptions) KubernetesUtils(org.apache.flink.kubernetes.utils.KubernetesUtils) KubernetesConfigOptions(org.apache.flink.kubernetes.configuration.KubernetesConfigOptions) Logger(org.slf4j.Logger) Configuration(org.apache.flink.configuration.Configuration) KubernetesJobManagerSpecification(org.apache.flink.kubernetes.kubeclient.KubernetesJobManagerSpecification) KubernetesApplicationClusterEntrypoint(org.apache.flink.kubernetes.entrypoint.KubernetesApplicationClusterEntrypoint) HighAvailabilityServicesUtils(org.apache.flink.runtime.highavailability.HighAvailabilityServicesUtils) JobManagerOptions(org.apache.flink.configuration.JobManagerOptions) FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) Preconditions(org.apache.flink.util.Preconditions) KubernetesSessionClusterEntrypoint(org.apache.flink.kubernetes.entrypoint.KubernetesSessionClusterEntrypoint) File(java.io.File) ClusterDeploymentException(org.apache.flink.client.deployment.ClusterDeploymentException) List(java.util.List) ClusterDescriptor(org.apache.flink.client.deployment.ClusterDescriptor) ClusterClient(org.apache.flink.client.program.ClusterClient) KubernetesJobManagerFactory(org.apache.flink.kubernetes.kubeclient.factory.KubernetesJobManagerFactory) Optional(java.util.Optional) AddressResolution(org.apache.flink.runtime.rpc.AddressResolution) ClusterClientProvider(org.apache.flink.client.program.ClusterClientProvider) ClusterEntrypoint(org.apache.flink.runtime.entrypoint.ClusterEntrypoint) Constants(org.apache.flink.kubernetes.utils.Constants) HighAvailabilityOptions(org.apache.flink.configuration.HighAvailabilityOptions) FlinkKubeClient(org.apache.flink.kubernetes.kubeclient.FlinkKubeClient) ClusterDeploymentException(org.apache.flink.client.deployment.ClusterDeploymentException) FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) KubernetesApplicationClusterEntrypoint(org.apache.flink.kubernetes.entrypoint.KubernetesApplicationClusterEntrypoint) KubernetesSessionClusterEntrypoint(org.apache.flink.kubernetes.entrypoint.KubernetesSessionClusterEntrypoint) ClusterEntrypoint(org.apache.flink.runtime.entrypoint.ClusterEntrypoint) KubernetesJobManagerSpecification(org.apache.flink.kubernetes.kubeclient.KubernetesJobManagerSpecification) FlinkException(org.apache.flink.util.FlinkException) ClusterRetrieveException(org.apache.flink.client.deployment.ClusterRetrieveException) ClusterDeploymentException(org.apache.flink.client.deployment.ClusterDeploymentException) KubernetesJobManagerParameters(org.apache.flink.kubernetes.kubeclient.parameters.KubernetesJobManagerParameters)

Example 4 with ClusterDeploymentException

use of org.apache.flink.client.deployment.ClusterDeploymentException in project flink by apache.

the class YarnClusterDescriptorTest method testFailIfTaskSlotsHigherThanMaxVcores.

@Test
public void testFailIfTaskSlotsHigherThanMaxVcores() throws ClusterDeploymentException {
    final Configuration flinkConfiguration = new Configuration();
    YarnClusterDescriptor clusterDescriptor = createYarnClusterDescriptor(flinkConfiguration);
    clusterDescriptor.setLocalJarPath(new Path(flinkJar.getPath()));
    try {
        clusterDescriptor.deploySessionCluster(clusterSpecification);
        fail("The deploy call should have failed.");
    } catch (ClusterDeploymentException e) {
        // we expect the cause to be an IllegalConfigurationException
        if (!(e.getCause() instanceof IllegalConfigurationException)) {
            throw e;
        }
    } finally {
        clusterDescriptor.close();
    }
}
Also used : Path(org.apache.hadoop.fs.Path) ClusterDeploymentException(org.apache.flink.client.deployment.ClusterDeploymentException) ApplicationConfiguration(org.apache.flink.client.deployment.application.ApplicationConfiguration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.flink.configuration.Configuration) IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException) Test(org.junit.Test)

Example 5 with ClusterDeploymentException

use of org.apache.flink.client.deployment.ClusterDeploymentException in project flink by apache.

the class YarnClusterDescriptorTest method testConfigOverwrite.

@Test
public void testConfigOverwrite() throws ClusterDeploymentException {
    Configuration configuration = new Configuration();
    // overwrite vcores in config
    configuration.setInteger(YarnConfigOptions.VCORES, Integer.MAX_VALUE);
    YarnClusterDescriptor clusterDescriptor = createYarnClusterDescriptor(configuration);
    clusterDescriptor.setLocalJarPath(new Path(flinkJar.getPath()));
    // configure slots
    ClusterSpecification clusterSpecification = new ClusterSpecification.ClusterSpecificationBuilder().createClusterSpecification();
    try {
        clusterDescriptor.deploySessionCluster(clusterSpecification);
        fail("The deploy call should have failed.");
    } catch (ClusterDeploymentException e) {
        // we expect the cause to be an IllegalConfigurationException
        if (!(e.getCause() instanceof IllegalConfigurationException)) {
            throw e;
        }
    } finally {
        clusterDescriptor.close();
    }
}
Also used : Path(org.apache.hadoop.fs.Path) ClusterDeploymentException(org.apache.flink.client.deployment.ClusterDeploymentException) ApplicationConfiguration(org.apache.flink.client.deployment.application.ApplicationConfiguration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.flink.configuration.Configuration) ClusterSpecification(org.apache.flink.client.deployment.ClusterSpecification) IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException) Test(org.junit.Test)

Aggregations

ClusterDeploymentException (org.apache.flink.client.deployment.ClusterDeploymentException)5 ApplicationConfiguration (org.apache.flink.client.deployment.application.ApplicationConfiguration)3 Configuration (org.apache.flink.configuration.Configuration)3 IllegalConfigurationException (org.apache.flink.configuration.IllegalConfigurationException)3 File (java.io.File)2 ClusterRetrieveException (org.apache.flink.client.deployment.ClusterRetrieveException)2 ClusterSpecification (org.apache.flink.client.deployment.ClusterSpecification)2 KubernetesDeploymentTarget (org.apache.flink.kubernetes.configuration.KubernetesDeploymentTarget)2 KubernetesApplicationClusterEntrypoint (org.apache.flink.kubernetes.entrypoint.KubernetesApplicationClusterEntrypoint)2 Path (org.apache.hadoop.fs.Path)2 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 List (java.util.List)1 Optional (java.util.Optional)1 ClusterDescriptor (org.apache.flink.client.deployment.ClusterDescriptor)1 ClusterClient (org.apache.flink.client.program.ClusterClient)1 ClusterClientProvider (org.apache.flink.client.program.ClusterClientProvider)1