Repository: mesos Updated Branches: refs/heads/1.5.x 8186e9b7b -> af64bcb38
Windows: Fixed docker executor `PATH` variable. The `docker` executable is not usually installed in `os::host_default_path()` on Windows, so the Executor cannot find it. Now, before launching the Executor, the Agent finds the directory containing `docker` and prepends it to the `PATH` given to the Executor so that both the Executor and Agent use the same `docker`. Review: https://reviews.apache.org/r/65147 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/af64bcb3 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/af64bcb3 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/af64bcb3 Branch: refs/heads/1.5.x Commit: af64bcb38754705020b4e35efccf94e9c85198d6 Parents: 0086ae1 Author: Akash Gupta <[email protected]> Authored: Fri Jan 12 16:23:39 2018 -0800 Committer: Andrew Schwartzmeyer <[email protected]> Committed: Tue Jan 16 13:38:02 2018 -0800 ---------------------------------------------------------------------- src/slave/containerizer/docker.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/af64bcb3/src/slave/containerizer/docker.cpp ---------------------------------------------------------------------- diff --git a/src/slave/containerizer/docker.cpp b/src/slave/containerizer/docker.cpp index b42fe1f..6d9c598 100644 --- a/src/slave/containerizer/docker.cpp +++ b/src/slave/containerizer/docker.cpp @@ -43,6 +43,7 @@ #include <stout/uuid.hpp> #include <stout/os/killtree.hpp> +#include <stout/os/which.hpp> #include "common/status_utils.hpp" @@ -1465,6 +1466,24 @@ Future<pid_t> DockerContainerizerProcess::launchExecutorProcess( if (environment.count("PATH") == 0) { environment["PATH"] = os::host_default_path(); + + // TODO(andschwa): We will consider removing the `#ifdef` in future, as + // other platforms may benefit from being pointed to the same `docker` in + // both Agent and Executor (there is a chance that the cleaned path results + // in using a different docker, if multiple dockers are installed). +#ifdef __WINDOWS__ + // Docker is generally not installed in `os::host_default_path()` on + // Windows, so the executor will not be able to find `docker`. We search for + // `docker` in `PATH` and prepend the parent directory to + // `environment["PATH"]`. We prepend instead of append so that in the off + // chance that `docker` is in `host_default_path`, the executor and agent + // will use the same `docker`. + Option<string> dockerPath = os::which("docker"); + if (dockerPath.isSome()) { + environment["PATH"] = + Path(dockerPath.get()).dirname() + ";" + environment["PATH"]; + } +#endif // __WINDOWS__ } vector<string> argv;
