| 1242 | } |
| 1243 | |
| 1244 | Future<bool> CheckerProcess::_tcpCheck( |
| 1245 | const vector<string>& cmdArgv, |
| 1246 | const Option<runtime::Plain>& plain) |
| 1247 | { |
| 1248 | VLOG(1) << "Launching " << name << " for task '" << taskId << "'" |
| 1249 | << " with command '" << strings::join(" ", cmdArgv) << "'"; |
| 1250 | |
| 1251 | // TODO(alexr): Consider launching the helper binary once per task lifetime, |
| 1252 | // see MESOS-6766. |
| 1253 | Try<Subprocess> s = subprocess( |
| 1254 | cmdArgv[0], |
| 1255 | cmdArgv, |
| 1256 | Subprocess::PATH(os::DEV_NULL), |
| 1257 | Subprocess::PIPE(), |
| 1258 | Subprocess::PIPE(), |
| 1259 | nullptr, |
| 1260 | None(), |
| 1261 | getCustomCloneFunc(plain)); |
| 1262 | |
| 1263 | if (s.isError()) { |
| 1264 | return Failure( |
| 1265 | "Failed to create the " + cmdArgv[0] + " subprocess: " + s.error()); |
| 1266 | } |
| 1267 | |
| 1268 | // TODO(alexr): Use lambda named captures for |
| 1269 | // these cached values once they are available. |
| 1270 | pid_t commandPid = s->pid(); |
| 1271 | const string _name = name; |
| 1272 | const Duration timeout = checkTimeout; |
| 1273 | const TaskID _taskId = taskId; |
| 1274 | |
| 1275 | return await( |
| 1276 | s->status(), |
| 1277 | process::io::read(s->out().get()), |
| 1278 | process::io::read(s->err().get())) |
| 1279 | .after( |
| 1280 | timeout, [timeout, commandPid, _name, _taskId]( |
| 1281 | Future<tuple<Future<Option<int>>, |
| 1282 | Future<string>, |
| 1283 | Future<string>>> future) |
| 1284 | { |
| 1285 | future.discard(); |
| 1286 | |
| 1287 | if (commandPid != -1) { |
| 1288 | // Cleanup the TCP_CHECK_COMMAND process. |
| 1289 | VLOG(1) << "Killing the " << _name << " process " << commandPid |
| 1290 | << " for task '" << _taskId << "'"; |
| 1291 | |
| 1292 | os::killtree(commandPid, SIGKILL); |
| 1293 | } |
| 1294 | |
| 1295 | return Failure( |
| 1296 | string(TCP_CHECK_COMMAND) + " timed out after " + stringify(timeout)); |
| 1297 | }) |
| 1298 | .then(defer(self(), &Self::__tcpCheck, lambda::_1)); |
| 1299 | } |
| 1300 | |
| 1301 |
nothing calls this directly
no test coverage detected