Unify build and step status codes
Also remove the obsolete status code 5 from the database.
This commit is contained in:
parent
9127f5bbc3
commit
80ff78b1b6
|
@ -116,7 +116,7 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore, Step::ptr step,
|
|||
{
|
||||
auto mc = startDbUpdate();
|
||||
pqxx::work txn(*conn);
|
||||
stepNr = createBuildStep(txn, result.startTime, build, step, machine->sshName, bssBusy);
|
||||
stepNr = createBuildStep(txn, result.startTime, build, step, machine->sshName, bsBusy);
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore, Step::ptr step,
|
|||
auto mc = startDbUpdate();
|
||||
pqxx::work txn(*conn);
|
||||
finishBuildStep(txn, result.startTime, result.stopTime, result.overhead, build->id,
|
||||
stepNr, machine->sshName, bssAborted, result.errorMsg);
|
||||
stepNr, machine->sshName, bsAborted, result.errorMsg);
|
||||
txn.commit();
|
||||
if (quit) exit(1);
|
||||
return sRetry;
|
||||
|
@ -222,7 +222,7 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore, Step::ptr step,
|
|||
pqxx::work txn(*conn);
|
||||
|
||||
finishBuildStep(txn, result.startTime, result.stopTime, result.overhead,
|
||||
build->id, stepNr, machine->sshName, bssSuccess);
|
||||
build->id, stepNr, machine->sshName, bsSuccess);
|
||||
|
||||
for (auto & b : direct)
|
||||
markSucceededBuild(txn, b, res, build != b || result.status != BuildResult::Built,
|
||||
|
@ -314,11 +314,6 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore, Step::ptr step,
|
|||
result.status == BuildResult::LogLimitExceeded ? bsLogLimitExceeded :
|
||||
result.canRetry() ? bsAborted :
|
||||
bsFailed;
|
||||
BuildStepStatus buildStepStatus =
|
||||
result.status == BuildResult::TimedOut ? bssTimedOut :
|
||||
result.status == BuildResult::LogLimitExceeded ? bssLogLimitExceeded :
|
||||
result.canRetry() ? bssAborted :
|
||||
bssFailed;
|
||||
|
||||
/* For standard failures, we don't care about the error
|
||||
message. */
|
||||
|
@ -340,12 +335,12 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore, Step::ptr step,
|
|||
build2->finishedInDB)
|
||||
continue;
|
||||
createBuildStep(txn, 0, build2, step, machine->sshName,
|
||||
buildStepStatus, result.errorMsg, build == build2 ? 0 : build->id);
|
||||
buildStatus, result.errorMsg, build == build2 ? 0 : build->id);
|
||||
}
|
||||
|
||||
if (!cachedFailure)
|
||||
finishBuildStep(txn, result.startTime, result.stopTime, result.overhead,
|
||||
build->id, stepNr, machine->sshName, buildStepStatus, result.errorMsg);
|
||||
build->id, stepNr, machine->sshName, buildStatus, result.errorMsg);
|
||||
|
||||
/* Mark all builds that depend on this derivation as failed. */
|
||||
for (auto & build2 : indirect) {
|
||||
|
|
|
@ -202,7 +202,7 @@ void State::clearBusy(Connection & conn, time_t stopTime)
|
|||
pqxx::work txn(conn);
|
||||
txn.parameterized
|
||||
("update BuildSteps set busy = 0, status = $1, stopTime = $2 where busy = 1")
|
||||
((int) bssAborted)
|
||||
((int) bsAborted)
|
||||
(stopTime, stopTime != 0).exec();
|
||||
txn.commit();
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ int State::allocBuildStep(pqxx::work & txn, Build::ptr build)
|
|||
|
||||
|
||||
int State::createBuildStep(pqxx::work & txn, time_t startTime, Build::ptr build, Step::ptr step,
|
||||
const std::string & machine, BuildStepStatus status, const std::string & errorMsg, BuildID propagatedFrom)
|
||||
const std::string & machine, BuildStatus status, const std::string & errorMsg, BuildID propagatedFrom)
|
||||
{
|
||||
int stepNr = allocBuildStep(txn, build);
|
||||
|
||||
|
@ -230,13 +230,13 @@ int State::createBuildStep(pqxx::work & txn, time_t startTime, Build::ptr build,
|
|||
(stepNr)
|
||||
(0) // == build
|
||||
(step->drvPath)
|
||||
(status == bssBusy ? 1 : 0)
|
||||
(status == bsBusy ? 1 : 0)
|
||||
(startTime, startTime != 0)
|
||||
(step->drv.platform)
|
||||
((int) status, status != bssBusy)
|
||||
((int) status, status != bsBusy)
|
||||
(propagatedFrom, propagatedFrom != 0)
|
||||
(errorMsg, errorMsg != "")
|
||||
(startTime, startTime != 0 && status != bssBusy)
|
||||
(startTime, startTime != 0 && status != bsBusy)
|
||||
(machine).exec();
|
||||
|
||||
for (auto & output : step->drv.outputs)
|
||||
|
@ -249,7 +249,7 @@ int State::createBuildStep(pqxx::work & txn, time_t startTime, Build::ptr build,
|
|||
|
||||
|
||||
void State::finishBuildStep(pqxx::work & txn, time_t startTime, time_t stopTime, unsigned int overhead,
|
||||
BuildID buildId, int stepNr, const std::string & machine, BuildStepStatus status,
|
||||
BuildID buildId, int stepNr, const std::string & machine, BuildStatus status,
|
||||
const std::string & errorMsg, BuildID propagatedFrom)
|
||||
{
|
||||
assert(startTime);
|
||||
|
|
|
@ -205,7 +205,7 @@ bool State::getQueuedBuilds(Connection & conn, ref<Store> localStore,
|
|||
}
|
||||
}
|
||||
|
||||
createBuildStep(txn, 0, build, r, "", bssCachedFailure, "", propagatedFrom);
|
||||
createBuildStep(txn, 0, build, r, "", bsCachedFailure, "", propagatedFrom);
|
||||
txn.parameterized
|
||||
("update Builds set finished = 1, buildStatus = $2, startTime = $3, stopTime = $3, isCachedBuild = 1 where id = $1 and finished = 0")
|
||||
(build->id)
|
||||
|
|
|
@ -26,27 +26,17 @@ typedef std::chrono::time_point<std::chrono::system_clock> system_time;
|
|||
typedef enum {
|
||||
bsSuccess = 0,
|
||||
bsFailed = 1,
|
||||
bsDepFailed = 2,
|
||||
bsDepFailed = 2, // builds only
|
||||
bsAborted = 3,
|
||||
bsFailedWithOutput = 6,
|
||||
bsFailedWithOutput = 6, // builds only
|
||||
bsTimedOut = 7,
|
||||
bsCachedFailure = 8, // steps only
|
||||
bsUnsupported = 9,
|
||||
bsLogLimitExceeded = 10,
|
||||
bsBusy = 100, // not stored
|
||||
} BuildStatus;
|
||||
|
||||
|
||||
typedef enum {
|
||||
bssSuccess = 0,
|
||||
bssFailed = 1,
|
||||
bssAborted = 4,
|
||||
bssTimedOut = 7,
|
||||
bssCachedFailure = 8,
|
||||
bssUnsupported = 9,
|
||||
bssLogLimitExceeded = 10,
|
||||
bssBusy = 100, // not stored
|
||||
} BuildStepStatus;
|
||||
|
||||
|
||||
struct RemoteResult : nix::BuildResult
|
||||
{
|
||||
time_t startTime = 0, stopTime = 0;
|
||||
|
@ -384,12 +374,12 @@ private:
|
|||
int allocBuildStep(pqxx::work & txn, Build::ptr build);
|
||||
|
||||
int createBuildStep(pqxx::work & txn, time_t startTime, Build::ptr build, Step::ptr step,
|
||||
const std::string & machine, BuildStepStatus status, const std::string & errorMsg = "",
|
||||
const std::string & machine, BuildStatus status, const std::string & errorMsg = "",
|
||||
BuildID propagatedFrom = 0);
|
||||
|
||||
void finishBuildStep(pqxx::work & txn, time_t startTime, time_t stopTime,
|
||||
unsigned int overhead, BuildID buildId, int stepNr,
|
||||
const std::string & machine, BuildStepStatus status, const std::string & errorMsg = "",
|
||||
const std::string & machine, BuildStatus status, const std::string & errorMsg = "",
|
||||
BuildID propagatedFrom = 0);
|
||||
|
||||
int createSubstitutionStep(pqxx::work & txn, time_t startTime, time_t stopTime,
|
||||
|
|
|
@ -55,7 +55,7 @@ FOR step IN steps; IF step.busy; busy = 1; END; END;
|
|||
<strong>Building</strong>
|
||||
[% ELSIF step.status == 0 %]
|
||||
Succeeded
|
||||
[% ELSIF step.status == 4 %]
|
||||
[% ELSIF step.status == 3 %]
|
||||
<span class="error"><strong>Aborted</strong>[% IF step.errormsg %]: [% HTML.escape(step.errormsg); END %]</span>
|
||||
[% ELSIF step.status == 7 %]
|
||||
<span class="error">Timed out</span>
|
||||
|
|
|
@ -195,7 +195,7 @@ BLOCK renderBuildStatusIcon;
|
|||
<img src="[% c.uri_for("/static/images/checkmark_${size}.png") %]" alt="Succeeded" class="build-status" />
|
||||
[% ELSIF buildstatus == 1 %]
|
||||
<img src="[% c.uri_for("/static/images/error_${size}.png") %]" alt="Failed" class="build-status" />
|
||||
[% ELSIF buildstatus == 2 || buildstatus == 5 %]
|
||||
[% ELSIF buildstatus == 2 %]
|
||||
<img src="[% c.uri_for("/static/images/dependency_${size}.png") %]" alt="Dependency failed" class="build-status" />
|
||||
[% ELSIF buildstatus == 3 || buildstatus == 9 %]
|
||||
<img src="[% c.uri_for("/static/images/warning_${size}.png") %]" alt="Aborted" class="build-status" />
|
||||
|
@ -224,7 +224,7 @@ BLOCK renderStatus;
|
|||
<strong>Success</strong>
|
||||
[% ELSIF buildstatus == 1 %]
|
||||
<span class="error">Build returned a non-zero exit code</span>
|
||||
[% ELSIF buildstatus == 2 || buildstatus == 5 %]
|
||||
[% ELSIF buildstatus == 2 %]
|
||||
<span class="error">A dependency of the build failed</span>
|
||||
[% ELSIF buildstatus == 4 %]
|
||||
<span class="error">Cancelled by user</span>
|
||||
|
|
|
@ -180,15 +180,16 @@ create table Builds (
|
|||
-- Information about finished builds.
|
||||
isCachedBuild integer, -- boolean
|
||||
|
||||
-- Status codes:
|
||||
-- Status codes used for builds and steps:
|
||||
-- 0 = succeeded
|
||||
-- 1 = build of this derivation failed
|
||||
-- 2 = build of some dependency failed
|
||||
-- 3 = other failure
|
||||
-- 4 = build cancelled (removed from queue; never built)
|
||||
-- 5 = build not done because a dependency failed previously (obsolete)
|
||||
-- 6 = failure with output
|
||||
-- 7 = timed out
|
||||
-- 1 = regular Nix failure (derivation returned non-zero exit code)
|
||||
-- 2 = build of a dependency failed [builds only]
|
||||
-- 3 = build or step aborted due to misc failure
|
||||
-- 4 = build cancelled (removed from queue; never built) [builds only]
|
||||
-- 5 = [obsolete]
|
||||
-- 6 = failure with output (i.e. $out/nix-support/failed exists) [builds only]
|
||||
-- 7 = build timed out
|
||||
-- 8 = cached failure [steps only; builds use isCachedBuild]
|
||||
-- 9 = unsupported system type
|
||||
-- 10 = log limit exceeded
|
||||
buildStatus integer,
|
||||
|
@ -253,15 +254,7 @@ create table BuildSteps (
|
|||
|
||||
busy integer not null,
|
||||
|
||||
-- Status codes:
|
||||
-- 0 = succeeded
|
||||
-- 1 = failed normally
|
||||
-- 4 = aborted
|
||||
-- 7 = timed out
|
||||
-- 8 = cached failure
|
||||
-- 9 = unsupported system type
|
||||
-- 10 = log limit exceeded
|
||||
status integer,
|
||||
status integer, -- see Builds.buildStatus
|
||||
|
||||
errorMsg text,
|
||||
|
||||
|
|
5
src/sql/upgrade-46.sql
Normal file
5
src/sql/upgrade-46.sql
Normal file
|
@ -0,0 +1,5 @@
|
|||
-- Unify Builds and BuildSteps status codes.
|
||||
update BuildSteps set status = 3 where status = 4;
|
||||
|
||||
-- Get rid of obsolete status code 5.
|
||||
update Builds set isCachedBuild = 1, buildStatus = 2 where buildStatus = 5;
|
Loading…
Reference in a new issue