Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FLINK-4900] flink-master: Allow to deploy TM with container #2703

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,29 @@ public final class ConfigConstants {
*/
public static final String MESOS_RESOURCEMANAGER_TASKS_CPUS = "mesos.resourcemanager.tasks.cpus";

/**
* The container image to use for task managers.
*/
public static final String MESOS_RESOURCEMANAGER_TASKS_CONTAINER_IMAGE_NAME =
"mesos.resourcemanager.tasks.container.image.name";

/**
* The type of container to use for task managers. Valid values are
* {@code MESOS_RESOURCEMANAGER_TASKS_CONTAINER_TYPE_MESOS} or
* {@code MESOS_RESOURCEMANAGER_TASKS_CONTAINER_TYPE_DOCKER}.
*/
public static final String MESOS_RESOURCEMANAGER_TASKS_CONTAINER_TYPE =
"mesos.resourcemanager.tasks.container.type";

/**
* Value for {@code MESOS_RESOURCEMANAGER_TASKS_CONTAINER_TYPE} setting. Tells to use the Mesos containerizer.
*/
public static final String MESOS_RESOURCEMANAGER_TASKS_CONTAINER_TYPE_MESOS = "mesos";
/**
* Value for {@code MESOS_RESOURCEMANAGER_TASKS_CONTAINER_TYPE} setting. Tells to use the Docker containerizer.
*/
public static final String MESOS_RESOURCEMANAGER_TASKS_CONTAINER_TYPE_DOCKER = "docker";

// ------------------------ Hadoop Configuration ------------------------

/**
Expand Down Expand Up @@ -1156,6 +1179,8 @@ public final class ConfigConstants {

public static final String DEFAULT_MESOS_RESOURCEMANAGER_FRAMEWORK_ROLE = "*";

public static final String DEFAULT_MESOS_RESOURCEMANAGER_TASKS_CONTAINER_IMAGE_TYPE = "mesos";

// ------------------------ File System Behavior ------------------------

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,53 @@ public static Protos.TaskInfo.Builder createTaskManagerContext(

info.setCommand(cmd);

// Set container for task manager if specified in configs.
String tmImageName = flinkConfig.getString(
ConfigConstants.MESOS_RESOURCEMANAGER_TASKS_CONTAINER_IMAGE_NAME, "");

if (tmImageName.length() > 0) {
String taskManagerContainerType = flinkConfig.getString(
ConfigConstants.MESOS_RESOURCEMANAGER_TASKS_CONTAINER_TYPE,
ConfigConstants.DEFAULT_MESOS_RESOURCEMANAGER_TASKS_CONTAINER_IMAGE_TYPE);

Protos.ContainerInfo.Builder containerInfo;

switch (taskManagerContainerType) {
case ConfigConstants.MESOS_RESOURCEMANAGER_TASKS_CONTAINER_TYPE_MESOS:
containerInfo = Protos.ContainerInfo.newBuilder()
.setType(Protos.ContainerInfo.Type.MESOS)
.setMesos(Protos.ContainerInfo.MesosInfo.newBuilder()
.setImage(Protos.Image.newBuilder()
.setType(Protos.Image.Type.DOCKER)
.setDocker(Protos.Image.Docker.newBuilder()
.setName(tmImageName))));
break;
case ConfigConstants.MESOS_RESOURCEMANAGER_TASKS_CONTAINER_TYPE_DOCKER:
containerInfo = Protos.ContainerInfo.newBuilder()
.setType(Protos.ContainerInfo.Type.DOCKER)
.setDocker(Protos.ContainerInfo.DockerInfo.newBuilder()
.setNetwork(Protos.ContainerInfo.DockerInfo.Network.HOST)
.setImage(tmImageName));
break;
default:
LOG.warn(
"Invalid container type '{}' provided for setting {}. Valid values are '{}' or '{}'. " +
"Starting task managers now without container.",
taskManagerContainerType,
ConfigConstants.MESOS_RESOURCEMANAGER_TASKS_CONTAINER_TYPE,
ConfigConstants.MESOS_RESOURCEMANAGER_TASKS_CONTAINER_TYPE_MESOS,
ConfigConstants.MESOS_RESOURCEMANAGER_TASKS_CONTAINER_TYPE_DOCKER);

containerInfo = null;

break;
}

if (containerInfo != null) {
info.setContainer(containerInfo);
}
}

return info;
}
}