From b04dc6c76e2e78b2f7ac4fb2a4f0881933e27bd0 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 19 Oct 2017 12:28:06 +0200 Subject: [PATCH] Fix root creation when the root already exists but is owned by another user --- src/hydra-queue-runner/builder.cc | 9 ++++++++- src/hydra-queue-runner/hydra-queue-runner.cc | 2 ++ src/hydra-queue-runner/queue-monitor.cc | 2 +- src/hydra-queue-runner/state.hh | 2 ++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/hydra-queue-runner/builder.cc b/src/hydra-queue-runner/builder.cc index 8a636b17..ceaa252e 100644 --- a/src/hydra-queue-runner/builder.cc +++ b/src/hydra-queue-runner/builder.cc @@ -264,7 +264,7 @@ State::StepResult State::doBuildStep(nix::ref destStore, assert(stepNr); for (auto & path : step->drv.outputPaths()) - writeFile(rootsDir + "/" + baseNameOf(path), ""); + addRoot(path); /* Register success in the database for all Build objects that have this step as the top-level step. Since the queue @@ -473,3 +473,10 @@ State::StepResult State::doBuildStep(nix::ref destStore, return sDone; } + + +void State::addRoot(const Path & storePath) +{ + auto root = rootsDir + "/" + baseNameOf(storePath); + if (!pathExists(root)) writeFile(root, ""); +} diff --git a/src/hydra-queue-runner/hydra-queue-runner.cc b/src/hydra-queue-runner/hydra-queue-runner.cc index f0bb338e..283ca96b 100644 --- a/src/hydra-queue-runner/hydra-queue-runner.cc +++ b/src/hydra-queue-runner/hydra-queue-runner.cc @@ -841,6 +841,8 @@ void State::run(BuildID buildOne) jobsetRepeats.emplace(std::make_pair(s2[0], s2[1]), std::stoi(s2[2])); } + addRoot("/nix/store/rk9lahzm21qm0zjclv6mz0m4hy77wk14-vm-test-run-unnamed.drv"); + { auto conn(dbPool.get()); clearBusy(*conn, 0); diff --git a/src/hydra-queue-runner/queue-monitor.cc b/src/hydra-queue-runner/queue-monitor.cc index 85d8f626..862925b2 100644 --- a/src/hydra-queue-runner/queue-monitor.cc +++ b/src/hydra-queue-runner/queue-monitor.cc @@ -222,7 +222,7 @@ bool State::getQueuedBuilds(Connection & conn, BuildOutput res = getBuildOutputCached(conn, destStore, drv); for (auto & path : drv.outputPaths()) - writeFile(rootsDir + "/" + baseNameOf(path), ""); + addRoot(path); { auto mc = startDbUpdate(); diff --git a/src/hydra-queue-runner/state.hh b/src/hydra-queue-runner/state.hh index f5ba641e..543a36e3 100644 --- a/src/hydra-queue-runner/state.hh +++ b/src/hydra-queue-runner/state.hh @@ -535,6 +535,8 @@ private: void dumpStatus(Connection & conn, bool log); + void addRoot(const nix::Path & storePath); + public: void showStatus();