Checked validity of master and agent version numbers on startup.

During startup, we now check that the compiled-in version number of the
master and agent can be parsed by stout's `Version::parse` (i.e., that
`MESOS_VERSION` is valid according to stout's extended variant of the
Semver 2.0.0 format).

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


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

Branch: refs/heads/1.2.x
Commit: 5a5dd8a4edcb52e2227e2a4607b95a7dcc6aa321
Parents: c56851e
Author: Neil Conway <[email protected]>
Authored: Mon Mar 6 10:55:07 2017 -0800
Committer: Neil Conway <[email protected]>
Committed: Fri May 5 15:16:38 2017 -0700

----------------------------------------------------------------------
 src/master/main.cpp | 11 +++++++++++
 src/slave/main.cpp  | 11 +++++++++++
 2 files changed, 22 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/5a5dd8a4/src/master/main.cpp
----------------------------------------------------------------------
diff --git a/src/master/main.cpp b/src/master/main.cpp
index da75fe9..d485a06 100644
--- a/src/master/main.cpp
+++ b/src/master/main.cpp
@@ -57,6 +57,7 @@
 #include <stout/stringify.hpp>
 #include <stout/strings.hpp>
 #include <stout/try.hpp>
+#include <stout/version.hpp>
 
 #include "common/build.hpp"
 #include "common/http.hpp"
@@ -175,6 +176,16 @@ int main(int argc, char** argv)
     return EXIT_FAILURE;
   }
 
+  // Check that master's version has the expected format (SemVer).
+  {
+    Try<Version> version = Version::parse(MESOS_VERSION);
+    if (version.isError()) {
+      EXIT(EXIT_FAILURE)
+        << "Failed to parse Mesos version '" << MESOS_VERSION << "': "
+        << version.error();
+    }
+  }
+
   if (flags.ip_discovery_command.isSome() && flags.ip.isSome()) {
     EXIT(EXIT_FAILURE) << flags.usage(
         "Only one of `--ip` or `--ip_discovery_command` should be specified");

http://git-wip-us.apache.org/repos/asf/mesos/blob/5a5dd8a4/src/slave/main.cpp
----------------------------------------------------------------------
diff --git a/src/slave/main.cpp b/src/slave/main.cpp
index 31f2b4f..f90aa2f 100644
--- a/src/slave/main.cpp
+++ b/src/slave/main.cpp
@@ -39,6 +39,7 @@
 #include <stout/os.hpp>
 #include <stout/stringify.hpp>
 #include <stout/try.hpp>
+#include <stout/version.hpp>
 
 #include "common/build.hpp"
 #include "common/http.hpp"
@@ -142,6 +143,16 @@ int main(int argc, char** argv)
     return EXIT_FAILURE;
   }
 
+  // Check that agent's version has the expected format (SemVer).
+  {
+    Try<Version> version = Version::parse(MESOS_VERSION);
+    if (version.isError()) {
+      EXIT(EXIT_FAILURE)
+        << "Failed to parse Mesos version '" << MESOS_VERSION << "': "
+        << version.error();
+    }
+  }
+
   if (flags.master.isNone() && flags.master_detector.isNone()) {
     cerr << flags.usage("Missing required option `--master` or "
                         "`--master_detector`.") << endl;

Reply via email to