From 1f9d8dc0a6d8e023f3f7c28afe2aa687caa5400d Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Tue, 9 Jul 2024 03:11:53 +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 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/hydra-queue-runner/builder.cc b/src/hydra-queue-runner/builder.cc index eecf43c4..b3ca12c9 100644 --- a/src/hydra-queue-runner/builder.cc +++ b/src/hydra-queue-runner/builder.cc @@ -28,6 +28,9 @@ void State::builder(MachineReservation::ptr reservation) { auto activeStep = std::make_shared(); + auto machineSshName = reservation->machine->sshName; + auto drvPath = reservation->step->drvPath; + activeStep->step = reservation->step; activeSteps_.lock()->insert(activeStep); @@ -39,9 +42,12 @@ void State::builder(MachineReservation::ptr reservation) auto destStore = getDestStore(); res = doBuildStep(destStore, reservation, activeStep); } 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", - localStore->printStorePath(reservation->step->drvPath), - reservation->machine->sshName, + localStore->printStorePath(drvPath), + machineSshName, e.what()); } } -- 2.44.1