Github user EronWright commented on a diff in the pull request:
https://github.com/apache/flink/pull/3481#discussion_r105826378
--- Diff:
flink-mesos/src/main/java/org/apache/flink/mesos/runtime/clusterframework/MesosTaskManagerParameters.java
---
@@ -162,11 +182,65 @@ public static MesosTaskManagerParameters
create(Configuration flinkConfig) {
throw new
IllegalConfigurationException("invalid container type: " + containerTypeString);
}
+ Option<String> containerVolOpt =
Option.<String>apply(flinkConfig.getString(MESOS_RM_CONTAINER_VOLUMES));
+ List<Protos.Volume> containerVolumes =
buildVolumes(containerVolOpt);
+
return new MesosTaskManagerParameters(
cpus,
containerType,
Option.apply(imageName),
- containeredParameters);
+ containeredParameters,
+ containerVolumes);
+ }
+
+ /**
+ * Used to build volume specs for mesos. This allows for mounting
additional volumes into a container
+ *
+ * @param containerVolumes a comma delimited optional string of
[host_path:]container_path[:RO|RW] that
+ * defines mount points for a container volume.
If None or empty string, returns
+ * an empty iterator
+ */
+ public static List<Protos.Volume> buildVolumes(Option<String>
containerVolumes) {
+ if (containerVolumes.isEmpty()) {
+ return new ArrayList<Protos.Volume>();
+ }
+ String[] specs = containerVolumes.get().split(",");
+ List<Protos.Volume> vols = new ArrayList<Protos.Volume>();
+ for (String s : specs) {
+ if (s.trim().isEmpty()) {
+ continue;
+ }
+ Protos.Volume.Builder vol = Protos.Volume.newBuilder();
+ vol.setMode(Protos.Volume.Mode.RW);
+
+ String[] parts = s.split(":");
+ switch (parts.length) {
+ case 1:
+ vol.setContainerPath(parts[0]);
+ break;
+ case 2:
+ try {
+ Protos.Volume.Mode mode =
Protos.Volume.Mode.valueOf(parts[1].trim().toUpperCase());
+ vol.setMode(mode)
+
.setContainerPath(parts[0]);
+ } catch (IllegalArgumentException e) {
--- End diff --
I gather that this code treats a two-part spec as `container:mode` first,
then falls back to `host:container`. Just curious, is there some precedent
for that? I'm not sure it makes sense; for example, `/data:ro` would create
an empty read-only volume, but what good is that?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---