You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ha...@apache.org on 2017/01/26 04:09:11 UTC

[2/3] mesos git commit: Reorganized the work directory and the runtime directory in local mode.

Reorganized the work directory and the runtime directory in local mode.

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


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

Branch: refs/heads/master
Commit: f698910ced01061f257bbf994832b97a432da336
Parents: 368f8be
Author: haosdent huang <ha...@apache.org>
Authored: Thu Jan 26 11:27:54 2017 +0800
Committer: Haosdent Huang <ha...@apache.org>
Committed: Thu Jan 26 12:05:16 2017 +0800

----------------------------------------------------------------------
 bin/mesos-local-flags.sh.in |  6 ++---
 src/local/flags.hpp         | 12 ++++++++-
 src/local/local.cpp         | 58 +++++++++++++++++++++++++++++-----------
 3 files changed, 55 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/f698910c/bin/mesos-local-flags.sh.in
----------------------------------------------------------------------
diff --git a/bin/mesos-local-flags.sh.in b/bin/mesos-local-flags.sh.in
index 5b4553a..ab23944 100644
--- a/bin/mesos-local-flags.sh.in
+++ b/bin/mesos-local-flags.sh.in
@@ -7,16 +7,14 @@
 # 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.
 
-export MESOS_WORK_DIR=/tmp/mesos
-
 . @abs_top_builddir@/bin/mesos-master-flags.sh
 . @abs_top_builddir@/bin/mesos-agent-flags.sh

http://git-wip-us.apache.org/repos/asf/mesos/blob/f698910c/src/local/flags.hpp
----------------------------------------------------------------------
diff --git a/src/local/flags.hpp b/src/local/flags.hpp
index 3d8e539..0cef5ac 100644
--- a/src/local/flags.hpp
+++ b/src/local/flags.hpp
@@ -49,7 +49,16 @@ public:
         "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"));
+        path::join(os::temp(), "mesos", "work"));
+
+    add(&Flags::runtime_dir,
+        "runtime_dir",
+        "Path of the agent runtime directory. This is where runtime\n"
+        "data is stored by an agent that it needs to persist across\n"
+        "crashes (but not across reboots). This directory will be\n"
+        "cleared on reboot.\n"
+        "(Example: `/var/run/mesos`)",
+        path::join(os::temp(), "mesos", "runtime"));
 
     add(&Flags::num_slaves,
         "num_slaves",
@@ -58,6 +67,7 @@ public:
   }
 
   std::string work_dir;
+  std::string runtime_dir;
   int num_slaves;
 };
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/f698910c/src/local/local.cpp
----------------------------------------------------------------------
diff --git a/src/local/local.cpp b/src/local/local.cpp
index 61005c3..e479809 100644
--- a/src/local/local.cpp
+++ b/src/local/local.cpp
@@ -174,21 +174,13 @@ 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();
-  }
-
-  // Use to propagate necessary flags to master and agent. Without
-  // this, the load call will spit out an error unless their
-  // corresponding environment variables explicitly set.
-  map<string, string> propagatedFlags;
-  propagatedFlags["work_dir"] = flags.work_dir;
-
   {
+    // Use to propagate necessary flags to master. Without this, the
+    // load call will spit out an error unless their corresponding
+    // environment variables explicitly set.
+    map<string, string> propagatedFlags;
+    propagatedFlags["work_dir"] = path::join(flags.work_dir, "master");
+
     master::Flags masterFlags;
     Try<flags::Warnings> load = masterFlags.load(
         propagatedFlags,
@@ -206,6 +198,14 @@ PID<Master> launch(const Flags& flags, Allocator* _allocator)
       LOG(WARNING) << warning.message;
     }
 
+    // Attempt to create the `work_dir` for master as a convenience.
+    Try<Nothing> mkdir = os::mkdir(masterFlags.work_dir.get());
+    if (mkdir.isError()) {
+      EXIT(EXIT_FAILURE)
+        << "Failed to create the work_dir for master '"
+        << masterFlags.work_dir.get() << "': " << mkdir.error();
+    }
+
     // Load modules. Note that this covers both, master and slave
     // specific modules as both use the same flag (--modules).
     if (masterFlags.modules.isSome()) {
@@ -356,6 +356,19 @@ PID<Master> launch(const Flags& flags, Allocator* _allocator)
   vector<UPID> pids;
 
   for (int i = 0; i < flags.num_slaves; i++) {
+    // Use to propagate necessary flags to agent. Without this, the
+    // load call will spit out an error unless their corresponding
+    // environment variables explicitly set.
+    map<string, string> propagatedFlags;
+
+    // Use a different work directory for each agent.
+    propagatedFlags["work_dir"] =
+      path::join(flags.work_dir, "agents", stringify(i));
+
+    // Use a different runtime directory for each agent.
+    propagatedFlags["runtime_dir"] =
+      path::join(flags.runtime_dir, "agents", stringify(i));
+
     slave::Flags slaveFlags;
     Try<flags::Warnings> load = slaveFlags.load(
         propagatedFlags,
@@ -373,8 +386,21 @@ PID<Master> launch(const Flags& flags, Allocator* _allocator)
       LOG(WARNING) << warning.message;
     }
 
-    // Use a different work directory for each slave.
-    slaveFlags.work_dir = path::join(slaveFlags.work_dir, stringify(i));
+    // Attempt to create the `work_dir` for agent as a convenience.
+    Try<Nothing> mkdir = os::mkdir(slaveFlags.work_dir);
+    if (mkdir.isError()) {
+      EXIT(EXIT_FAILURE)
+        << "Failed to create the work_dir for agent '"
+        << slaveFlags.work_dir << "': " << mkdir.error();
+    }
+
+    // Attempt to create the `runtime_dir` for agent as a convenience.
+    mkdir = os::mkdir(slaveFlags.runtime_dir);
+    if (mkdir.isError()) {
+      EXIT(EXIT_FAILURE)
+        << "Failed to create the runtime_dir for agent '"
+        << slaveFlags.runtime_dir << "': " << mkdir.error();
+    }
 
     garbageCollectors->push_back(new GarbageCollector());
     statusUpdateManagers->push_back(new StatusUpdateManager(slaveFlags));