Fixed the incomplete `TaskStatus` message of docker executor.

When we enable health check for the tasks run in docker container,
their `TaskStatus` messages generated by docker executor may miss
`NetworkInfo` field and agent would fill the host ip as default value.
In this change, we cache the `NetworkInfo` of the task and reuse it
when generating `TaskStatus` messages which the task's health is
updated.

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


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

Branch: refs/heads/1.0.x
Commit: ff5e084da779dc2294bb9ee50fb515a85b1dbe8c
Parents: 0d51860
Author: haosdent huang <haosd...@gmail.com>
Authored: Mon Jul 18 18:01:42 2016 +0200
Committer: Vinod Kone <vinodk...@gmail.com>
Committed: Fri Jul 22 11:41:49 2016 -0700

----------------------------------------------------------------------
 src/docker/executor.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ff5e084d/src/docker/executor.cpp
----------------------------------------------------------------------
diff --git a/src/docker/executor.cpp b/src/docker/executor.cpp
index 9fcf83c..0d1fd65 100644
--- a/src/docker/executor.cpp
+++ b/src/docker/executor.cpp
@@ -201,6 +201,8 @@ public:
 
             NetworkInfo::IPAddress* ipAddress = 
networkInfo->add_ip_addresses();
             ipAddress->set_ip_address(container.ipAddress.get());
+
+            containerNetworkInfo = *networkInfo;
           }
           driver->sendStatusUpdate(status);
         }
@@ -295,6 +297,12 @@ protected:
     status.mutable_task_id()->CopyFrom(taskID);
     status.set_healthy(healthy);
     status.set_state(TASK_RUNNING);
+
+    if (containerNetworkInfo.isSome()) {
+      status.mutable_container_status()->add_network_infos()->CopyFrom(
+          containerNetworkInfo.get());
+    }
+
     driver.get()->sendStatusUpdate(status);
 
     if (initiateTaskKill) {
@@ -576,6 +584,7 @@ private:
   Option<ExecutorDriver*> driver;
   Option<FrameworkInfo> frameworkInfo;
   Option<TaskID> taskId;
+  Option<NetworkInfo> containerNetworkInfo;
 };
 
 

Reply via email to