You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2015/12/01 20:14:13 UTC
[3/3] mesos git commit: Added --egress_flow_classifier_parent flag.
Added --egress_flow_classifier_parent flag.
When --egress_unique_flow_per_container is enabled, we need to install a
flow classifier (fq_codel) qdisc on egress side. This flag specifies
where to install it in the hierarchy. By default, we install it at root.
But, for example, if you have already installed HTB qdisc at root, you
may want this to be installed in other place than root, specify an HTB
class ID as its parent here.
Review: https://reviews.apache.org/r/39417
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/5e1bf473
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/5e1bf473
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/5e1bf473
Branch: refs/heads/master
Commit: 5e1bf473c822861daf6a895b88e2482791bb09e5
Parents: efc0025
Author: Cong Wang <cw...@twopensource.com>
Authored: Tue Dec 1 10:06:01 2015 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Tue Dec 1 11:13:56 2015 -0800
----------------------------------------------------------------------
docs/configuration.md | 15 +++++
src/Makefile.am | 1 +
src/linux/routing/handle.cpp | 58 ++++++++++++++++++++
src/linux/routing/handle.hpp | 4 ++
.../mesos/isolators/network/port_mapping.cpp | 48 +++++++++++-----
.../mesos/isolators/network/port_mapping.hpp | 3 +
src/slave/flags.cpp | 8 +++
src/slave/flags.hpp | 1 +
8 files changed, 123 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/5e1bf473/docs/configuration.md
----------------------------------------------------------------------
diff --git a/docs/configuration.md b/docs/configuration.md
index addcc72..3498368 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -1673,6 +1673,21 @@ file:///path/to/file (where file contains one of the above)</code></pre>
</tr>
<tr>
<td>
+ --egress_flow_classifier_parent=root/X:Y
+ </td>
+ <td>
+ When --egress_unique_flow_per_container is enabled, we need to install
+ a flow classifier (fq_codel qdisc) on egress side. This flag specifies
+ where to install it in the whole qdisc hierarchy. By default, we install
+ it at root. But, for example, if you have already installed an HTB qdisc
+ at root, you may want this to be installed in other place than root,
+ specify an HTB class ID (X:Y) as its parent. X:Y must be hexadecimal
+ numbers without "0x" prefix. Note, it is always your responsibility to
+ ensure the whole qdisc hierarchy is meaningful and correct.
+ </td>
+ </tr>
+ <tr>
+ <td>
--[no-]network_enable_socket_statistics_summary
</td>
<td>
http://git-wip-us.apache.org/repos/asf/mesos/blob/5e1bf473/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index fd38cfa..0409491 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -793,6 +793,7 @@ MESOS_LINUX_FILES += \
slave/containerizer/mesos/provisioner/backends/bind.hpp
MESOS_NETWORK_ISOLATOR_FILES = \
+ linux/routing/handle.cpp \
linux/routing/route.cpp \
linux/routing/utils.cpp \
linux/routing/diagnosis/diagnosis.cpp \
http://git-wip-us.apache.org/repos/asf/mesos/blob/5e1bf473/src/linux/routing/handle.cpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/handle.cpp b/src/linux/routing/handle.cpp
new file mode 100644
index 0000000..09589e9
--- /dev/null
+++ b/src/linux/routing/handle.cpp
@@ -0,0 +1,58 @@
+/**
+ * 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.
+ */
+
+#include <string>
+#include <vector>
+
+#include <stout/numify.hpp>
+#include <stout/strings.hpp>
+
+#include "handle.hpp"
+
+using std::string;
+using std::vector;
+
+namespace routing {
+
+Try<Handle> Handle::parse(const std::string& str)
+{
+ if (str == "root") {
+ return EGRESS_ROOT;
+ }
+
+ vector<string> tokens = strings::tokenize(str, ":");
+ if (tokens.size() != 2) {
+ return Error("Failed to tokenize string: " + str);
+ }
+
+ // Handles should not have '0x' prefix, so we add '0x' to satisfy
+ // numify() here. If they do have a '0x' prefix, we expect an error.
+ Try<uint16_t> primary = numify<uint16_t>("0x" + tokens[0]);
+ if (primary.isError()) {
+ return Error("Failed to convert " + tokens[0] + " to a hex integer");
+ }
+
+ Try<uint16_t> secondary = numify<uint16_t>("0x" + tokens[1]);
+ if (secondary.isError()) {
+ return Error("Failed to convert " + tokens[1] + " to a hex integer");
+ }
+
+ return Handle(primary.get(), secondary.get());
+}
+
+} // namespace routing {
http://git-wip-us.apache.org/repos/asf/mesos/blob/5e1bf473/src/linux/routing/handle.hpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/handle.hpp b/src/linux/routing/handle.hpp
index 6deff85..5b03be5 100644
--- a/src/linux/routing/handle.hpp
+++ b/src/linux/routing/handle.hpp
@@ -23,6 +23,8 @@
#include <netlink/route/tc.h>
+#include <stout/try.hpp>
+
namespace routing {
// The Linux kernel Traffic Control (TC) uses handles to uniqely
@@ -57,6 +59,8 @@ public:
return handle != that.handle;
}
+ static Try<Handle> parse(const std::string& str);
+
constexpr uint16_t primary() const { return handle >> 16; }
constexpr uint16_t secondary() const { return handle & 0x0000ffff; }
constexpr uint32_t get() const { return handle; }
http://git-wip-us.apache.org/repos/asf/mesos/blob/5e1bf473/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp b/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp
index 09f8196..89bb36f 100644
--- a/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp
+++ b/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp
@@ -1382,11 +1382,28 @@ Try<Isolator*> PortMappingIsolatorProcess::create(const Flags& flags)
}
set<uint16_t> freeFlowIds;
+ Handle hostTxFqCodelHandle = HOST_TX_FQ_CODEL_HANDLE;
+
if (flags.egress_unique_flow_per_container) {
+ Try<Handle> egressParentHandle = Handle::parse(
+ flags.egress_flow_classifier_parent);
+
+ if (egressParentHandle.isError()) {
+ return Error(
+ "Failed to parse egress_flow_classifier_parent: " +
+ egressParentHandle.error());
+ }
+
+ if (egressParentHandle.get() != EGRESS_ROOT) {
+ // TODO(cwang): This is just a guess, we do not know if this
+ // handle is available or not.
+ hostTxFqCodelHandle = Handle(egressParentHandle.get().primary() + 1, 0);
+ }
+
// Prepare a fq_codel queueing discipline on host public interface
// (eth0) for egress flow classification.
Try<bool> existHostEth0EgressFqCodel =
- fq_codel::exists(eth0.get(), EGRESS_ROOT);
+ fq_codel::exists(eth0.get(), egressParentHandle.get());
if (existHostEth0EgressFqCodel.isError()) {
return Error(
@@ -1403,8 +1420,8 @@ Try<Isolator*> PortMappingIsolatorProcess::create(const Flags& flags)
// qdisc at root. We try to create one to check which is true.
Try<bool> createHostEth0EgressQdisc = fq_codel::create(
eth0.get(),
- EGRESS_ROOT,
- HOST_TX_FQ_CODEL_HANDLE);
+ egressParentHandle.get(),
+ hostTxFqCodelHandle);
if (createHostEth0EgressQdisc.isError()) {
return Error(
@@ -1628,6 +1645,7 @@ Try<Isolator*> PortMappingIsolatorProcess::create(const Flags& flags)
hostIPNetwork.get(),
hostEth0MTU.get(),
hostDefaultGateway.get(),
+ hostTxFqCodelHandle,
hostNetworkConfigurations,
egressRateLimitPerContainer,
nonEphemeralPorts,
@@ -1956,7 +1974,7 @@ PortMappingIsolatorProcess::_recover(pid_t pid)
if (flags.egress_unique_flow_per_container) {
// Get all egress IP flow classifiers on eth0.
Result<vector<filter::Filter<ip::Classifier>>> eth0EgressFilters =
- ip::filters(eth0, HOST_TX_FQ_CODEL_HANDLE);
+ ip::filters(eth0, hostTxFqCodelHandle);
if (eth0EgressFilters.isError()) {
return Error(
@@ -2430,10 +2448,10 @@ Future<Nothing> PortMappingIsolatorProcess::isolate(
// packets into a reserved flow.
Try<bool> icmpEth0Egress = filter::icmp::create(
eth0,
- HOST_TX_FQ_CODEL_HANDLE,
+ hostTxFqCodelHandle,
icmp::Classifier(None()),
Priority(ICMP_FILTER_PRIORITY, NORMAL),
- Handle(HOST_TX_FQ_CODEL_HANDLE, ICMP_FLOWID));
+ Handle(hostTxFqCodelHandle, ICMP_FLOWID));
if (icmpEth0Egress.isError()) {
++metrics.adding_eth0_egress_filters_errors;
@@ -2450,10 +2468,10 @@ Future<Nothing> PortMappingIsolatorProcess::isolate(
// packets into a reserved flow.
Try<bool> arpEth0Egress = filter::basic::create(
eth0,
- HOST_TX_FQ_CODEL_HANDLE,
+ hostTxFqCodelHandle,
ETH_P_ARP,
Priority(ARP_FILTER_PRIORITY, NORMAL),
- Handle(HOST_TX_FQ_CODEL_HANDLE, ARP_FLOWID));
+ Handle(hostTxFqCodelHandle, ARP_FLOWID));
if (arpEth0Egress.isError()) {
++metrics.adding_eth0_egress_filters_errors;
@@ -2469,10 +2487,10 @@ Future<Nothing> PortMappingIsolatorProcess::isolate(
// Rest of the host packets go to a reserved flow.
Try<bool> defaultEth0Egress = filter::basic::create(
eth0,
- HOST_TX_FQ_CODEL_HANDLE,
+ hostTxFqCodelHandle,
ETH_P_ALL,
Priority(DEFAULT_FILTER_PRIORITY, NORMAL),
- Handle(HOST_TX_FQ_CODEL_HANDLE, HOST_FLOWID));
+ Handle(hostTxFqCodelHandle, HOST_FLOWID));
if (defaultEth0Egress.isError()) {
++metrics.adding_eth0_egress_filters_errors;
@@ -3048,7 +3066,7 @@ Try<Nothing> PortMappingIsolatorProcess::_cleanup(
// Remove the ICMP flow classifier on host eth0.
Try<bool> icmpEth0Egress = filter::icmp::remove(
eth0,
- HOST_TX_FQ_CODEL_HANDLE,
+ hostTxFqCodelHandle,
icmp::Classifier(None()));
if (icmpEth0Egress.isError()) {
@@ -3067,7 +3085,7 @@ Try<Nothing> PortMappingIsolatorProcess::_cleanup(
// Remove the ARP flow classifier on host eth0.
Try<bool> arpEth0Egress = filter::basic::remove(
eth0,
- HOST_TX_FQ_CODEL_HANDLE,
+ hostTxFqCodelHandle,
ETH_P_ARP);
if (arpEth0Egress.isError()) {
@@ -3352,10 +3370,10 @@ Try<Nothing> PortMappingIsolatorProcess::addHostIPFilters(
// classified to different flows defined by fq_codel.
Try<bool> hostEth0Egress = filter::ip::create(
eth0,
- HOST_TX_FQ_CODEL_HANDLE,
+ hostTxFqCodelHandle,
ip::Classifier(None(), None(), range, None()),
Priority(IP_FILTER_PRIORITY, LOW),
- Handle(HOST_TX_FQ_CODEL_HANDLE, flowId.get()));
+ Handle(hostTxFqCodelHandle, flowId.get()));
if (hostEth0Egress.isError()) {
++metrics.adding_eth0_egress_filters_errors;
@@ -3430,7 +3448,7 @@ Try<Nothing> PortMappingIsolatorProcess::removeHostIPFilters(
// Remove the egress flow classifier on host eth0.
Try<bool> hostEth0Egress = filter::ip::remove(
eth0,
- HOST_TX_FQ_CODEL_HANDLE,
+ hostTxFqCodelHandle,
ip::Classifier(None(), None(), range, None()));
if (hostEth0Egress.isError()) {
http://git-wip-us.apache.org/repos/asf/mesos/blob/5e1bf473/src/slave/containerizer/mesos/isolators/network/port_mapping.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/network/port_mapping.hpp b/src/slave/containerizer/mesos/isolators/network/port_mapping.hpp
index 0865a71..eaea644 100644
--- a/src/slave/containerizer/mesos/isolators/network/port_mapping.hpp
+++ b/src/slave/containerizer/mesos/isolators/network/port_mapping.hpp
@@ -255,6 +255,7 @@ private:
const net::IPNetwork& _hostIPNetwork,
const size_t _hostEth0MTU,
const net::IP& _hostDefaultGateway,
+ const routing::Handle& _hostTxFqCodelHandle,
const hashmap<std::string, std::string>& _hostNetworkConfigurations,
const Option<Bytes>& _egressRateLimitPerContainer,
const IntervalSet<uint16_t>& _managedNonEphemeralPorts,
@@ -267,6 +268,7 @@ private:
hostIPNetwork(_hostIPNetwork),
hostEth0MTU(_hostEth0MTU),
hostDefaultGateway(_hostDefaultGateway),
+ hostTxFqCodelHandle(_hostTxFqCodelHandle),
hostNetworkConfigurations(_hostNetworkConfigurations),
egressRateLimitPerContainer(_egressRateLimitPerContainer),
managedNonEphemeralPorts(_managedNonEphemeralPorts),
@@ -313,6 +315,7 @@ private:
const net::IPNetwork hostIPNetwork;
const size_t hostEth0MTU;
const net::IP hostDefaultGateway;
+ const routing::Handle hostTxFqCodelHandle;
// Describe the host network configurations. It is a map between
// configure proc files (e.g., /proc/sys/net/core/somaxconn) and
http://git-wip-us.apache.org/repos/asf/mesos/blob/5e1bf473/src/slave/flags.cpp
----------------------------------------------------------------------
diff --git a/src/slave/flags.cpp b/src/slave/flags.cpp
index 31700b4..c4343ab 100644
--- a/src/slave/flags.cpp
+++ b/src/slave/flags.cpp
@@ -559,6 +559,14 @@ mesos::internal::slave::Flags::Flags()
"isolator.",
false);
+ add(&Flags::egress_flow_classifier_parent,
+ "egress_flow_classifier_parent",
+ "When egress_unique_flow_per_container is enabled, we need to install\n"
+ "a flow classifier (fq_codel) qdisc on egress side. This flag specifies\n"
+ "where to install it in the hierarchy. By default, we install it at\n"
+ "root.",
+ "root");
+
add(&Flags::network_enable_socket_statistics_summary,
"network_enable_socket_statistics_summary",
"Whether to collect socket statistics summary for each container.\n"
http://git-wip-us.apache.org/repos/asf/mesos/blob/5e1bf473/src/slave/flags.hpp
----------------------------------------------------------------------
diff --git a/src/slave/flags.hpp b/src/slave/flags.hpp
index 0858bdf..1250786 100644
--- a/src/slave/flags.hpp
+++ b/src/slave/flags.hpp
@@ -113,6 +113,7 @@ public:
Option<std::string> lo_name;
Option<Bytes> egress_rate_limit_per_container;
bool egress_unique_flow_per_container;
+ std::string egress_flow_classifier_parent;
bool network_enable_socket_statistics_summary;
bool network_enable_socket_statistics_details;
#endif