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 2016/10/06 01:28:06 UTC
[1/2] mesos git commit: Propagated work_dir flag from local runs to
agents/masters.
Repository: mesos
Updated Branches:
refs/heads/1.0.x 63c2ece2f -> 6773b8ffe
Propagated work_dir flag from local runs to agents/masters.
Review: https://reviews.apache.org/r/50003/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/e7a35ebe
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/e7a35ebe
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/e7a35ebe
Branch: refs/heads/1.0.x
Commit: e7a35ebe1c52aa3dc3d90feabae13c1f7220723f
Parents: 63c2ece
Author: Ammar Askar <am...@ammaraskar.com>
Authored: Wed Aug 10 17:57:09 2016 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Wed Oct 5 18:22:02 2016 -0700
----------------------------------------------------------------------
src/local/flags.hpp | 22 ++++++++++++++++++++++
src/local/local.cpp | 42 +++++++++++++-----------------------------
2 files changed, 35 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/e7a35ebe/src/local/flags.hpp
----------------------------------------------------------------------
diff --git a/src/local/flags.hpp b/src/local/flags.hpp
index f0af0d2..c77eff1 100644
--- a/src/local/flags.hpp
+++ b/src/local/flags.hpp
@@ -18,6 +18,8 @@
#define __LOCAL_FLAGS_HPP__
#include <stout/flags.hpp>
+#include <stout/os.hpp>
+#include <stout/path.hpp>
#include "logging/flags.hpp"
@@ -30,12 +32,32 @@ class Flags : public logging::Flags
public:
Flags()
{
+ // `work_dir` is passed from here to the agents/master.
+ // This is necessary because `work_dir` is a required flag
+ // in agents/master and without this, the load call for their
+ // flags will spit out an error unless they have an env
+ // variable for the `work_dir` explicitly set.
+ // Since local mode is used strictly for non-production
+ // purposes, it is the one case where we deem it acceptable
+ // to set a default value for `work_dir`.
+ add(&Flags::work_dir,
+ "work_dir",
+ "Path of the master/agent work directory. This is where the\n"
+ "persistent information of the cluster will be stored.\n"
+ "Note that locations like `/tmp` which are cleaned\n"
+ "automatically are not suitable for the work directory\n"
+ "when running in production, since long-running masters\n"
+ "and agents could lose data when cleanup occurs.\n"
+ "(Example: `/var/lib/mesos`)",
+ path::join(os::temp(), "mesos", "local"));
+
add(&Flags::num_slaves,
"num_slaves",
"Number of agents to launch for local cluster",
1);
}
+ std::string work_dir;
int num_slaves;
};
http://git-wip-us.apache.org/repos/asf/mesos/blob/e7a35ebe/src/local/local.cpp
----------------------------------------------------------------------
diff --git a/src/local/local.cpp b/src/local/local.cpp
index d6fe4d0..1e1d246 100644
--- a/src/local/local.cpp
+++ b/src/local/local.cpp
@@ -168,9 +168,20 @@ PID<Master> launch(const Flags& flags, Allocator* _allocator)
files = new Files();
+ // Attempt to create the `work_dir` as a convenience.
+ Try<Nothing> mkdir = os::mkdir(flags.work_dir);
+ if (mkdir.isError()) {
+ EXIT(EXIT_FAILURE)
+ << "Failed to create the work_dir for agents/master '"
+ << flags.work_dir << "': " << mkdir.error();
+ }
+
+ std::map<std::string, std::string> propagated_flags;
+ propagated_flags["work_dir"] = flags.work_dir;
+
{
master::Flags flags;
- Try<flags::Warnings> load = flags.load("MESOS_");
+ Try<flags::Warnings> load = flags.load(propagated_flags, false, "MESOS_");
if (load.isError()) {
EXIT(EXIT_FAILURE)
<< "Failed to start a local cluster while loading"
@@ -194,15 +205,6 @@ PID<Master> launch(const Flags& flags, Allocator* _allocator)
if (flags.registry == "in_memory") {
storage = new mesos::state::InMemoryStorage();
} else if (flags.registry == "replicated_log") {
- // For local runs, we use a temporary work directory.
- if (flags.work_dir.isNone()) {
- CHECK_SOME(os::mkdir("/tmp/mesos/local"));
-
- Try<string> directory = os::mkdtemp("/tmp/mesos/local/XXXXXX");
- CHECK_SOME(directory);
- flags.work_dir = directory.get();
- }
-
// TODO(vinod): Add support for replicated log with ZooKeeper.
log = new Log(
1,
@@ -339,25 +341,7 @@ PID<Master> launch(const Flags& flags, Allocator* _allocator)
for (int i = 0; i < flags.num_slaves; i++) {
slave::Flags flags;
- if (os::getenv("MESOS_WORK_DIR").isNone()) {
- const string workDir = "/tmp/mesos/local/agents";
- Try<Nothing> mkdir = os::mkdir(workDir);
- if (mkdir.isError()) {
- EXIT(EXIT_FAILURE)
- << "Failed to create the root work directory for local agents '"
- << workDir << "': " << mkdir.error();
- }
-
- flags.work_dir = path::join(workDir, stringify(i));
- Try<Nothing> directory = os::mkdir(flags.work_dir);
- if (directory.isError()) {
- EXIT(EXIT_FAILURE)
- << "Failed to create work directory for local agent '"
- << flags.work_dir << "': " << directory.error();
- }
- }
-
- Try<flags::Warnings> load = flags.load("MESOS_");
+ Try<flags::Warnings> load = flags.load(propagated_flags, false, "MESOS_");
if (load.isError()) {
EXIT(EXIT_FAILURE)
[2/2] mesos git commit: Added MESOS-5613 to 1.0.2 CHANGELOG.
Posted by vi...@apache.org.
Added MESOS-5613 to 1.0.2 CHANGELOG.
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/6773b8ff
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/6773b8ff
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/6773b8ff
Branch: refs/heads/1.0.x
Commit: 6773b8ffef6672ef012f8ccb6a9fe73d40e02ae0
Parents: e7a35eb
Author: Vinod Kone <vi...@gmail.com>
Authored: Wed Oct 5 18:24:57 2016 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Wed Oct 5 18:26:51 2016 -0700
----------------------------------------------------------------------
CHANGELOG | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/6773b8ff/CHANGELOG
----------------------------------------------------------------------
diff --git a/CHANGELOG b/CHANGELOG
index 8aa2ab1..9d5cea6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@ Release Notes - Mesos - Version 1.0.2
All Issues:
** Bug
+ * [MESOS-5613] - mesos-local fails to start if MESOS_WORK_DIR isn't set.
* [MESOS-6013] - Use readdir instead of readdir_r.
* [MESOS-6074] - Master check failure if the metrics endpoint is polled soon after it starts.
* [MESOS-6075] - Avoid libprocess functions in `mesos-containerizer launch`.