| 1450 | |
| 1451 | |
| 1452 | Future<pid_t> DockerContainerizerProcess::launchExecutorProcess( |
| 1453 | const ContainerID& containerId) |
| 1454 | { |
| 1455 | if (!containers_.contains(containerId)) { |
| 1456 | return Failure("Container is already destroyed"); |
| 1457 | } |
| 1458 | |
| 1459 | if (containers_[containerId]->state == Container::DESTROYING) { |
| 1460 | return Failure( |
| 1461 | "Container is being destroyed during launching executor process"); |
| 1462 | } |
| 1463 | |
| 1464 | Container* container = containers_.at(containerId); |
| 1465 | container->state = Container::RUNNING; |
| 1466 | |
| 1467 | // Prepare environment variables for the executor. |
| 1468 | map<string, string> environment = container->environment; |
| 1469 | |
| 1470 | // Include any environment variables from ExecutorInfo. |
| 1471 | foreach (const Environment::Variable& variable, |
| 1472 | container->containerConfig.executor_info() |
| 1473 | .command().environment().variables()) { |
| 1474 | const string& name = variable.name(); |
| 1475 | const string& value = variable.value(); |
| 1476 | |
| 1477 | if (environment.count(name)) { |
| 1478 | VLOG(1) << "Overwriting environment variable '" |
| 1479 | << name << "', original: '" |
| 1480 | << environment[name] << "', new: '" |
| 1481 | << value << "', for container " |
| 1482 | << container->id; |
| 1483 | } |
| 1484 | |
| 1485 | environment[name] = value; |
| 1486 | } |
| 1487 | |
| 1488 | // Pass GLOG flag to the executor. |
| 1489 | const Option<string> glog = os::getenv("GLOG_v"); |
| 1490 | if (glog.isSome()) { |
| 1491 | environment["GLOG_v"] = glog.get(); |
| 1492 | } |
| 1493 | |
| 1494 | if (environment.count("PATH") == 0) { |
| 1495 | environment["PATH"] = os::host_default_path(); |
| 1496 | |
| 1497 | // TODO(andschwa): We will consider removing the `#ifdef` in future, as |
| 1498 | // other platforms may benefit from being pointed to the same `docker` in |
| 1499 | // both Agent and Executor (there is a chance that the cleaned path results |
| 1500 | // in using a different docker, if multiple dockers are installed). |
| 1501 | #ifdef __WINDOWS__ |
| 1502 | // Docker is generally not installed in `os::host_default_path()` on |
| 1503 | // Windows, so the executor will not be able to find `docker`. We search for |
| 1504 | // `docker` in `PATH` and prepend the parent directory to |
| 1505 | // `environment["PATH"]`. We prepend instead of append so that in the off |
| 1506 | // chance that `docker` is in `host_default_path`, the executor and agent |
| 1507 | // will use the same `docker`. |
| 1508 | Option<string> dockerPath = os::which("docker"); |
| 1509 | if (dockerPath.isSome()) { |
nothing calls this directly
no test coverage detected