aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-09-04 01:17:38 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-09-04 01:17:38 +0000
commitaad4abcc9c27d5c1a2349e40f51f076387e0f844 (patch)
tree6feff2254239cc48c9b75c52dc6741479516cd65 /src/libstore
parent4409530fc948a038688c5f0505be2efd5af2b0df (diff)
Fix floating CA tests
We will sometimes try to query the outputs of derivations we can't resolve. That's fine; it just means we don't know what those outputs are yet.
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/build.cc4
-rw-r--r--src/libstore/derivations.cc4
-rw-r--r--src/libstore/derivations.hh2
-rw-r--r--src/libstore/local-store.cc9
4 files changed, 13 insertions, 6 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 1249668c4..1f77b8ea8 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -1460,7 +1460,9 @@ void DerivationGoal::inputsRealised()
/* We are be able to resolve this derivation based on the
now-known results of dependencies. If so, we become a stub goal
aliasing that resolved derivation goal */
- Derivation drvResolved { fullDrv.resolve(worker.store) };
+ std::optional attempt = fullDrv.tryResolve(worker.store);
+ assert(attempt);
+ Derivation drvResolved { *std::move(attempt) };
auto pathResolved = writeDerivation(worker.store, drvResolved);
/* Add to memotable to speed up downstream goal's queries with the
diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc
index ce57a5bb0..695265860 100644
--- a/src/libstore/derivations.cc
+++ b/src/libstore/derivations.cc
@@ -671,7 +671,7 @@ static void rewriteDerivation(Store & store, BasicDerivation & drv, const String
Sync<DrvPathResolutions> drvPathResolutions;
-BasicDerivation Derivation::resolve(Store & store) {
+std::optional<BasicDerivation> Derivation::tryResolve(Store & store) {
BasicDerivation resolved { *this };
// Input paths that we'll want to rewrite in the derivation
@@ -683,7 +683,7 @@ BasicDerivation Derivation::resolve(Store & store) {
for (auto & outputName : input.second) {
auto actualPathOpt = inputDrvOutputs.at(outputName);
if (!actualPathOpt)
- throw Error("input drv '%s' wasn't yet built", store.printStorePath(input.first));
+ return std::nullopt;
auto actualPath = *actualPathOpt;
inputRewrites.emplace(
downstreamPlaceholder(store, input.first, outputName),
diff --git a/src/libstore/derivations.hh b/src/libstore/derivations.hh
index e4d85aa05..eaffbf452 100644
--- a/src/libstore/derivations.hh
+++ b/src/libstore/derivations.hh
@@ -133,7 +133,7 @@ struct Derivation : BasicDerivation
1. input drv outputs moved to input sources.
2. placeholders replaced with realized input store paths. */
- BasicDerivation resolve(Store & store);
+ std::optional<BasicDerivation> tryResolve(Store & store);
Derivation() = default;
Derivation(BasicDerivation && bd) : BasicDerivation(std::move(bd)) { }
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index e51d127b3..f490188ce 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -825,8 +825,13 @@ std::map<std::string, std::optional<StorePath>> LocalStore::queryPartialDerivati
/* can't just use else-if instead of `!haveCached` because we need to unlock
`drvPathResolutions` before it is locked in `Derivation::resolve`. */
if (!haveCached && drv.type() == DerivationType::CAFloating) {
- /* Resolve drv and use that path instead. */
- auto pathResolved = writeDerivation(*this, drv.resolve(*this));
+ /* Try resolve drv and use that path instead. */
+ auto attempt = drv.tryResolve(*this);
+ if (!attempt)
+ /* If we cannot resolve the derivation, we cannot have any path
+ assigned so we return the map of all std::nullopts. */
+ return outputs;
+ auto pathResolved = writeDerivation(*this, *std::move(attempt));
/* Store in memo table. */
/* FIXME: memo logic should not be local-store specific, should have
wrapper-method instead. */