From ea1eb2e3fbf337ce64deb212c98bfc6aceee0ffc Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 17 Aug 2015 14:37:57 +0200 Subject: [PATCH] Keep track of requiredSystemFeatures in the machine stats For example, steps that require the "kvm" feature may require a different kind of machine to be provisioned. This can also be used to require performance-sensitive tests to run on a particular kind of machine, e.g., by setting requiredSystemFeatures to something like "ec2-i2.8xlarge". --- src/hydra-queue-runner/dispatcher.cc | 10 +++++----- src/hydra-queue-runner/queue-monitor.cc | 6 +++++- src/hydra-queue-runner/state.hh | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/hydra-queue-runner/dispatcher.cc b/src/hydra-queue-runner/dispatcher.cc index ecc68116..d6a02d4a 100644 --- a/src/hydra-queue-runner/dispatcher.cc +++ b/src/hydra-queue-runner/dispatcher.cc @@ -158,7 +158,7 @@ system_time State::doDispatch() ++i; - runnablePerType[step->drv.platform]++; + runnablePerType[step->systemType]++; /* Skip previously failed steps that aren't ready to be retried. */ @@ -219,8 +219,8 @@ system_time State::doDispatch() break; } else ++i; assert(removed); - assert(runnablePerType[step->drv.platform]); - runnablePerType[step->drv.platform]--; + assert(runnablePerType[step->systemType]); + runnablePerType[step->systemType]--; } /* Make a slot reservation and start a thread to @@ -291,7 +291,7 @@ State::MachineReservation::MachineReservation(State & state, Step::ptr step, Mac { auto machineTypes_(state.machineTypes.lock()); - (*machineTypes_)[step->drv.platform].running++; + (*machineTypes_)[step->systemType].running++; } } @@ -305,7 +305,7 @@ State::MachineReservation::~MachineReservation() { auto machineTypes_(state.machineTypes.lock()); - auto & machineType = (*machineTypes_)[step->drv.platform]; + auto & machineType = (*machineTypes_)[step->systemType]; assert(machineType.running); machineType.running--; if (machineType.running == 0) diff --git a/src/hydra-queue-runner/queue-monitor.cc b/src/hydra-queue-runner/queue-monitor.cc index 3be08897..bad6dabf 100644 --- a/src/hydra-queue-runner/queue-monitor.cc +++ b/src/hydra-queue-runner/queue-monitor.cc @@ -359,10 +359,14 @@ Step::ptr State::createStep(std::shared_ptr store, const Path & drvPat it's not runnable yet, and other threads won't make it runnable while step->created == false. */ step->drv = readDerivation(drvPath); + step->systemType = step->drv.platform; { auto i = step->drv.env.find("requiredSystemFeatures"); - if (i != step->drv.env.end()) + if (i != step->drv.env.end()) { step->requiredSystemFeatures = tokenizeString>(i->second); + step->systemType += ":"; + step->systemType += concatStringsSep(",", step->requiredSystemFeatures); + } } auto attr = step->drv.env.find("preferLocalBuild"); diff --git a/src/hydra-queue-runner/state.hh b/src/hydra-queue-runner/state.hh index db81a290..7d376b70 100644 --- a/src/hydra-queue-runner/state.hh +++ b/src/hydra-queue-runner/state.hh @@ -135,6 +135,7 @@ struct Step nix::Derivation drv; std::set requiredSystemFeatures; bool preferLocalBuild; + std::string systemType; // concatenation of drv.platform and requiredSystemFeatures struct State {