From a8a5dea41110c962fbd78c9fbc2d131aa7f6a70e Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Mon, 8 Jul 2024 17:02:47 +0200 Subject: [PATCH] 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 --- src/hydra-queue-runner/builder.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/hydra-queue-runner/builder.cc b/src/hydra-queue-runner/builder.cc index eecf43c4..42ebfa66 100644 --- a/src/hydra-queue-runner/builder.cc +++ b/src/hydra-queue-runner/builder.cc @@ -28,6 +28,7 @@ void State::builder(MachineReservation::ptr reservation) { auto activeStep = std::make_shared(); + 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()); } }