1
0
mirror of https://github.com/ohwgiles/laminar.git synced 2026-11-03 00:54:44 +00:00

assign run numbers at queue time

This allows build chains to be traced in the common case where
an upstream job calls `laminarc queue' instead of `laminarc start'.
Incomplete job runs now have database entries, which requires
some adjustments in queries. Queued jobs can now be viewed in
the frontend and there is a corresponding status icon.
This commit is contained in:
Oliver Giles
2020-09-25 15:29:30 +12:00
parent 6d2c0b208b
commit 06a5f3d8ef
10 changed files with 119 additions and 112 deletions

View File

@@ -33,7 +33,7 @@ inline kj::Path operator/(const kj::Path& p, const T& ext) {
std::string to_string(const RunState& rs) {
switch(rs) {
case RunState::PENDING: return "pending";
case RunState::QUEUED: return "queued";
case RunState::RUNNING: return "running";
case RunState::ABORTED: return "aborted";
case RunState::FAILED: return "failed";
@@ -44,9 +44,10 @@ std::string to_string(const RunState& rs) {
}
Run::Run(std::string name, ParamMap pm, kj::Path&& rootPath) :
Run::Run(std::string name, uint num, ParamMap pm, kj::Path&& rootPath) :
result(RunState::SUCCESS),
name(name),
build(num),
params(kj::mv(pm)),
queuedAt(time(nullptr)),
rootPath(kj::mv(rootPath)),
@@ -83,7 +84,7 @@ static void setEnvFromFile(const kj::Path& rootPath, kj::Path file) {
}
}
kj::Promise<RunState> Run::start(uint buildNum, RunState lastResult, std::shared_ptr<Context> ctx, const kj::Directory &fsHome, std::function<kj::Promise<int>(kj::Maybe<pid_t>&)> getPromise)
kj::Promise<RunState> Run::start(RunState lastResult, std::shared_ptr<Context> ctx, const kj::Directory &fsHome, std::function<kj::Promise<int>(kj::Maybe<pid_t>&)> getPromise)
{
kj::Path cfgDir{"cfg"};
@@ -130,7 +131,7 @@ kj::Promise<RunState> Run::start(uint buildNum, RunState lastResult, std::shared
PATH.append(p);
}
std::string runNumStr = std::to_string(buildNum);
std::string runNumStr = std::to_string(build);
setenv("PATH", PATH.c_str(), true);
setenv("RUN", runNumStr.c_str(), true);
@@ -151,14 +152,13 @@ kj::Promise<RunState> Run::start(uint buildNum, RunState lastResult, std::shared
// enough. Instead, we'll just exec ourselves and handle that in laminard's
// main() by calling leader_main()
char* procName;
if(asprintf(&procName, "{laminar} %s:%d", name.data(), buildNum) > 0)
if(asprintf(&procName, "{laminar} %s:%d", name.data(), build) > 0)
execl("/proc/self/exe", procName, NULL); // does not return
_exit(EXIT_FAILURE);
}
// All good, we've "started"
startedAt = time(nullptr);
build = buildNum;
context = ctx;
output_fd = plog[0];