hydra-queue-runner: do not assume reservation is available when build step throws unexpectedly
Some checks failed
Test / tests (pull_request) Has been cancelled

`reservation` might be null when an uncaught exception has been thrown.
We copy the data we need to report the error.

Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
This commit is contained in:
raito 2024-07-08 17:02:47 +02:00
parent a9a2679793
commit a8a5dea411

View file

@ -28,6 +28,7 @@ void State::builder(MachineReservation::ptr reservation)
{
auto activeStep = std::make_shared<ActiveStep>();
auto machineSshName = reservation->machine->sshName;
activeStep->step = reservation->step;
activeSteps_.lock()->insert(activeStep);
@ -39,9 +40,12 @@ void State::builder(MachineReservation::ptr reservation)
auto destStore = getDestStore();
res = doBuildStep(destStore, reservation, activeStep);
} catch (std::exception & e) {
if (!reservation) {
printMsg(lvlError, "machine '%s' has been released unexpectedly", machineSshName);
}
printMsg(lvlError, "uncaught exception building %s on %s: %s",
localStore->printStorePath(reservation->step->drvPath),
reservation->machine->sshName,
localStore->printStorePath(activeStep->step->drvPath),
machineSshName,
e.what());
}
}