You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by nn...@apache.org on 2014/05/14 02:26:52 UTC
git commit: Added support for passing flags in override command.
Repository: mesos
Updated Branches:
refs/heads/master c75e76c66 -> d903d2965
Added support for passing flags in override command.
Calling the mesos executor with "./mesos-executor --override ./foo
--bar" would cause the executor flags parsing to fail as it would
continue evaluating arguments as potential flags candidates. r21388
and r21384 adds the option to use a "--" terminator, which will cause
the mesos flag parsing to stop and modify argv to contain the
remaining arguments.
Review: https://reviews.apache.org/r/21408
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d903d296
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d903d296
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d903d296
Branch: refs/heads/master
Commit: d903d2965c14700af426df60567b23abc258e1bd
Parents: c75e76c
Author: Niklas Q. Nielsen <ni...@mesosphere.io>
Authored: Tue May 13 16:35:19 2014 -0700
Committer: Niklas Q. Nielsen <ni...@mesosphere.io>
Committed: Tue May 13 16:35:45 2014 -0700
----------------------------------------------------------------------
src/launcher/executor.cpp | 14 ++++++++------
src/tests/slave_tests.cpp | 2 +-
2 files changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/d903d296/src/launcher/executor.cpp
----------------------------------------------------------------------
diff --git a/src/launcher/executor.cpp b/src/launcher/executor.cpp
index f1ec656..3d55d93 100644
--- a/src/launcher/executor.cpp
+++ b/src/launcher/executor.cpp
@@ -480,7 +480,7 @@ int main(int argc, char** argv)
false);
// Load flags from environment and command line.
- Try<Nothing> load = flags.load(None(), argc, argv);
+ Try<Nothing> load = flags.load(None(), &argc, &argv);
if (load.isError()) {
cerr << load.error() << endl;
@@ -493,13 +493,15 @@ int main(int argc, char** argv)
return -1;
}
+ // After flags.load(..., &argc, &argv) all flags will have been
+ // stripped from argv. Additionally, arguments after a "--"
+ // terminator will be preservered in argv and it is therefore
+ // possible to pass override and prefix commands which use
+ // "--foobar" style flags.
Option<char**> override = None();
if (flags.override) {
- // TODO(nnielsen): We assume that when you run "--override" that
- // there won't be other flags or arguments. In the future, we
- // should be able to use MESOS-1345.
- if (argc > 2) {
- override = argv + 2;
+ if (argc > 1) {
+ override = argv + 1;
}
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/d903d296/src/tests/slave_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/slave_tests.cpp b/src/tests/slave_tests.cpp
index eca276b..dfbc648 100644
--- a/src/tests/slave_tests.cpp
+++ b/src/tests/slave_tests.cpp
@@ -335,7 +335,7 @@ TEST_F(SlaveTest, MesosExecutorWithOverride)
string executorCommand =
path::join(tests::flags.build_dir, "src", "mesos-executor") +
- " --override /bin/sh -c 'echo hello world >" + file.get() + "'";
+ " --override -- /bin/sh -c 'echo hello world >" + file.get() + "'";
// Expect two status updates, one for once the mesos-executor says
// the task is running and one for after our overridden command