Repository: mesos Updated Branches: refs/heads/master 039f84b5d -> d3eede1a1
Modified the default for ephemeral ports per container. Review: https://reviews.apache.org/r/24461 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d3eede1a Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d3eede1a Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d3eede1a Branch: refs/heads/master Commit: d3eede1a1808b51e0383e356fd96344abc97502f Parents: 039f84b Author: Jie Yu <[email protected]> Authored: Thu Aug 7 11:08:10 2014 -0700 Committer: Jie Yu <[email protected]> Committed: Thu Aug 7 17:12:50 2014 -0700 ---------------------------------------------------------------------- src/slave/constants.cpp | 3 +-- src/slave/constants.hpp | 3 --- .../containerizer/isolators/network/port_mapping.cpp | 3 +-- src/tests/mesos.cpp | 8 +++++++- src/tests/port_mapping_tests.cpp | 10 ++++++++-- 5 files changed, 17 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/d3eede1a/src/slave/constants.cpp ---------------------------------------------------------------------- diff --git a/src/slave/constants.cpp b/src/slave/constants.cpp index 4339c7c..e1da5c0 100644 --- a/src/slave/constants.cpp +++ b/src/slave/constants.cpp @@ -47,8 +47,7 @@ const Bytes DEFAULT_MEM = Gigabytes(1); const Bytes DEFAULT_DISK = Gigabytes(10); const std::string DEFAULT_PORTS = "[31000-32000]"; #ifdef WITH_NETWORK_ISOLATOR -const uint16_t DEFAULT_EPHEMERAL_PORTS_PER_CONTAINER = 16; -const std::string DEFAULT_EPHEMERAL_PORTS = "[30001-30999]"; +const uint16_t DEFAULT_EPHEMERAL_PORTS_PER_CONTAINER = 1024; #endif Duration MASTER_PING_TIMEOUT() http://git-wip-us.apache.org/repos/asf/mesos/blob/d3eede1a/src/slave/constants.hpp ---------------------------------------------------------------------- diff --git a/src/slave/constants.hpp b/src/slave/constants.hpp index a6bae1e..9030871 100644 --- a/src/slave/constants.hpp +++ b/src/slave/constants.hpp @@ -92,9 +92,6 @@ const Bytes DEFAULT_EXECUTOR_MEM = Megabytes(32); // Default number of ephemeral ports allocated to a container by the // network isolator. extern const uint16_t DEFAULT_EPHEMERAL_PORTS_PER_CONTAINER; - -// Default ephemeral port range reserved for the network isolator. -extern const std::string DEFAULT_EPHEMERAL_PORTS; #endif // If no pings received within this timeout, then the slave will http://git-wip-us.apache.org/repos/asf/mesos/blob/d3eede1a/src/slave/containerizer/isolators/network/port_mapping.cpp ---------------------------------------------------------------------- diff --git a/src/slave/containerizer/isolators/network/port_mapping.cpp b/src/slave/containerizer/isolators/network/port_mapping.cpp index daf89cc..938782a 100644 --- a/src/slave/containerizer/isolators/network/port_mapping.cpp +++ b/src/slave/containerizer/isolators/network/port_mapping.cpp @@ -100,8 +100,7 @@ const string BIND_MOUNT_ROOT = "/var/run/netns"; // The minimum number of ephemeral ports a container should have. -static const uint16_t MIN_EPHEMERAL_PORTS_SIZE = - DEFAULT_EPHEMERAL_PORTS_PER_CONTAINER; +static const uint16_t MIN_EPHEMERAL_PORTS_SIZE = 16; // The primary priority used by each type of filter. http://git-wip-us.apache.org/repos/asf/mesos/blob/d3eede1a/src/tests/mesos.cpp ---------------------------------------------------------------------- diff --git a/src/tests/mesos.cpp b/src/tests/mesos.cpp index b51954e..6b5c43f 100644 --- a/src/tests/mesos.cpp +++ b/src/tests/mesos.cpp @@ -350,10 +350,16 @@ slave::Flags ContainerizerTest<slave::MesosContainerizer>::CreateSlaveFlags() flags.isolation, "network/port_mapping"); + // NOTE: By default, Linux sets host ip local port range to + // [32768, 61000]. We set 'ephemeral_ports' resource so that it + // does not overlap with the host ip local port range. flags.resources = strings::join( ";", flags.resources.get(), - "ephemeral_ports:" + slave::DEFAULT_EPHEMERAL_PORTS); + "ephemeral_ports:[30001-30999]"); + + // NOTE: '16' should be enough for all our tests. + flags.ephemeral_ports_per_container = 16; } #endif http://git-wip-us.apache.org/repos/asf/mesos/blob/d3eede1a/src/tests/port_mapping_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/port_mapping_tests.cpp b/src/tests/port_mapping_tests.cpp index 682325a..a990da3 100644 --- a/src/tests/port_mapping_tests.cpp +++ b/src/tests/port_mapping_tests.cpp @@ -238,9 +238,15 @@ protected: flags.launcher_dir = path::join(tests::flags.build_dir, "src"); + // NOTE: By default, Linux sets host ip local port range to + // [32768, 61000]. We set 'ephemeral_ports' resource so that it + // does not overlap with the host ip local port range. flags.resources = - ("cpus:2;mem:1024;disk:1024;ports:[31000-32000];ephemeral_ports:" + - slave::DEFAULT_EPHEMERAL_PORTS); + "cpus:2;mem:1024;disk:1024;ports:[31000-32000];" + "ephemeral_ports:[30001-30999]"; + + // NOTE: '16' should be enough for all our tests. + flags.ephemeral_ports_per_container = 16; flags.isolation = "network/port_mapping";
