You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2015/10/08 21:40:11 UTC
mesos git commit: Introduced a /version endpoint.
Repository: mesos
Updated Branches:
refs/heads/master 263316916 -> 0981bb004
Introduced a /version endpoint.
Review: https://reviews.apache.org/r/37024
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/0981bb00
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/0981bb00
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/0981bb00
Branch: refs/heads/master
Commit: 0981bb004f89bbb4b04c2895a24511ae41ec67a0
Parents: 2633169
Author: haosdent huang <ha...@gmail.com>
Authored: Thu Oct 8 12:38:05 2015 -0700
Committer: Benjamin Mahler <be...@gmail.com>
Committed: Thu Oct 8 12:39:59 2015 -0700
----------------------------------------------------------------------
src/Makefile.am | 2 +
src/exec/exec.cpp | 4 ++
src/local/main.cpp | 4 ++
src/master/main.cpp | 3 ++
src/sched/sched.cpp | 4 ++
src/slave/main.cpp | 4 ++
src/version/version.cpp | 106 +++++++++++++++++++++++++++++++++++++++++++
src/version/version.hpp | 47 +++++++++++++++++++
8 files changed, 174 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/0981bb00/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index e698927..d855cb8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -551,6 +551,7 @@ libmesos_no_3rdparty_la_SOURCES = \
v1/mesos.cpp \
v1/resources.cpp \
v1/values.cpp \
+ version/version.cpp \
watcher/whitelist_watcher.cpp \
zookeeper/contender.cpp \
zookeeper/detector.cpp \
@@ -882,6 +883,7 @@ libmesos_no_3rdparty_la_SOURCES += \
tests/containerizer/rootfs.hpp \
tests/containerizer/setns_test_helper.hpp \
usage/usage.hpp \
+ version/version.hpp \
watcher/whitelist_watcher.hpp \
zookeeper/authentication.hpp \
zookeeper/contender.hpp \
http://git-wip-us.apache.org/repos/asf/mesos/blob/0981bb00/src/exec/exec.cpp
----------------------------------------------------------------------
diff --git a/src/exec/exec.cpp b/src/exec/exec.cpp
index 7b51baa..c99dc07 100644
--- a/src/exec/exec.cpp
+++ b/src/exec/exec.cpp
@@ -57,6 +57,8 @@
#include "slave/constants.hpp"
#include "slave/state.hpp"
+#include "version/version.hpp"
+
using namespace mesos;
using namespace mesos::internal;
using namespace mesos::internal::slave;
@@ -597,6 +599,8 @@ MesosExecutorDriver::MesosExecutorDriver(Executor* _executor)
} else {
VLOG(1) << "Disabling initialization of GLOG logging";
}
+
+ spawn(new VersionProcess(), true);
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/0981bb00/src/local/main.cpp
----------------------------------------------------------------------
diff --git a/src/local/main.cpp b/src/local/main.cpp
index 18b2f01..daa3e31 100644
--- a/src/local/main.cpp
+++ b/src/local/main.cpp
@@ -34,6 +34,8 @@
#include "logging/logging.hpp"
+#include "version/version.hpp"
+
using namespace mesos::internal;
using mesos::internal::master::Master;
@@ -93,6 +95,8 @@ int main(int argc, char **argv)
logging::initialize(argv[0], flags);
+ spawn(new VersionProcess(), true);
+
process::wait(local::launch(flags));
return EXIT_SUCCESS;
http://git-wip-us.apache.org/repos/asf/mesos/blob/0981bb00/src/master/main.cpp
----------------------------------------------------------------------
diff --git a/src/master/main.cpp b/src/master/main.cpp
index bafc605..dd8f355 100644
--- a/src/master/main.cpp
+++ b/src/master/main.cpp
@@ -72,6 +72,7 @@
#include "state/protobuf.hpp"
#include "state/storage.hpp"
+#include "version/version.hpp"
#include "zookeeper/detector.hpp"
@@ -226,6 +227,8 @@ int main(int argc, char** argv)
logging::initialize(argv[0], flags, true); // Catch signals.
+ spawn(new VersionProcess(), true);
+
LOG(INFO) << "Build: " << build::DATE << " by " << build::USER;
LOG(INFO) << "Version: " << MESOS_VERSION;
http://git-wip-us.apache.org/repos/asf/mesos/blob/0981bb00/src/sched/sched.cpp
----------------------------------------------------------------------
diff --git a/src/sched/sched.cpp b/src/sched/sched.cpp
index 571e00d..724d7c0 100644
--- a/src/sched/sched.cpp
+++ b/src/sched/sched.cpp
@@ -89,6 +89,8 @@
#include "sched/constants.hpp"
#include "sched/flags.hpp"
+#include "version/version.hpp"
+
using namespace mesos;
using namespace mesos::internal;
using namespace mesos::internal::master;
@@ -1523,6 +1525,8 @@ void MesosSchedulerDriver::initialize() {
VLOG(1) << "Disabling initialization of GLOG logging";
}
+ spawn(new VersionProcess(), true);
+
// Initialize Latch.
latch = new Latch();
http://git-wip-us.apache.org/repos/asf/mesos/blob/0981bb00/src/slave/main.cpp
----------------------------------------------------------------------
diff --git a/src/slave/main.cpp b/src/slave/main.cpp
index 854ade4..746eec6 100644
--- a/src/slave/main.cpp
+++ b/src/slave/main.cpp
@@ -54,6 +54,8 @@
#include "slave/slave.hpp"
#include "slave/status_update_manager.hpp"
+#include "version/version.hpp"
+
using namespace mesos::internal;
using namespace mesos::internal::slave;
@@ -183,6 +185,8 @@ int main(int argc, char** argv)
logging::initialize(argv[0], flags, true); // Catch signals.
+ spawn(new VersionProcess(), true);
+
LOG(INFO) << "Build: " << build::DATE << " by " << build::USER;
LOG(INFO) << "Version: " << MESOS_VERSION;
http://git-wip-us.apache.org/repos/asf/mesos/blob/0981bb00/src/version/version.cpp
----------------------------------------------------------------------
diff --git a/src/version/version.cpp b/src/version/version.cpp
new file mode 100644
index 0000000..3e852b2
--- /dev/null
+++ b/src/version/version.cpp
@@ -0,0 +1,106 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string>
+
+#include <mesos/mesos.hpp>
+
+#include <process/help.hpp>
+#include <process/http.hpp>
+
+#include <stout/json.hpp>
+
+#include "common/build.hpp"
+
+#include "version/version.hpp"
+
+using namespace process;
+
+using process::DESCRIPTION;
+using process::HELP;
+using process::TLDR;
+
+using process::http::OK;
+
+using std::string;
+
+namespace mesos {
+namespace internal {
+
+static const string VERSION_HELP()
+{
+ // TODO(haosdent): generate the example in description automatically after we
+ // have json pretty printing.
+ return HELP(
+ TLDR(
+ "Provides version information."),
+ DESCRIPTION(
+ "Example:",
+ "",
+ "```",
+ "{",
+ " \"version\":\"0.26.0\",",
+ " \"build_user\":\"username\",",
+ " \"build_time\":1443894750,",
+ " \"build_date\":\"2015-10-04 01:52:30\"",
+ " \"git_branch\":\"branch\", // Optional",
+ " \"git_tag\":\"0.26.0-rc1\", // Optional",
+ " \"git_sha\":\"d31f096a4665650ad4b9eda372ac41d2c472a77c\","
+ " // Optional",
+ "}",
+ "```"));
+}
+
+
+VersionProcess::VersionProcess()
+ : ProcessBase("version")
+{}
+
+
+void VersionProcess::initialize()
+{
+ route("/", VERSION_HELP(), &VersionProcess::version);
+}
+
+
+Future<http::Response> VersionProcess::version(const http::Request& request)
+{
+ JSON::Object object;
+ object.values["version"] = MESOS_VERSION;
+
+ if (build::GIT_SHA.isSome()) {
+ object.values["git_sha"] = build::GIT_SHA.get();
+ }
+
+ if (build::GIT_BRANCH.isSome()) {
+ object.values["git_branch"] = build::GIT_BRANCH.get();
+ }
+
+ if (build::GIT_TAG.isSome()) {
+ object.values["git_tag"] = build::GIT_TAG.get();
+ }
+
+ object.values["build_date"] = build::DATE;
+ object.values["build_time"] = build::TIME;
+ object.values["build_user"] = build::USER;
+
+ return OK(object, request.url.query.get("jsonp"));
+}
+
+} // namespace internal {
+} // namespace mesos {
http://git-wip-us.apache.org/repos/asf/mesos/blob/0981bb00/src/version/version.hpp
----------------------------------------------------------------------
diff --git a/src/version/version.hpp b/src/version/version.hpp
new file mode 100644
index 0000000..9863cee
--- /dev/null
+++ b/src/version/version.hpp
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __VERSION_HPP__
+#define __VERSION_HPP__
+
+#include <string>
+
+#include <process/future.hpp>
+#include <process/http.hpp>
+#include <process/process.hpp>
+
+namespace mesos {
+namespace internal {
+
+class VersionProcess : public process::Process<VersionProcess>
+{
+public:
+ VersionProcess();
+
+protected:
+ virtual void initialize();
+
+private:
+ static process::Future<process::http::Response> version(
+ const process::http::Request& request);
+};
+
+} // namespace internal {
+} // namespace mesos {
+
+#endif // __VERSION_HPP__