hydra-queue-runner: Write GC roots for outputs paths

We lost this behaviour somewhere. So build outputs could be GC'ed when
running the collector with --option gc-keep-outputs false.
This commit is contained in:
Eelco Dolstra 2017-10-12 18:55:38 +02:00
parent eb7631fb9d
commit 45b138373b
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
4 changed files with 12 additions and 0 deletions

View file

@ -263,6 +263,9 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore,
assert(stepNr);
for (auto & path : step->drv.outputPaths())
writeFile(rootsDir + "/" + baseNameOf(path), "");
/* Register success in the database for all Build objects that
have this step as the top-level step. Since the queue
monitor thread may be creating new referring Builds

View file

@ -87,6 +87,7 @@ State::State()
, maxOutputSize(config->getIntOption("max_output_size", 2ULL << 30))
, maxLogSize(config->getIntOption("max_log_size", 64ULL << 20))
, uploadLogsToBinaryCache(config->getBoolOption("upload_logs_to_binary_cache", false))
, rootsDir(config->getStrOption("gc_roots_dir", fmt("%s/gcroots/per-user/%s/hydra-roots", settings.nixStateDir, getEnv("USER"))))
{
debug("using %d bytes for the NAR buffer", memoryTokens.capacity());

View file

@ -221,6 +221,9 @@ bool State::getQueuedBuilds(Connection & conn,
Derivation drv = readDerivation(build->drvPath);
BuildOutput res = getBuildOutputCached(conn, destStore, drv);
for (auto & path : drv.outputPaths())
writeFile(rootsDir + "/" + baseNameOf(path), "");
{
auto mc = startDbUpdate();
pqxx::work txn(conn);

View file

@ -436,6 +436,11 @@ private:
bool uploadLogsToBinaryCache;
/* Where to store GC roots. Defaults to
/nix/var/nix/gcroots/per-user/$USER/hydra-roots, overridable
via gc_roots_dir. */
nix::Path rootsDir;
public:
State();