You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2015/07/25 02:40:43 UTC

mesos git commit: Added address field to MasterInfo.

Repository: mesos
Updated Branches:
  refs/heads/master d8969c0d1 -> aa39faa6d


Added address field to MasterInfo.

    As part of the new HTTP API and the need to
    provide a better interface for clients that
    do not integrate libmesos, we provide the IP
    address of the Leader Master in the information
    that gets serialized (in JSON) to ZooKeeper.

    This will eventually supersede the `ip`, `port`
    and `hostname` fields that are currently in
    MasterInfo an which cannot fully support IPv6
    addresses.

    Jira: MESOS-2736

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


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

Branch: refs/heads/master
Commit: aa39faa6d6c656cef375055fd507e253c62d2cc9
Parents: d8969c0
Author: Marco Massenzio <ma...@mesosphere.io>
Authored: Fri Jul 24 17:39:32 2015 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Fri Jul 24 17:40:11 2015 -0700

----------------------------------------------------------------------
 CHANGELOG                                     |  9 ++++++++
 include/mesos/mesos.proto                     | 26 +++++++++++++++++++++-
 src/common/protobuf_utils.cpp                 | 11 ++++++++-
 src/master/master.cpp                         |  9 ++++++++
 src/tests/master_contender_detector_tests.cpp | 22 ++++++++++++++++++
 5 files changed, 75 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/aa39faa6/CHANGELOG
----------------------------------------------------------------------
diff --git a/CHANGELOG b/CHANGELOG
index 1a8649d..afffa35 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,12 @@
+Release Notes - Mesos - Version 0.24.0
+--------------------------------------------
+This release contains new features:
+
+* Deprecations:
+  * [MESOS-2736]  - MasterInfo `ip`, `port` and `hostname` are deprecated in
+                    favor of using the `address` field (see `Address` protobuf)
+
+
 Release Notes - Mesos - Version 0.23.0
 --------------------------------------------
 This release contains new features:

http://git-wip-us.apache.org/repos/asf/mesos/blob/aa39faa6/include/mesos/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto
index dfb1fd5..a6748d1 100644
--- a/include/mesos/mesos.proto
+++ b/include/mesos/mesos.proto
@@ -96,7 +96,7 @@ message ContainerID {
 /**
  * A network address.
  *
- * TODO(bmahler): Use this more widely (e.g. MasterInfo).
+ * TODO(bmahler): Use this more widely.
  */
 message Address {
   // May contain a hostname, IP address, or both.
@@ -369,11 +369,35 @@ message ExecutorInfo {
  */
 message MasterInfo {
   required string id = 1;
+
+  // The IP address (only IPv4) as a packed 4-bytes integer,
+  // stored in network order.  Deprecated, use `address.ip` instead.
   required uint32 ip = 2;
+
+  // The TCP port the Master is listening on for incoming
+  // HTTP requests; deprecated, use `address.port` instead.
   required uint32 port = 3 [default = 5050];
+
+  // In the default implementation, this will contain information
+  // about both the IP address, port and Master name; it should really
+  // not be relied upon by external tooling/frameworks and be
+  // considered an "internal" implementation field.
   optional string pid = 4;
+
+  // The server's hostname, if available; it may be unreliable
+  // in environments where the DNS configuration does not resolve
+  // internal hostnames (eg, some public cloud providers).
+  // Deprecated, use `address.hostname` instead.
   optional string hostname = 5;
+
+  // The running Master version, as a string; taken from the
+  // generated "master/version.hpp".
   optional string version = 6;
+
+  // The full IP address (supports both IPv4 and IPv6 formats)
+  // and supersedes the use of `ip`, `port` and `hostname`.
+  // Since Mesos 0.24.
+  optional Address address = 7;
 }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/aa39faa6/src/common/protobuf_utils.cpp
----------------------------------------------------------------------
diff --git a/src/common/protobuf_utils.cpp b/src/common/protobuf_utils.cpp
index 0b8b04c..bf178d2 100644
--- a/src/common/protobuf_utils.cpp
+++ b/src/common/protobuf_utils.cpp
@@ -190,14 +190,23 @@ MasterInfo createMasterInfo(const UPID& pid)
 
   // NOTE: Currently, we store the ip in network order, which should
   // be fixed. See MESOS-1201 for more details.
+  // TODO(marco): `ip` and `port` are deprecated in favor of `address`;
+  //     remove them both after the deprecation cycle.
   info.set_ip(pid.address.ip.in().get().s_addr);
-
   info.set_port(pid.address.port);
+
+  info.mutable_address()->set_ip(stringify(pid.address.ip));
+  info.mutable_address()->set_port(pid.address.port);
+
   info.set_pid(pid);
 
   Try<string> hostname = net::getHostname(pid.address.ip);
   if (hostname.isSome()) {
+    // Hostname is deprecated; but we need to update it
+    // to maintain backward compatibility.
+    // TODO(marco): Remove once we deprecate it.
     info.set_hostname(hostname.get());
+    info.mutable_address()->set_hostname(hostname.get());
   }
 
   return info;

http://git-wip-us.apache.org/repos/asf/mesos/blob/aa39faa6/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 613a011..5b5e3c3 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -85,6 +85,7 @@
 #include "watcher/whitelist_watcher.hpp"
 
 using std::list;
+using std::ostringstream;
 using std::shared_ptr;
 using std::string;
 using std::vector;
@@ -316,6 +317,9 @@ Master::Master(
 
   // NOTE: Currently, we store ip in MasterInfo in network order,
   // which should be fixed. See MESOS-1201 for details.
+  // TODO(marco): The ip, port, hostname fields above are
+  //     being deprecated; the code should be removed once
+  //     the deprecation cycle is complete.
   info_.set_ip(self().address.ip.in().get().s_addr);
 
   info_.set_port(self().address.port);
@@ -338,6 +342,11 @@ Master::Master(
   }
 
   info_.set_hostname(hostname);
+
+  // This uses the new `Address` message in `MasterInfo`.
+  info_.mutable_address()->set_ip(stringify(self().address.ip));
+  info_.mutable_address()->set_port(self().address.port);
+  info_.mutable_address()->set_hostname(hostname);
 }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/aa39faa6/src/tests/master_contender_detector_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_contender_detector_tests.cpp b/src/tests/master_contender_detector_tests.cpp
index d7a3b46..1da7f91 100644
--- a/src/tests/master_contender_detector_tests.cpp
+++ b/src/tests/master_contender_detector_tests.cpp
@@ -182,6 +182,28 @@ TEST(BasicMasterContenderDetectorTest, Detector)
 }
 
 
+TEST(BasicMasterContenderDetectorTest, MasterInfo)
+{
+  PID<Master> master;
+  master.address.ip = net::IP::parse("10.10.1.105", AF_INET).get();
+  master.address.port = 8088;
+
+  StandaloneMasterDetector detector;
+
+  Future<Option<MasterInfo> > detected = detector.detect();
+
+  detector.appoint(master);
+
+  AWAIT_READY(detected);
+  ASSERT_SOME(detected.get());
+  const MasterInfo& info = detected.get().get();
+
+  ASSERT_TRUE(info.has_address());
+  EXPECT_EQ("10.10.1.105", info.address().ip());
+  ASSERT_EQ(8088, info.address().port());
+}
+
+
 #ifdef MESOS_HAS_JAVA
 class ZooKeeperMasterContenderDetectorTest : public ZooKeeperTest {};