Added support for metadata for job runs#208
Conversation
bba5a48 to
9c1cfad
Compare
With the `laminarc tag` command the build scripts can augment runs with metadata. This can be SCM-oriented information like the used branch or source-version. The metadata is a list of key/value pairs. The metadata is automatically shown in the run-view of a job in the web UI. Each call of `laminarc tag` can assign one key/value pair. Example: ``` laminarc tag $JOBNAME $NUMBER` \ Branch "$(git -C $WORKSPACE branch --show-current)" ```
9c1cfad to
accdff2
Compare
All keys from metainfo of all shown runs is concatenated. So only relevant colums for metadata is shown.
pkg-config is needed in docker image. "laminar.conf" has to be copied from "usr/etc/laminar.conf" to "etc/laminar.conf" in installation directory.
| set(CMAKE_CXX_STANDARD 17) | ||
|
|
||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare") | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=deprecated-declarations" ) |
There was a problem hiding this comment.
What caused this? If it is not related to this change it should be dealt with separately. Also consider that only Debug builds get -Werror, so if this is really needed then it should be put in CMAKE_CXX_FLAGS_DEBUG
| src/run.cpp | ||
| src/server.cpp | ||
| src/version.cpp | ||
| src/json.cpp |
There was a problem hiding this comment.
I don't think it is necessary to break this out into a separate file - see later comments for explanation
|
|
||
| Example: | ||
| ``` | ||
| laminarc tag $JOBNAME $NUMBER Branch "$(git -C $WORKSPACE branch --show-current)" |
There was a problem hiding this comment.
Since we only intend this to be called from within the run, laminarc can handle reading $JOBNAME and $NUMBER, see for example what set does
| return run->tag(key, value); | ||
| else | ||
| { | ||
| LLOG(WARNING, "No active run with ", job, buildNum); |
There was a problem hiding this comment.
return false (propagates error to laminarc)
| // store metadata into run | ||
| bool tag(const std::string& key, const std::string& value); | ||
| // Return the meta as JSON text | ||
| std::string getMetaDataJsonString(); |
There was a problem hiding this comment.
I don't think Run should know about JSON at all. Just do
const std::map<std::string, std::string>& metadata() const { return metadata; }
and do the conversion to JSON in the Laminar class with a local method there.
| kj::PromiseFulfillerPair<RunState> finished; | ||
| kj::ForkedPromise<RunState> finishedFork; | ||
|
|
||
| std::map<std::string, std::string> metaDataMap; |
There was a problem hiding this comment.
There is a minor consideration here: what order should the tags show up in the frontend? Using std::map means they will show up alphabetically, but I wonder if it would be preferable for them to show up in the order that they were created? Unfortunately I think that would require using vector<pair<string,string>> and manually checking for duplicates, or using boost::multi_index_container
| LLOG(INFO, "Setting tag ", key, value ); | ||
| metaDataMap[key]=value; | ||
| return true; | ||
| } |
| <template v-show="Object.keys(job.metadata).length" v-for="(value, key) in job.metadata"> | ||
| <dt>{{key}}</dt> | ||
| <dd>{{value}}</dd> | ||
| </template> |
There was a problem hiding this comment.
I think this would look better before / on top of the artifacts
| <div style="grid-column: 1/-1"> | ||
| <div v-show="false">{{metaDataKeys=["XBranch", "XVersion"]}}</div> | ||
| <div v-show="false">{{allJobs=jobsQueued.concat(jobsRunning).concat(jobsRecent)}}</div> | ||
| <div v-show="false">{{metaDataKeys=uniteMetadataKeys(allJobs)}}</div> |
There was a problem hiding this comment.
I think metadataKeys is best generated in the JS at the time the run list is received, and updated when a new run joins the list
| <canvas id="chartBt"></canvas> | ||
| </div> | ||
| <div style="grid-column: 1/-1"> | ||
| <div v-show="false">{{metaDataKeys=["XBranch", "XVersion"]}}</div> |
| <th class="text-center">Started <a class="sort" :class="(sort.field=='started'?sort.order:'')" v-on:click="do_sort('started')"> </a></th> | ||
| <th class="text-center">Duration <a class="sort" :class="(sort.field=='duration'?sort.order:'')" v-on:click="do_sort('duration')"> </a></th> | ||
| <th class="text-center vp-sm-hide">Reason <a class="sort" :class="(sort.field=='reason'?sort.order:'')" v-on:click="do_sort('reason')"> </a></th> | ||
| <th class="text-center vp-sm-hide" v-for="(value, key) in metaDataKeys">{{key}}<a class="sort" :class="(sort.field=='reason'?sort.order:'')" v-on:click="do_sort('reason')"> </a></th> |
There was a problem hiding this comment.
Do not sort by reason. It should be pretty simple to add sorting by metadata fields, using something like 'meta_' + key for sort.field and in the backend using ORDER BY metadata -> $key, but also happy just to not implement sorting for metadata
| EOF | ||
| echo /etc/laminar.conf > laminar/DEBIAN/conffiles | ||
| mkdir -p laminar/etc | ||
| mv laminar/usr/etc/laminar.conf laminar/etc/laminar.conf |
There was a problem hiding this comment.
I think this is a bug introduced elsewhere and this is not the right place to fix it
| DOCKER_TAG=$(docker build -q - <<EOS | ||
| FROM debian:11-slim | ||
| RUN apt-get update && apt-get install -y wget cmake g++ capnproto libcapnp-dev rapidjson-dev libsqlite3-dev libboost-dev zlib1g-dev | ||
| RUN apt-get update && apt-get install -y wget cmake g++ capnproto libcapnp-dev rapidjson-dev libsqlite3-dev libboost-dev zlib1g-dev pkg-config |
|
This seems pretty useful. Hopefully it can be completed. |
With the
laminarc tagcommand the build scripts can augment runs with metadata. This can be SCM-oriented information like the used branch or source-version.The metadata is a list of key-value-pairs. The metadata is automatically shown in the run-view of a job in the web UI.
Each call of
laminarc tagcan assign one key/value pair.Example: