You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2013/11/08 02:21:34 UTC

[1/4] git commit: Included mesos-cat and mesos-tail in installation.

Updated Branches:
  refs/heads/master 847f6cf43 -> f69eab218


Included mesos-cat and mesos-tail in installation.

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


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

Branch: refs/heads/master
Commit: a63ca0fe0e7e5df9e6c5d6b4452ffeffb86d100f
Parents: 847f6cf
Author: Benjamin Hindman <be...@gmail.com>
Authored: Wed Nov 6 20:10:41 2013 -1000
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Wed Nov 6 22:38:36 2013 -1000

----------------------------------------------------------------------
 src/Makefile.am | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/a63ca0fe/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index a73d6e1..d9e7bcd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -377,7 +377,9 @@ mesos_resolve_LDADD = libmesos.la
 
 # Need to distribute and install mesos-*.
 dist_bin_SCRIPTS +=							\
-  cli/mesos-ps
+  cli/mesos-cat								\
+  cli/mesos-ps								\
+  cli/mesos-tail
 
 # Also install the supporting scripts for the Python based CLI tools.
 # TODO(benh): Use PIP and python/setup.py to do this correctly.


[2/4] git commit: Created 'usage' and moved 'get' helper to cli.py.

Posted by be...@apache.org.
Created 'usage' and moved 'get' helper to cli.py.

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


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

Branch: refs/heads/master
Commit: 39017657fc5f938f581dbffa636bb07c91ba1f11
Parents: a63ca0f
Author: Benjamin Hindman <be...@gmail.com>
Authored: Wed Nov 6 20:11:50 2013 -1000
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Thu Nov 7 15:18:08 2013 -1000

----------------------------------------------------------------------
 src/Makefile.am              |  3 ++-
 src/cli/mesos-ps             | 37 ++++++++++++++-----------------------
 src/cli/python/mesos/cli.py  | 38 +++++++++++++++++++++++---------------
 src/cli/python/mesos/http.py | 27 +++++++++++++++++++++++++++
 4 files changed, 66 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/39017657/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index d9e7bcd..52244dd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -388,7 +388,8 @@ mesospythonpkglibexecdir = $(pkglibexecdir)/python/mesos
 dist_mesospythonpkglibexec_SCRIPTS =					\
   cli/python/mesos/__init__.py						\
   cli/python/mesos/cli.py						\
-  cli/python/mesos/futures.py
+  cli/python/mesos/futures.py						\
+  cli/python/mesos/http.py
 
 # Need to distribute/install webui javascript. We use 'pkgdatadir'
 # instead of 'datadir' as the install directory so we get the the

http://git-wip-us.apache.org/repos/asf/mesos/blob/39017657/src/cli/mesos-ps
----------------------------------------------------------------------
diff --git a/src/cli/mesos-ps b/src/cli/mesos-ps
index 0d1694e..f32c812 100755
--- a/src/cli/mesos-ps
+++ b/src/cli/mesos-ps
@@ -4,11 +4,12 @@ import datetime
 import json
 import signal
 import sys
-import urllib2
 
 from contextlib import closing
 from optparse import OptionParser
+from urllib2 import urlopen
 
+from mesos import http
 from mesos.cli import *
 from mesos.futures import *
 
@@ -62,7 +63,7 @@ def mem(task, statistics):
 
     # An executorless task has an empty executor ID in the master but
     # uses the same executor ID as task ID in the slave.
-    if executor_id == "": executor_id = task['id']
+    if executor_id == '': executor_id = task['id']
 
     mem_rss_bytes = None
     for entry in statistics:
@@ -73,7 +74,7 @@ def mem(task, statistics):
 
     if mem_rss_bytes is not None:
         MB = 1024.0 * 1024.0
-        return "{0:.1f} MB".format(mem_rss_bytes / MB)
+        return '{0:.1f} MB'.format(mem_rss_bytes / MB)
 
     return None
 
@@ -88,7 +89,7 @@ def time(task, statistics):
 
     # An executorless task has an empty executor ID in the master but
     # uses the same executor ID as task ID in the slave.
-    if executor_id == "": executor_id = task['id']
+    if executor_id == '': executor_id = task['id']
 
     cpus_time_secs = None
     for entry in statistics:
@@ -115,9 +116,7 @@ def main():
     (options, args) = parser.parse_args(sys.argv)
 
     if options.master is None:
-        sys.stderr.write('Missing --master\n')
-        parser.print_help()
-        sys.exit(-1)
+        usage('Missing --master', parser)
 
     try:
         timeout = float(options.timeout)
@@ -126,13 +125,11 @@ def main():
         sys.exit(-1)
 
     # Get the master's state.
-    url = 'http://' + resolve(options.master) + '/master/state.json'
-    with closing(urllib2.urlopen(url)) as file:
-        try:
-            state = json.loads(file.read())
-        except:
-            sys.stderr.write('Failed to read the master state\n')
-            sys.exit(1)
+    try:
+        state = http.get(resolve(options.master), '/master/state.json')
+    except:
+        sys.stderr.write('Failed to get the master state\n')
+        sys.exit(1)
 
     # Collect all the active frameworks and tasks by slave ID.
     active = {}
@@ -157,19 +154,13 @@ def main():
         sys.stdout.write(columns[i].title)
         sys.stdout.write(' ' * columns[i].padding)
 
-    # Helper to get the statistics from the slave.
-    def get(slave):
-        pid = slave['pid']
-        url = 'http://' + pid[len('slave(1)@'):] + '/monitor/statistics.json'
-        with closing(urllib2.urlopen(url)) as file:
-            return json.loads(file.read())
-
     with ThreadingExecutor() as executor:
         # Grab all the slaves with active tasks.
         slaves = [slave for slave in state['slaves'] if slave['id'] in active]
 
         # Now submit calls to get the statistics for each slave.
-        futures = dict((executor.submit(get, slave), slave)
+        path = '/monitor/statistics.json'
+        futures = dict((executor.submit(http.get, slave['pid'], path), slave)
                        for slave in slaves)
 
         # And wait for each future to complete!
@@ -198,7 +189,7 @@ def main():
     sys.exit(0)
 
 
-if __name__ == "__main__":
+if __name__ == '__main__':
   def handler(signal, frame):
     sys.stdout.write('\n')
     sys.exit(130)

http://git-wip-us.apache.org/repos/asf/mesos/blob/39017657/src/cli/python/mesos/cli.py
----------------------------------------------------------------------
diff --git a/src/cli/python/mesos/cli.py b/src/cli/python/mesos/cli.py
index 7712886..5c11d46 100644
--- a/src/cli/python/mesos/cli.py
+++ b/src/cli/python/mesos/cli.py
@@ -1,4 +1,10 @@
-import subprocess
+# Helper for printing out a message and then the "usage" then exiting.
+def usage(message, parser):
+    import sys
+    sys.stderr.write(message + '\n')
+    parser.print_help()
+    sys.exit(-1)
+
 
 # Helper that uses 'mesos-resolve' to resolve a master IP:port from
 # one of:
@@ -6,19 +12,21 @@ import subprocess
 #     zk://username:password@host1:port1,host2:port2,.../path
 #     file://path/to/file (where file contains one of the above)
 def resolve(master):
-  process = subprocess.Popen(
-    ['mesos-resolve', master],
-    stdin=None,
-    stdout=subprocess.PIPE,
-    stderr=subprocess.PIPE,
-    shell=False)
+    import subprocess
+
+    process = subprocess.Popen(
+        ['mesos-resolve', master],
+        stdin=None,
+        stdout=subprocess.PIPE,
+        stderr=subprocess.PIPE,
+        shell=False)
 
-  status = process.wait()
-  if status != 0:
-    raise Exception('Failed to execute \'mesos-resolve %s\':\n%s'
-                    % (master, process.stderr.read()))
+    status = process.wait()
+    if status != 0:
+        raise Exception('Failed to execute \'mesos-resolve %s\':\n%s'
+                        % (master, process.stderr.read()))
 
-  result = process.stdout.read()
-  process.stdout.close()
-  process.stderr.close()
-  return result
+    result = process.stdout.read()
+    process.stdout.close()
+    process.stderr.close()
+    return result

http://git-wip-us.apache.org/repos/asf/mesos/blob/39017657/src/cli/python/mesos/http.py
----------------------------------------------------------------------
diff --git a/src/cli/python/mesos/http.py b/src/cli/python/mesos/http.py
new file mode 100644
index 0000000..e65701b
--- /dev/null
+++ b/src/cli/python/mesos/http.py
@@ -0,0 +1,27 @@
+# Helper for doing an HTTP GET given a PID, a path, and a query dict.
+# For example:
+#
+#     get('foo@1.2.3.4:123',
+#         '/endpoint',
+#         {'first': 'ben',
+#          'last': 'hindman'})
+#
+# Would yield: 1.2.3.4:123/endpoint?first='ben'&last='hindman'
+#
+# Note that you can also pass an IP:port (or hostname:port) for 'pid'
+# (i.e., you can omit the ID component of the PID, e.g., 'foo@').
+def get(pid, path, query=None):
+    import json
+    import urllib2
+
+    from contextlib import closing
+
+    url = 'http://' + pid[(pid.find('@') + 1):] + path
+
+    if query is not None and len(query) > 0:
+        url += '?' + '&'.join(
+            ['%s=%s' % (urllib2.quote(str(key)), urllib2.quote(str(value)))
+             for (key, value) in query.items()])
+
+    with closing(urllib2.urlopen(url)) as file:
+        return json.loads(file.read())


[3/4] git commit: Refactored mesos-cat to use helpers from cli.py.

Posted by be...@apache.org.
Refactored mesos-cat to use helpers from cli.py.

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


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

Branch: refs/heads/master
Commit: a7dcb99bbd286a21a15ef95479db0671e117878d
Parents: 3901765
Author: Benjamin Hindman <be...@gmail.com>
Authored: Wed Nov 6 20:12:38 2013 -1000
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Thu Nov 7 15:18:10 2013 -1000

----------------------------------------------------------------------
 src/cli/mesos-cat | 286 +++++++++++++++++++++----------------------------
 1 file changed, 123 insertions(+), 163 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/a7dcb99b/src/cli/mesos-cat
----------------------------------------------------------------------
diff --git a/src/cli/mesos-cat b/src/cli/mesos-cat
index 6ea5d8a..bb1e197 100755
--- a/src/cli/mesos-cat
+++ b/src/cli/mesos-cat
@@ -1,111 +1,79 @@
 #!/usr/bin/env python
 
-import datetime
 import json
 import os
-import resource
-import subprocess
 import signal
 import sys
-import time
-import urllib
+import urllib2
 
+from contextlib import closing
 from optparse import OptionParser
+from urllib2 import HTTPError, urlopen
+
+from mesos import http
+from mesos.cli import *
+from mesos.futures import *
 
 
 if sys.version_info < (2,6,0):
-  sys.stderr.write('Expecting Python >= 2.6\n')
-  sys.exit(1)
-
-
-# Helper that uses 'mesos-resolve' to resolve the master's IP:port.
-def resolve(master):
-  process = subprocess.Popen(
-    ['mesos-resolve', master],
-    stdin=subprocess.PIPE,
-    stdout=subprocess.PIPE,
-    stderr=subprocess.PIPE,
-    shell=False)
-
-  status = process.wait()
-  if status != 0:
-    print "Failed to resolve 'mesos-resolve %s'\n" % master
-    print process.stderr.read()
+    sys.stderr.write('Expecting Python >= 2.6\n')
     sys.exit(1)
 
-  return process.stdout.read()
-
-
-class Slave:
-  def __init__(self, slave):
-    self.slave = slave
-
-  def hostname(self):
-    return self.slave['hostname']
-
-  def curl(self, path, query):
-    pid = self.slave['pid']
-    url = 'http://' + pid[len('slave(1)@'):] + path
-    if query is not None and len(query) > 0:
-      url += '?' + '&'.join(
-        ['%s=%s' % (urllib.quote(str(key)), urllib.quote(str(value))) for (key, value) in query.items()])
-
-    process = subprocess.Popen(
-      ['curl', '-sSfL', url],
-      stdin=None,
-      stdout=subprocess.PIPE,
-      stderr=subprocess.PIPE,
-      shell=False)
-
-    status = process.wait()
-    if status != 0:
-      print 'Failed to execute \'curl\':\n'
-      print process.stderr.read()
-      sys.exit(1)
-
-    result = process.stdout.read()
-    process.stdout.close()
-    process.stderr.close()
-    return result
 
-  def read(self, task, file):
+def read(slave, task, file):
     framework_id = task['framework_id']
     executor_id = task['executor_id']
-    if executor_id == "": executor_id = task['id']
 
-    # Get 'state.json' to get the executor directory.
-    state = json.loads(self.curl('/slave(1)/state.json', None))
+    # An executorless task has an empty executor ID in the master but
+    # uses the same executor ID as task ID in the slave.
+    if executor_id == '': executor_id = task['id']
+
+    # Get 'state.json' to determine the executor directory.
+    try:
+        state = http.get(slave['pid'], '/slave(1)/state.json')
+    except:
+        sys.stderr.write('Failed to get state from slave\n')
+        sys.exit(1)
 
     directory = None
 
     for framework in state['frameworks']:
-      if framework['id'] == framework_id:
-        for executor in framework['executors']:
-          if executor['id'] == executor_id:
-            directory = executor['directory']
-            break
-        for completed_executor in framework['completed_executors']:
-          if completed_executor['id'] == executor_id:
-            directory = completed_executor['directory']
-            break
-
-    for completed_framework in state['completed_frameworks']:
-      if completed_framework['id'] == framework_id:
-        for completed_executor in completed_framework['completed_executors']:
-          if completed_executor['id'] == executor_id:
-            directory = completed_executor['directory']
-            break
+        if framework['id'] == framework_id:
+            for executor in framework['executors']:
+                if executor['id'] == executor_id:
+                    directory = executor['directory']
+                    break
+            for executor in framework['completed_executors']:
+                if executor['id'] == executor_id:
+                    directory = executor['directory']
+                    break
+
+    for framework in state['completed_frameworks']:
+        if framework['id'] == framework_id:
+            for executor in framework['completed_executors']:
+                if executor['id'] == executor_id:
+                    directory = executor['directory']
+                    break
 
     if directory is None:
-      raise IOError('Task directory/file not found')
+        sys.stderr.write('File not found\n')
+        sys.exit(1)
 
     path = os.path.join(directory, file)
 
     # Determine the current length of the file.
-    result = json.loads(self.curl(
-        '/files/read.json',
-        {'path': path,
-         'offset': -1}))
+    try:
+        result = http.get(
+            slave['pid'],
+            '/files/read.json',
+            {'path': path,
+             'offset': -1})
+    except HTTPError as error:
+        if error.code == 404:
+            sys.stderr.write('No such file or directory\n')
+        else:
+            sys.stderr.write('Failed to determine length of file\n')
+        sys.exit(1)
 
     length = result['offset']
 
@@ -114,91 +82,83 @@ class Slave:
     offset = 0
 
     while True:
-      result = json.loads(self.curl(
-          '/files/read.json',
-          {'path': path,
-           'offset': offset,
-           'length': PAGE_LENGTH}))
-      offset += len(result['data'])
-      yield result['data']
-      if offset == length:
-        return
+        try:
+            result = http.get(
+                slave['pid'],
+                '/files/read.json',
+                {'path': path,
+                 'offset': offset,
+                 'length': PAGE_LENGTH})
+            offset += len(result['data'])
+            yield result['data']
+            if offset == length:
+                return
+        except:
+            sys.stderr.write('Failed to read file from slave\n')
+            sys.exit(1)
 
 
 def main():
-  # Parse options for this script.
-  parser = OptionParser()
-  parser.add_option('--master')
-  parser.add_option('--framework')
-  parser.add_option('--task')
-  parser.add_option('--file')
-  (options, args) = parser.parse_args(sys.argv)
-
-  if options.master is None:
-    print "Missing --master\n"
-    parser.print_help()
-    exit(-1)
-
-  if options.framework is None:
-    print "Missing --framework\n"
-    parser.print_help()
-    exit(-1)
-
-  if options.task is None:
-    print "Missing --task\n"
-    parser.print_help()
-    exit(-1)
-
-  if options.file is None:
-    print "Missing --file\n"
-    parser.print_help()
-    exit(-1)
-
-  url = 'http://' + resolve(options.master) + '/master/state.json'
-  file = urllib.urlopen(url)
-  state = json.loads(file.read())
-  file.close()
-
-  # Build a dict from slave ID to `slaves'.
-  slaves = {}
-  for slave in state['slaves']:
-    slaves[slave['id']] = Slave(slave)
-
-  target_task = None
-  target_slave = None
-
-  for framework in state['frameworks']:
-    if framework['id'] == options.framework:
-      for task in framework['tasks']:
-        if (task['id'] == options.task):
-          target_task = task
-          target_slave = slaves[task['slave_id']]
-          break
-      for completed_task in framework['completed_tasks']:
-        if (completed_task['id'] == options.task):
-          target_task = completed_task
-          target_slave = slaves[completed_task['slave_id']]
-          break
-
-  for completed_framework in state['completed_frameworks']:
-    if completed_framework['id'] == options.framework:
-      for completed_task in completed_framework['completed_tasks']:
-        if (completed_task['id'] == options.task):
-          target_task = completed_task
-          target_slave= slaves[completed_task['slave_id']]
-          break
-
-  for data in target_slave.read(target_task, options.file):
-    sys.stdout.write(data)
-    sys.stdout.flush()
-    exit(0)
-
-  sys.stderr.write('No task found!\n')
-  sys.stderr.flush()
-  exit(-1)
-
-
-if __name__ == "__main__":
+    # Parse options for this script.
+    parser = OptionParser()
+    parser.add_option('--master')
+    parser.add_option('--framework')
+    parser.add_option('--task')
+    parser.add_option('--file')
+    (options, args) = parser.parse_args(sys.argv)
+
+    if options.master is None:
+        usage('Missing --master', parser)
+
+    if options.framework is None:
+        usage('Missing --framework', parser)
+
+    if options.task is None:
+        usage('Missing --task', parser)
+
+    if options.file is None:
+        usage('Missing --file', parser)
+
+    # Get the master's state.
+    try:
+        state = http.get(resolve(options.master), '/master/state.json')
+    except:
+        sys.stderr.write('Failed to get the master state\n')
+        sys.exit(1)
+
+    # Build a dict from slave ID to slaves.
+    slaves = {}
+    for slave in state['slaves']:
+        slaves[slave['id']] = slave
+
+    def cat(slave, task):
+        for data in read(slave, task, options.file):
+            sys.stdout.write(data)
+
+    for framework in state['frameworks']:
+        if framework['id'] == options.framework:
+            for task in framework['tasks']:
+                if task['id'] == options.task:
+                    cat(slaves[task['slave_id']], task)
+                    sys.exit(0)
+
+            for task in framework['completed_tasks']:
+                if task['id'] == options.task:
+                    cat(slaves[task['slave_id']], task)
+                    sys.exit(0)
+
+    for framework in state['completed_frameworks']:
+        if framework['id'] == options.framework:
+            for task in framework['completed_tasks']:
+                if task['id'] == options.task:
+                    cat(slaves[task['slave_id']], task)
+                    sys.exit(0)
+
+    sys.stderr.write('No task found!\n')
+    sys.exit(-1)
+
+
+if __name__ == '__main__':
   def signal_handler(signal, frame):
     sys.stdout.write('\n')
     sys.exit(130)


[4/4] git commit: Revised os::realpath to return Result for when path does not exist.

Posted by be...@apache.org.
Revised os::realpath to return Result for when path does not exist.

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


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

Branch: refs/heads/master
Commit: f69eab21808ce9cb2c9cc8290d9d944c5daaaa5d
Parents: a7dcb99
Author: Benjamin Hindman <be...@gmail.com>
Authored: Wed Nov 6 21:30:41 2013 -1000
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Thu Nov 7 15:19:20 2013 -1000

----------------------------------------------------------------------
 .../3rdparty/stout/include/stout/os.hpp         |  5 +-
 src/cli/mesos.cpp                               |  2 +-
 src/files/files.cpp                             | 13 +++--
 src/linux/cgroups.cpp                           | 59 ++++++++++++--------
 src/slave/process_isolator.cpp                  |  9 ++-
 src/slave/slave.cpp                             |  8 ++-
 src/slave/state.cpp                             | 20 ++++---
 src/tests/flags.hpp                             |  2 +-
 src/tests/script.cpp                            |  7 ++-
 9 files changed, 80 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/f69eab21/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
index 18d8b7f..4ce9344 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
@@ -361,10 +361,13 @@ inline Try<std::string> dirname(const std::string& path)
 }
 
 
-inline Try<std::string> realpath(const std::string& path)
+inline Result<std::string> realpath(const std::string& path)
 {
   char temp[PATH_MAX];
   if (::realpath(path.c_str(), temp) == NULL) {
+    if (errno == ENOENT || errno == ENOTDIR) {
+      return None();
+    }
     return ErrnoError();
   }
   return std::string(temp);

http://git-wip-us.apache.org/repos/asf/mesos/blob/f69eab21/src/cli/mesos.cpp
----------------------------------------------------------------------
diff --git a/src/cli/mesos.cpp b/src/cli/mesos.cpp
index fbdc3b9..171a707 100644
--- a/src/cli/mesos.cpp
+++ b/src/cli/mesos.cpp
@@ -57,7 +57,7 @@ int main(int argc, char** argv)
   // the path).
   Try<string> dirname = os::dirname(argv[0]);
   if (dirname.isSome()) {
-    Try<string> realpath = os::realpath(dirname.get());
+    Result<string> realpath = os::realpath(dirname.get());
     if (realpath.isSome()) {
       os::setenv("PATH", realpath.get() + ":" + os::getenv("PATH"));
     }

http://git-wip-us.apache.org/repos/asf/mesos/blob/f69eab21/src/files/files.cpp
----------------------------------------------------------------------
diff --git a/src/files/files.cpp b/src/files/files.cpp
index 69d6852..6b85842 100644
--- a/src/files/files.cpp
+++ b/src/files/files.cpp
@@ -113,11 +113,14 @@ void FilesProcess::initialize()
 
 Future<Nothing> FilesProcess::attach(const string& path, const string& name)
 {
-  Try<string> result = os::realpath(path);
+  Result<string> result = os::realpath(path);
 
-  if (result.isError()) {
+  if (!result.isSome()) {
     return Future<Nothing>::failed(
-        "Failed to get realpath of '" + path + "': " + result.error());
+        "Failed to get realpath of '" + path + "': " +
+        (result.isError()
+         ? result.error()
+         : "No such file or directory"));
   }
 
   // Make sure we have permissions to read the file/dir.
@@ -409,11 +412,13 @@ Result<string> FilesProcess::resolve(const string& path)
       path = path::join(path, suffix);
 
       // Canonicalize the absolute path.
-      Try<string> realpath = os::realpath(path);
+      Result<string> realpath = os::realpath(path);
       if (realpath.isError()) {
         return Error(
             "Failed to determine canonical path of '" + path +
             "': " + realpath.error());
+      } else if (realpath.isNone()) {
+        return None();
       }
 
       // Make sure the canonicalized absolute path is accessible

http://git-wip-us.apache.org/repos/asf/mesos/blob/f69eab21/src/linux/cgroups.cpp
----------------------------------------------------------------------
diff --git a/src/linux/cgroups.cpp b/src/linux/cgroups.cpp
index f1aec3f..8379aa3 100644
--- a/src/linux/cgroups.cpp
+++ b/src/linux/cgroups.cpp
@@ -458,11 +458,13 @@ Try<set<string> > hierarchies()
   set<string> results;
   foreach (const fs::MountTable::Entry& entry, table.get().entries) {
     if (entry.type == "cgroup") {
-      Try<string> realpath = os::realpath(entry.dir);
-      if (realpath.isError()) {
+      Result<string> realpath = os::realpath(entry.dir);
+      if (!realpath.isSome()) {
         return Error(
-            "Failed to determine canonical path of " + entry.dir +
-            ": " + realpath.error());
+            "Failed to determine canonical path of " + entry.dir + ": " +
+            (realpath.isError()
+             ? realpath.error()
+             : "No such file or directory"));
       }
       results.insert(realpath.get());
     }
@@ -573,11 +575,13 @@ Try<set<string> > subsystems()
 Try<set<string> > subsystems(const string& hierarchy)
 {
   // We compare the canonicalized absolute paths.
-  Try<string> hierarchyAbsPath = os::realpath(hierarchy);
-  if (hierarchyAbsPath.isError()) {
+  Result<string> hierarchyAbsPath = os::realpath(hierarchy);
+  if (!hierarchyAbsPath.isSome()) {
     return Error(
-        "Failed to determine canonical path of '" + hierarchy +
-        "': " + hierarchyAbsPath.error());
+        "Failed to determine canonical path of '" + hierarchy + "': " +
+        (hierarchyAbsPath.isError()
+         ? hierarchyAbsPath.error()
+         : "No such file or directory"));
   }
 
   // Read currently mounted file systems from /proc/mounts.
@@ -590,11 +594,13 @@ Try<set<string> > subsystems(const string& hierarchy)
   Option<fs::MountTable::Entry> hierarchyEntry;
   foreach (const fs::MountTable::Entry& entry, table.get().entries) {
     if (entry.type == "cgroup") {
-      Try<string> dirAbsPath = os::realpath(entry.dir);
-      if (dirAbsPath.isError()) {
+      Result<string> dirAbsPath = os::realpath(entry.dir);
+      if (!dirAbsPath.isSome()) {
         return Error(
-            "Failed to determine canonical path of '" + entry.dir +
-            "': " + dirAbsPath.error());
+            "Failed to determine canonical path of '" + entry.dir + "': " +
+            (dirAbsPath.isError()
+             ? dirAbsPath.error()
+             : "No such file or directory"));
       }
 
       // Seems that a directory can be mounted more than once. Previous mounts
@@ -676,11 +682,13 @@ Try<bool> mounted(const string& hierarchy, const string& subsystems)
   }
 
   // We compare canonicalized absolute paths.
-  Try<string> realpath = os::realpath(hierarchy);
-  if (realpath.isError()) {
+  Result<string> realpath = os::realpath(hierarchy);
+  if (!realpath.isSome()) {
     return Error(
-        "Failed to determine canonical path of '" + hierarchy +
-        "': " + realpath.error());
+        "Failed to determine canonical path of '" + hierarchy + "': " +
+        (realpath.isError()
+         ? realpath.error()
+         : "No such file or directory"));
   }
 
   Try<set<string> > hierarchies = cgroups::hierarchies();
@@ -760,18 +768,23 @@ Try<vector<string> > get(const string& hierarchy, const string& cgroup)
     return Error(error.get());
   }
 
-  Try<string> hierarchyAbsPath = os::realpath(hierarchy);
-  if (hierarchyAbsPath.isError()) {
+  Result<string> hierarchyAbsPath = os::realpath(hierarchy);
+  if (!hierarchyAbsPath.isSome()) {
     return Error(
-        "Failed to determine canonical path of '" + hierarchy +
-        "': " + hierarchyAbsPath.error());
+        "Failed to determine canonical path of '" + hierarchy + "': " +
+        (hierarchyAbsPath.isError()
+         ? hierarchyAbsPath.error()
+         : "No such file or directory"));
   }
 
-  Try<string> destAbsPath = os::realpath(path::join(hierarchy, cgroup));
-  if (destAbsPath.isError()) {
+  Result<string> destAbsPath = os::realpath(path::join(hierarchy, cgroup));
+  if (!destAbsPath.isSome()) {
     return Error(
         "Failed to determine canonical path of '" +
-        path::join(hierarchy, cgroup) + "': " + destAbsPath.error());
+        path::join(hierarchy, cgroup) + "': " +
+        (destAbsPath.isError()
+         ? destAbsPath.error()
+         : "No such file or directory"));
   }
 
   char* paths[] = { const_cast<char*>(destAbsPath.get().c_str()), NULL };

http://git-wip-us.apache.org/repos/asf/mesos/blob/f69eab21/src/slave/process_isolator.cpp
----------------------------------------------------------------------
diff --git a/src/slave/process_isolator.cpp b/src/slave/process_isolator.cpp
index fa80293..a6e9ed6 100644
--- a/src/slave/process_isolator.cpp
+++ b/src/slave/process_isolator.cpp
@@ -211,14 +211,17 @@ void ProcessIsolator::launchExecutor(
     const char** args = (const char**) new char*[2];
 
     // Determine path for mesos-launcher.
-    Try<string> realpath = os::realpath(
+    Result<string> realpath = os::realpath(
         path::join(flags.launcher_dir, "mesos-launcher"));
 
-    if (realpath.isError()) {
+    if (!realpath.isSome()) {
       EXIT(1) << "Failed to determine the canonical path "
               << "for the mesos-launcher '"
               << path::join(flags.launcher_dir, "mesos-launcher")
-              << "': " << realpath.error();
+              << "': "
+              << (realpath.isError()
+                  ? realpath.error()
+                  : "No such file or directory");
     }
 
     // Grab a copy of the path so that we can reliably use 'c_str()'.

http://git-wip-us.apache.org/repos/asf/mesos/blob/f69eab21/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 90575db..13cb418 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -1998,14 +1998,18 @@ ExecutorInfo Slave::getExecutorInfo(
     // echo the error and exit).
     executor.mutable_command()->MergeFrom(task.command());
 
-    Try<string> path = os::realpath(
+    Result<string> path = os::realpath(
         path::join(flags.launcher_dir, "mesos-executor"));
 
     if (path.isSome()) {
       executor.mutable_command()->set_value(path.get());
     } else {
       executor.mutable_command()->set_value(
-          "echo '" + path.error() + "'; exit 1");
+          "echo '" +
+          (path.isError()
+           ? path.error()
+           : "No such file or directory") +
+          "'; exit 1");
     }
 
     // TODO(benh): Set some resources for the executor so that a task

http://git-wip-us.apache.org/repos/asf/mesos/blob/f69eab21/src/slave/state.cpp
----------------------------------------------------------------------
diff --git a/src/slave/state.cpp b/src/slave/state.cpp
index c675b4c..bf267b5 100644
--- a/src/slave/state.cpp
+++ b/src/slave/state.cpp
@@ -50,9 +50,12 @@ Result<SlaveState> recover(const string& rootDir, bool strict)
   }
 
   // Get the latest slave id.
-  Try<string> directory = os::realpath(latest);
-  if (directory.isError()) {
-    return Error("Failed to find latest slave: " + directory.error());
+  Result<string> directory = os::realpath(latest);
+  if (!directory.isSome()) {
+    return Error("Failed to find latest slave: " +
+                 (directory.isError()
+                  ? directory.error()
+                  : "No such file or directory"));
   }
 
   SlaveID slaveId;
@@ -309,11 +312,14 @@ Try<ExecutorState> ExecutorState::recover(
   // Recover the runs.
   foreach (const string& path, runs.get()) {
     if (os::basename(path).get() == paths::LATEST_SYMLINK) {
-      const Try<string>& latest = os::realpath(path);
-      if (latest.isError()) {
+      const Result<string>& latest = os::realpath(path);
+      if (!latest.isSome()) {
         return Error(
-            "Failed to find latest run of executor '" + executorId.value() +
-            "': " + latest.error());
+            "Failed to find latest run of executor '" +
+            executorId.value() + "': " +
+            (latest.isError()
+             ? latest.error()
+             : "No such file or directory"));
       }
 
       // Store the UUID of the latest executor run.

http://git-wip-us.apache.org/repos/asf/mesos/blob/f69eab21/src/tests/flags.hpp
----------------------------------------------------------------------
diff --git a/src/tests/flags.hpp b/src/tests/flags.hpp
index 071f138..9760a7a 100644
--- a/src/tests/flags.hpp
+++ b/src/tests/flags.hpp
@@ -47,7 +47,7 @@ public:
     // preprocessor definitions (at the time this comment was written
     // these were set via '-DSOURCE_DIR=...' and '-DBUILD_DIR=...' in
     // src/Makefile.am).
-    Try<std::string> path = os::realpath(SOURCE_DIR);
+    Result<std::string> path = os::realpath(SOURCE_DIR);
     CHECK_SOME(path);
     add(&Flags::source_dir,
         "source_dir",

http://git-wip-us.apache.org/repos/asf/mesos/blob/f69eab21/src/tests/script.cpp
----------------------------------------------------------------------
diff --git a/src/tests/script.cpp b/src/tests/script.cpp
index b3bbf87..09c7f3b 100644
--- a/src/tests/script.cpp
+++ b/src/tests/script.cpp
@@ -53,11 +53,12 @@ void execute(const string& script)
   }
 
   // Determine the path for the script.
-  Try<string> path =
+  Result<string> path =
     os::realpath(path::join(flags.source_dir, "src", "tests", script));
 
-  if (path.isError()) {
-    FAIL() << "Failed to locate script: " << path.error();
+  if (!path.isSome()) {
+    FAIL() << "Failed to locate script: "
+           << (path.isError() ? path.error() : "No such file or directory");
   }
 
   // Fork a process to change directory and run the test.