Repository: mesos Updated Branches: refs/heads/master 37f8545ac -> 1e83bdac0
Handle potential 'net::hostname()' failure. Review: https://reviews.apache.org/r/36794 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/1e83bdac Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/1e83bdac Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/1e83bdac Branch: refs/heads/master Commit: 1e83bdac04dfbe3f58f93ae3cec4ddd61a993210 Parents: 37f8545 Author: Michael Park <[email protected]> Authored: Fri Jul 24 14:25:39 2015 -0700 Committer: Benjamin Hindman <[email protected]> Committed: Fri Jul 24 14:26:08 2015 -0700 ---------------------------------------------------------------------- include/mesos/mesos.proto | 3 ++- src/sched/sched.cpp | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/1e83bdac/include/mesos/mesos.proto ---------------------------------------------------------------------- diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto index e015c81..dfb1fd5 100644 --- a/include/mesos/mesos.proto +++ b/include/mesos/mesos.proto @@ -156,7 +156,8 @@ message FrameworkInfo { // Used to indicate the current host from which the scheduler is // registered in the Mesos Web UI. If set to an empty string Mesos - // will automagically set it to the current hostname. + // will automagically set it to the current hostname if one is + // available. optional string hostname = 7; // This field should match the credential's principal the framework http://git-wip-us.apache.org/repos/asf/mesos/blob/1e83bdac/src/sched/sched.cpp ---------------------------------------------------------------------- diff --git a/src/sched/sched.cpp b/src/sched/sched.cpp index e411f37..1bcc376 100644 --- a/src/sched/sched.cpp +++ b/src/sched/sched.cpp @@ -1521,8 +1521,12 @@ void MesosSchedulerDriver::initialize() { framework.set_user(user.get()); } + if (framework.hostname().empty()) { - framework.set_hostname(net::hostname().get()); + Try<string> hostname = net::hostname(); + if (hostname.isSome()) { + framework.set_hostname(hostname.get()); + } } // Launch a local cluster if necessary.
