You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by al...@apache.org on 2018/09/18 18:00:24 UTC

[mesos] 05/06: Fixed broken pipe error in IOSwitchboard.

This is an automated email from the ASF dual-hosted git repository.

alexr pushed a commit to branch 1.6.x
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit c1448f36d4c2c2c8345e7e8d1bf1f206dba18dac
Author: Andrei Budnik <ab...@mesosphere.com>
AuthorDate: Tue Sep 18 19:10:20 2018 +0200

    Fixed broken pipe error in IOSwitchboard.
    
    We force IOSwitchboard to return a final response to the client for the
    `ATTACH_CONTAINER_INPUT` call after IO redirects are finished. In this
    case, we don't read remaining messages from the input stream. So the
    agent might send an acknowledgment for the request before IOSwitchboard
    has received remaining messages. We need to delay termination of
    IOSwitchboard to give it a chance to read the remaining messages.
    Otherwise, the agent might get `HTTP 500` "broken pipe" while
    attempting to write the final message.
    
    Review: https://reviews.apache.org/r/62187/
    (cherry picked from commit c5cf4d49f47579b5a6cb7afc2f7df7c8f51dc6d0)
---
 src/slave/containerizer/mesos/io/switchboard.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/slave/containerizer/mesos/io/switchboard.cpp b/src/slave/containerizer/mesos/io/switchboard.cpp
index 10680ae..4b50dcb 100644
--- a/src/slave/containerizer/mesos/io/switchboard.cpp
+++ b/src/slave/containerizer/mesos/io/switchboard.cpp
@@ -1620,9 +1620,14 @@ IOSwitchboardServerProcess::acknowledgeContainerInputResponse()
   if (--numPendingAcknowledgments == 0) {
     // If IO redirects are finished or writing to `stdin` failed we want to
     // terminate ourselves (after flushing any outstanding messages from our
-    // message queue).
+    // message queue). Since IOSwitchboard might receive an acknowledgment for
+    // the `ATTACH_CONTAINER_INPUT` request before reading a final message from
+    // the corresponding connection, we need to delay our termination to give
+    // IOSwitchboard a chance to read the final message. Otherwise, the agent
+    // might get `HTTP 500` "broken pipe" while attempting to write the final
+    // message.
     if (!redirectFinished.future().isPending() || failure.isSome()) {
-      terminate(self(), false);
+      after(Seconds(1)).onAny([=]() { terminate(self(), false); });
     }
   }
   return http::OK();