hydra-queue-runner: do not assume reservation is available when build step throws unexpectedly

`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 <raito@lix.systems>
This commit is contained in:
raito 2024-07-09 03:11:53 +02:00
parent a9a2679793
commit 1f9d8dc0a6

View file

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