Re-implement log size limits

The old queue runner already had this. However, we now store "log
limit exceeded" as a separate status code in the database.
This commit is contained in:
Eelco Dolstra 2015-10-06 17:35:08 +02:00
parent 82504fe010
commit 8e8e31ce86
6 changed files with 25 additions and 8 deletions

View File

@ -155,17 +155,19 @@ void State::buildRemote(std::shared_ptr<StoreAPI> store,
/* Handshake. */ /* Handshake. */
bool sendDerivation = true; bool sendDerivation = true;
unsigned int remoteVersion;
try { try {
to << SERVE_MAGIC_1 << SERVE_PROTOCOL_VERSION; to << SERVE_MAGIC_1 << 0x202;
to.flush(); to.flush();
unsigned int magic = readInt(from); unsigned int magic = readInt(from);
if (magic != SERVE_MAGIC_2) if (magic != SERVE_MAGIC_2)
throw Error(format("protocol mismatch with nix-store --serve on %1%") % machine->sshName); throw Error(format("protocol mismatch with nix-store --serve on %1%") % machine->sshName);
unsigned int version = readInt(from); remoteVersion = readInt(from);
if (GET_PROTOCOL_MAJOR(version) != 0x200) if (GET_PROTOCOL_MAJOR(remoteVersion) != 0x200)
throw Error(format("unsupported nix-store --serve protocol version on %1%") % machine->sshName); throw Error(format("unsupported nix-store --serve protocol version on %1%") % machine->sshName);
if (GET_PROTOCOL_MINOR(version) >= 1) if (GET_PROTOCOL_MINOR(remoteVersion) >= 1)
sendDerivation = false; sendDerivation = false;
} catch (EndOfFile & e) { } catch (EndOfFile & e) {
@ -237,10 +239,12 @@ void State::buildRemote(std::shared_ptr<StoreAPI> store,
printMsg(lvlDebug, format("building %1% on %2%") % step->drvPath % machine->sshName); printMsg(lvlDebug, format("building %1% on %2%") % step->drvPath % machine->sshName);
if (sendDerivation) if (sendDerivation)
to << cmdBuildPaths << PathSet({step->drvPath}) << maxSilentTime << buildTimeout; to << cmdBuildPaths << PathSet({step->drvPath});
else else
to << cmdBuildDerivation << step->drvPath << basicDrv << maxSilentTime << buildTimeout; to << cmdBuildDerivation << step->drvPath << basicDrv;
// FIXME: send maxLogSize. to << maxSilentTime << buildTimeout;
if (GET_PROTOCOL_MINOR(remoteVersion) >= 2)
to << 64 * 1024 * 1024; // == maxLogSize
to.flush(); to.flush();
result.startTime = time(0); result.startTime = time(0);

View File

@ -300,10 +300,12 @@ bool State::doBuildStep(std::shared_ptr<StoreAPI> store, Step::ptr step,
BuildStatus buildStatus = BuildStatus buildStatus =
result.status == BuildResult::TimedOut ? bsTimedOut : result.status == BuildResult::TimedOut ? bsTimedOut :
result.status == BuildResult::LogLimitExceeded ? bsLogLimitExceeded :
result.canRetry() ? bsAborted : result.canRetry() ? bsAborted :
bsFailed; bsFailed;
BuildStepStatus buildStepStatus = BuildStepStatus buildStepStatus =
result.status == BuildResult::TimedOut ? bssTimedOut : result.status == BuildResult::TimedOut ? bssTimedOut :
result.status == BuildResult::LogLimitExceeded ? bssLogLimitExceeded :
result.canRetry() ? bssAborted : result.canRetry() ? bssAborted :
bssFailed; bssFailed;
@ -312,7 +314,8 @@ bool State::doBuildStep(std::shared_ptr<StoreAPI> store, Step::ptr step,
if (result.status == BuildResult::PermanentFailure || if (result.status == BuildResult::PermanentFailure ||
result.status == BuildResult::TransientFailure || result.status == BuildResult::TransientFailure ||
result.status == BuildResult::CachedFailure || result.status == BuildResult::CachedFailure ||
result.status == BuildResult::TimedOut) result.status == BuildResult::TimedOut ||
result.status == BuildResult::LogLimitExceeded)
result.errorMsg = ""; result.errorMsg = "";
/* Create failed build steps for every build that depends /* Create failed build steps for every build that depends

View File

@ -30,6 +30,7 @@ typedef enum {
bsFailedWithOutput = 6, bsFailedWithOutput = 6,
bsTimedOut = 7, bsTimedOut = 7,
bsUnsupported = 9, bsUnsupported = 9,
bsLogLimitExceeded = 10,
} BuildStatus; } BuildStatus;
@ -40,6 +41,7 @@ typedef enum {
bssTimedOut = 7, bssTimedOut = 7,
bssCachedFailure = 8, bssCachedFailure = 8,
bssUnsupported = 9, bssUnsupported = 9,
bssLogLimitExceeded = 10,
bssBusy = 100, // not stored bssBusy = 100, // not stored
} BuildStepStatus; } BuildStepStatus;

View File

@ -59,6 +59,8 @@
<span class="error">Cached failure</span> <span class="error">Cached failure</span>
[% ELSIF step.status == 9 %] [% ELSIF step.status == 9 %]
<span class="error">Unsupported system type</span> <span class="error">Unsupported system type</span>
[% ELSIF step.status == 10 %]
<span class="error">Log limit exceeded</span>
[% ELSIF step.errormsg %] [% ELSIF step.errormsg %]
<span class="error">Failed: [% HTML.escape(step.errormsg) %]</span> <span class="error">Failed: [% HTML.escape(step.errormsg) %]</span>
[% ELSE %] [% ELSE %]

View File

@ -206,6 +206,8 @@ BLOCK renderBuildStatusIcon;
<img src="[% c.uri_for("/static/images/error_${size}.png") %]" alt="Failed with output" class="build-status" /> <img src="[% c.uri_for("/static/images/error_${size}.png") %]" alt="Failed with output" class="build-status" />
[% ELSIF buildstatus == 7 %] [% ELSIF buildstatus == 7 %]
<img src="[% c.uri_for("/static/images/warning_${size}.png") %]" alt="Timed out" class="build-status" /> <img src="[% c.uri_for("/static/images/warning_${size}.png") %]" alt="Timed out" class="build-status" />
[% ELSIF buildstatus == 10 %]
<img src="[% c.uri_for("/static/images/warning_${size}.png") %]" alt="Log limit exceeded" class="build-status" />
[% ELSE %] [% ELSE %]
<img src="[% c.uri_for("/static/images/error_${size}.png") %]" alt="Failed" class="build-status" /> <img src="[% c.uri_for("/static/images/error_${size}.png") %]" alt="Failed" class="build-status" />
[% END; [% END;
@ -235,6 +237,8 @@ BLOCK renderStatus;
<span class="error">Timed out</span> <span class="error">Timed out</span>
[% ELSIF buildstatus == 9 %] [% ELSIF buildstatus == 9 %]
<span class="error">Unsupported system type</span> <span class="error">Unsupported system type</span>
[% ELSIF buildstatus == 10 %]
<span class="error">Log limit exceeded</span>
[% ELSE %] [% ELSE %]
<span class="error">Aborted</span> <span class="error">Aborted</span>
(Hydra failure; see <a href="#nix-error">below</a>) (Hydra failure; see <a href="#nix-error">below</a>)

View File

@ -195,6 +195,7 @@ create table Builds (
-- 6 = failure with output -- 6 = failure with output
-- 7 = timed out -- 7 = timed out
-- 9 = unsupported system type -- 9 = unsupported system type
-- 10 = log limit exceeded
buildStatus integer, buildStatus integer,
errorMsg text, -- error message in case of a Nix failure errorMsg text, -- error message in case of a Nix failure
@ -266,6 +267,7 @@ create table BuildSteps (
-- 7 = timed out -- 7 = timed out
-- 8 = cached failure -- 8 = cached failure
-- 9 = unsupported system type -- 9 = unsupported system type
-- 10 = log limit exceeded
status integer, status integer,
errorMsg text, errorMsg text,