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 2016/10/12 18:01:53 UTC

[2/5] mesos git commit: Added the 'name' and 'args' field to the 'delegate' plugin's CNI config.

Added the 'name' and 'args' field to the 'delegate' plugin's CNI config.

When the port-mapper plugin invokes the 'delegate' plugin, the CNI
config of the 'delegate' plugin needs to have the 'name' and the
'args' fields set. We are therefore updating the config during
creation of the `PortMapper` object, and will use this config when
the 'delegate' plugin is invoked.

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


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

Branch: refs/heads/master
Commit: 7a9f1c485829c2aedb20adeaec4556bf73e74e48
Parents: 539d67f
Author: Avinash sridharan <av...@mesosphere.io>
Authored: Wed Oct 12 09:53:33 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Oct 12 10:59:45 2016 -0700

----------------------------------------------------------------------
 .../network/cni/plugins/port_mapper/port_mapper.cpp  | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/7a9f1c48/src/slave/containerizer/mesos/isolators/network/cni/plugins/port_mapper/port_mapper.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/network/cni/plugins/port_mapper/port_mapper.cpp b/src/slave/containerizer/mesos/isolators/network/cni/plugins/port_mapper/port_mapper.cpp
index 5caa6d7..5de777c 100644
--- a/src/slave/containerizer/mesos/isolators/network/cni/plugins/port_mapper/port_mapper.cpp
+++ b/src/slave/containerizer/mesos/isolators/network/cni/plugins/port_mapper/port_mapper.cpp
@@ -166,13 +166,13 @@ Try<Owned<PortMapper>, PluginError> PortMapper::create(const string& _cniConfig)
 
   // The port-mapper should always be used in conjunction with another
   // 'delegate' CNI plugin.
-  Result<JSON::Object> delegateConfig =
+  Result<JSON::Object> _delegateConfig =
     cniConfig->find<JSON::Object>("delegate");
 
-  if (!delegateConfig.isSome()) {
+  if (!_delegateConfig.isSome()) {
     return PluginError(
         "Failed to get the required field 'delegate'" +
-        (delegateConfig.isError() ? delegateConfig.error() : "Not found"),
+        (_delegateConfig.isError() ? _delegateConfig.error() : "Not found"),
         ERROR_BAD_ARGS);
   }
 
@@ -181,7 +181,7 @@ Try<Owned<PortMapper>, PluginError> PortMapper::create(const string& _cniConfig)
 
   // Make sure the 'delegate' plugin exists.
   Result<JSON::String> delegatePlugin =
-    delegateConfig->find<JSON::String>("type");
+    _delegateConfig->find<JSON::String>("type");
 
   if (!delegatePlugin.isSome()) {
     return PluginError(
@@ -197,6 +197,11 @@ Try<Owned<PortMapper>, PluginError> PortMapper::create(const string& _cniConfig)
         ERROR_BAD_ARGS);
   }
 
+  // Add the 'name' and 'args' field to the 'delegate' config.
+  JSON::Object delegateConfig(_delegateConfig.get());
+  delegateConfig.values["name"] = name.get();
+  delegateConfig.values["args"] = args.get();
+
   return Owned<PortMapper>(
       new PortMapper(
           cniCommand.get(),
@@ -207,7 +212,7 @@ Try<Owned<PortMapper>, PluginError> PortMapper::create(const string& _cniConfig)
           cniPath.get(),
           networkInfo.get(),
           delegatePlugin->value,
-          delegateConfig.get(),
+          delegateConfig,
           chain->value,
           excludeDevices));
 }