Fixed Mesos since `os::spawn()` now returns an `Option<int>`. The `os::spawn()` function now returns `None()` for a launch failure instead of `-1`, and a `Some(exit_code)` for success.
Review: https://reviews.apache.org/r/65864/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/be8be3b8 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/be8be3b8 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/be8be3b8 Branch: refs/heads/master Commit: be8be3b88ec0c1bddd461cb2ed1396ebd8f03b70 Parents: 1971a54 Author: Akash Gupta <akash-gu...@hotmail.com> Authored: Tue Mar 6 13:11:27 2018 -0800 Committer: Andrew Schwartzmeyer <and...@schwartzmeyer.com> Committed: Tue Mar 6 13:52:56 2018 -0800 ---------------------------------------------------------------------- src/linux/fs.cpp | 15 ++++++++------- .../mesos/isolators/network/cni/cni.cpp | 10 ++++++---- src/tests/containerizer/perf_tests.cpp | 4 +++- 3 files changed, 17 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/be8be3b8/src/linux/fs.cpp ---------------------------------------------------------------------- diff --git a/src/linux/fs.cpp b/src/linux/fs.cpp index dae0942..ed26f80 100644 --- a/src/linux/fs.cpp +++ b/src/linux/fs.cpp @@ -38,16 +38,16 @@ extern "C" { #include <stout/adaptor.hpp> #include <stout/check.hpp> #include <stout/error.hpp> +#include <stout/fs.hpp> #include <stout/hashmap.hpp> #include <stout/hashset.hpp> #include <stout/numify.hpp> +#include <stout/option.hpp> +#include <stout/os.hpp> #include <stout/path.hpp> #include <stout/strings.hpp> #include <stout/synchronized.hpp> -#include <stout/fs.hpp> -#include <stout/os.hpp> - #include <stout/os/read.hpp> #include <stout/os/realpath.hpp> #include <stout/os/shell.hpp> @@ -554,17 +554,18 @@ Try<Nothing> unmountAll(const string& target, int flags) // still catch the error here in case there's an error somewhere // else while running this command. // TODO(xujyan): Consider using `setmntent(3)` to implement this. - int status = os::spawn("umount", {"umount", "--fake", entry.dir}); + const Option<int> status = + os::spawn("umount", {"umount", "--fake", entry.dir}); const string message = "Failed to clean up '" + entry.dir + "' in /etc/mtab"; - if (status == -1) { + if (status.isNone()) { return ErrnoError(message); } - if (!WSUCCEEDED(status)) { - return Error(message + ": " + WSTRINGIFY(status)); + if (!WSUCCEEDED(status.get())) { + return Error(message + ": " + WSTRINGIFY(status.get())); } } } http://git-wip-us.apache.org/repos/asf/mesos/blob/be8be3b8/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp ---------------------------------------------------------------------- diff --git a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp b/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp index c60c23f..d8dc02a 100644 --- a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp +++ b/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp @@ -27,6 +27,7 @@ #include <stout/adaptor.hpp> #include <stout/net.hpp> +#include <stout/option.hpp> #include <stout/os.hpp> #include <stout/path.hpp> #include <stout/strings.hpp> @@ -2077,20 +2078,21 @@ int NetworkCniIsolatorSetup::execute() return EXIT_FAILURE; } - int status = os::spawn("ifconfig", {"ifconfig", "lo", "up"}); + const Option<int> status = os::spawn("ifconfig", {"ifconfig", "lo", "up"}); const string message = "Failed to bring up the loopback interface in the new " "network namespace of pid " + stringify(flags.pid.get()); - if (status == -1) { + if (status.isNone()) { cerr << message << ": " << "os::spawn failed: " << os::strerror(errno) << endl; return EXIT_FAILURE; } - if (!WSUCCEEDED(status)) { - cerr << message << ": 'ifconfig lo up' " << WSTRINGIFY(status) << endl; + if (!WSUCCEEDED(status.get())) { + cerr << message << ": 'ifconfig lo up' " + << WSTRINGIFY(status.get()) << endl; return EXIT_FAILURE; } } http://git-wip-us.apache.org/repos/asf/mesos/blob/be8be3b8/src/tests/containerizer/perf_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/containerizer/perf_tests.cpp b/src/tests/containerizer/perf_tests.cpp index d8aab08..7176240 100644 --- a/src/tests/containerizer/perf_tests.cpp +++ b/src/tests/containerizer/perf_tests.cpp @@ -24,6 +24,7 @@ #include <process/gtest.hpp> #include <stout/gtest.hpp> +#include <stout/option.hpp> #include <stout/os.hpp> #include <stout/stringify.hpp> @@ -137,7 +138,8 @@ TEST_F(PerfTest, Version) // version, make sure we can parse it using the perf library. // Note that on some systems, perf is a stub that asks you to // install the right packages. - if (WSUCCEEDED(os::spawn("perf", {"perf", "--version"}))) { + const Option<int> status = os::spawn("perf", {"perf", "--version"}); + if (status.isSome() && WSUCCEEDED(status.get())) { AWAIT_READY(perf::version()); }