| 346 | } |
| 347 | |
| 348 | void taskHealthUpdated(const TaskHealthStatus& healthStatus) |
| 349 | { |
| 350 | CHECK_SOME(taskId); |
| 351 | CHECK_EQ(taskId.get(), healthStatus.task_id()); |
| 352 | |
| 353 | // This prevents us from sending health updates after a terminal |
| 354 | // status update, because we may receive an update from a health |
| 355 | // check scheduled before the task has been reaped. |
| 356 | // |
| 357 | // TODO(alexr): Consider sending health updates after TASK_KILLING. |
| 358 | if (killed || terminated) { |
| 359 | return; |
| 360 | } |
| 361 | |
| 362 | LOG(INFO) << "Received task health update, healthy: " |
| 363 | << stringify(healthStatus.healthy()); |
| 364 | |
| 365 | // Use the previous task status to preserve all attached information. |
| 366 | CHECK_SOME(lastTaskStatus); |
| 367 | TaskStatus status = protobuf::createTaskStatus( |
| 368 | lastTaskStatus.get(), |
| 369 | id::UUID::random(), |
| 370 | Clock::now().secs(), |
| 371 | None(), |
| 372 | None(), |
| 373 | None(), |
| 374 | TaskStatus::REASON_TASK_HEALTH_CHECK_STATUS_UPDATED, |
| 375 | None(), |
| 376 | healthStatus.healthy()); |
| 377 | |
| 378 | forward(status); |
| 379 | |
| 380 | if (healthStatus.kill_task()) { |
| 381 | killedByHealthCheck = true; |
| 382 | kill(healthStatus.task_id()); |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | void doReliableRegistration() |
| 387 | { |