You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2016/09/28 21:44:46 UTC
[3/8] mesos git commit: Added ExitedEvents for links whose sockets
fail on creation.
Added ExitedEvents for links whose sockets fail on creation.
When we try to link to a remote process, we will send the linkee an
`ExitedEvent` when the link is broken or if the connection fails.
This patch adds an `ExitedEvent` when the socket creation step fails.
This is logically equivalent to having the connection step fail.
Because this is an entirely unexpected case, the log level should be
a WARNING or higher.
Review: https://reviews.apache.org/r/52180/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/152484ba
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/152484ba
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/152484ba
Branch: refs/heads/1.0.x
Commit: 152484bab6a31c027136f81b782173255d1c3be7
Parents: c885b26
Author: Joseph Wu <jo...@mesosphere.io>
Authored: Wed Sep 28 12:33:28 2016 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Wed Sep 28 13:22:16 2016 -0700
----------------------------------------------------------------------
3rdparty/libprocess/src/process.cpp | 16 +++++++--
3rdparty/libprocess/src/tests/process_tests.cpp | 34 ++++++++++++++++++++
2 files changed, 48 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/152484ba/3rdparty/libprocess/src/process.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/process.cpp b/3rdparty/libprocess/src/process.cpp
index d0a7a40..5b7be3a 100644
--- a/3rdparty/libprocess/src/process.cpp
+++ b/3rdparty/libprocess/src/process.cpp
@@ -1549,7 +1549,13 @@ void SocketManager::link(
// from SSL to POLL if enabled.
Try<Socket> create = Socket::create(kind);
if (create.isError()) {
- VLOG(1) << "Failed to link, create socket: " << create.error();
+ LOG(WARNING) << "Failed to link, create socket: " << create.error();
+
+ // Failure to create a new socket should generate an `ExitedEvent`
+ // for the linkee. At this point, we have not passed ownership of
+ // this socket to the `SocketManager`, so there is only one possible
+ // linkee to notify.
+ process->enqueue(new ExitedEvent(to));
return;
}
socket = create.get();
@@ -1575,7 +1581,13 @@ void SocketManager::link(
// create a new socket anyway.
Try<Socket> create = Socket::create(kind);
if (create.isError()) {
- VLOG(1) << "Failed to link, create socket: " << create.error();
+ LOG(WARNING) << "Failed to link, create socket: " << create.error();
+
+ // Failure to create a new socket should generate an `ExitedEvent`
+ // for the linkee. At this point, we have not passed ownership of
+ // this socket to the `SocketManager`, so there is only one possible
+ // linkee to notify.
+ process->enqueue(new ExitedEvent(to));
return;
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/152484ba/3rdparty/libprocess/src/tests/process_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/process_tests.cpp b/3rdparty/libprocess/src/tests/process_tests.cpp
index 54d9bbb..368930a 100644
--- a/3rdparty/libprocess/src/tests/process_tests.cpp
+++ b/3rdparty/libprocess/src/tests/process_tests.cpp
@@ -952,6 +952,40 @@ TEST_F(ProcessRemoteLinkTest, RemoteDoubleLinkRelink)
}
+// Verifies that remote links will trigger an `ExitedEvent` if the link
+// fails during socket creation. The test instigates a socket creation
+// failure by hogging all available file descriptors.
+TEST_F(ProcessRemoteLinkTest, RemoteLinkLeak)
+{
+ RemoteLinkTestProcess relinker(pid);
+ Future<UPID> relinkerExitedPid;
+
+ EXPECT_CALL(relinker, exited(pid))
+ .WillOnce(FutureArg<0>(&relinkerExitedPid));
+
+ spawn(relinker);
+
+ // Open enough sockets to fill up all available FDs.
+ vector<Socket> fdHogs;
+ while (true) {
+ Try<Socket> hog = Socket::create();
+
+ if (hog.isError()) {
+ break;
+ }
+
+ fdHogs.push_back(hog.get());
+ }
+
+ relinker.linkup();
+
+ AWAIT_ASSERT_EQ(pid, relinkerExitedPid);
+
+ terminate(relinker);
+ wait(relinker);
+}
+
+
namespace process {
// Forward declare the `get_persistent_socket` function since we want