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 2014/10/26 05:30:13 UTC

git commit: PortMappingIsolator: Swap TX/RX in statistic collection in usage

Repository: mesos
Updated Branches:
  refs/heads/master 6a045e98f -> b4528ce46


PortMappingIsolator: Swap TX/RX in statistic collection in usage

statistics collected on the host end of veth pair have reversed RX/TX of those in the container.

Review: https://reviews.apache.org/r/27154


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b4528ce4
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b4528ce4
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b4528ce4

Branch: refs/heads/master
Commit: b4528ce46f797234fb5a3bad29cb81da8113e73e
Parents: 6a045e9
Author: Chi Zhang <ch...@gmail.com>
Authored: Sat Oct 25 21:28:45 2014 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Sat Oct 25 21:28:45 2014 -0700

----------------------------------------------------------------------
 .../isolators/network/port_mapping.cpp          | 31 +++++++++++++++-----
 1 file changed, 23 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/b4528ce4/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 62ca9bc..9cb7487 100644
--- a/src/slave/containerizer/isolators/network/port_mapping.cpp
+++ b/src/slave/containerizer/isolators/network/port_mapping.cpp
@@ -1980,42 +1980,57 @@ Future<ResourceStatistics> PortMappingIsolatorProcess::usage(
     return Failure("Failed to find link: " + veth(info->pid.get()));
   }
 
-  Option<uint64_t> rx_packets = stat.get().get("rx_packets");
+  // Note: The RX/TX statistics on the two ends of the veth are the
+  // exact opposite, because of its 'tunnel' nature. We sample on the
+  // host end of the veth pair, which means we have to reverse RX and
+  // TX to reflect statistics inside the container.
+
+  // +----------+                    +----------+
+  // |          |                    |          |
+  // |          |RX<--------------+TX|          |
+  // |          |                    |          |
+  // |   veth   |                    |   eth0   |
+  // |          |                    |          |
+  // |          |TX+-------------->RX|          |
+  // |          |                    |          |
+  // +----------+                    +----------+
+
+  Option<uint64_t> rx_packets = stat.get().get("tx_packets");
   if (rx_packets.isSome()) {
     result.set_net_rx_packets(rx_packets.get());
   }
 
-  Option<uint64_t> rx_bytes = stat.get().get("rx_bytes");
+  Option<uint64_t> rx_bytes = stat.get().get("tx_bytes");
   if (rx_bytes.isSome()) {
     result.set_net_rx_bytes(rx_bytes.get());
   }
 
-  Option<uint64_t> rx_errors = stat.get().get("rx_errors");
+  Option<uint64_t> rx_errors = stat.get().get("tx_errors");
   if (rx_errors.isSome()) {
     result.set_net_rx_errors(rx_errors.get());
   }
 
-  Option<uint64_t> rx_dropped = stat.get().get("rx_dropped");
+  Option<uint64_t> rx_dropped = stat.get().get("tx_dropped");
   if (rx_dropped.isSome()) {
     result.set_net_rx_dropped(rx_dropped.get());
   }
 
-  Option<uint64_t> tx_packets = stat.get().get("tx_packets");
+  Option<uint64_t> tx_packets = stat.get().get("rx_packets");
   if (tx_packets.isSome()) {
     result.set_net_tx_packets(tx_packets.get());
   }
 
-  Option<uint64_t> tx_bytes = stat.get().get("tx_bytes");
+  Option<uint64_t> tx_bytes = stat.get().get("rx_bytes");
   if (tx_bytes.isSome()) {
     result.set_net_tx_bytes(tx_bytes.get());
   }
 
-  Option<uint64_t> tx_errors = stat.get().get("tx_errors");
+  Option<uint64_t> tx_errors = stat.get().get("rx_errors");
   if (tx_errors.isSome()) {
     result.set_net_tx_errors(tx_errors.get());
   }
 
-  Option<uint64_t> tx_dropped = stat.get().get("tx_dropped");
+  Option<uint64_t> tx_dropped = stat.get().get("rx_dropped");
   if (tx_dropped.isSome()) {
     result.set_net_tx_dropped(tx_dropped.get());
   }