Make struct Config fields private and introduces getter methods to
access them. This will make it easier to change the CI broker to be
able to run different adapters for different changes.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
The configuration file can have a field `queue_len_interval`, and
defaults to 10 seconds. This should reduce log spam.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Previously, we failed to capture all of stderr from the adapter if the
adapter sent messages to its stdout could not be parsed, or otherwise
meant the CI broker deduced the CI run had failed. Now we read all of
stderr (module time limits) before returning an error result.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Add subcommand "cibtool log" to extract cib log messages from journald
logs, and pretty print them. Optionally with some very rudimentary
filtering based on log level, message kind, or broker run id.
Example:
sudo journalctl -S today -u radicle-ci-broker -o json | cibtool log --log-level info
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This identifies what the message is, without having to parse the
message text, which is free form and may change and may some day get
translated.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Adjust log levels for messages, move data from free-form text field
into extra fields (even if still in free-form text form, as debug
formatted Rust values), and other related changes.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Change CI event creation to set the `from_node` field to the node id
in the Git ref being updated. Previously we set it to the `remote`
field in the node event, but that is id of the node from which our
local node got the `RefsUpdated` event, not the node where the change
was originally made.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This makes the code more verbose, possibly harder to follow, but will
make it easier to figure what's going wrong, in production. That's
more valuable than elegant code.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Refactor the code the constructs CI events from node events, and
trigger messages from CI events, to debug why I'm having trouble with
patch events.
Also adjust debug logging so I have more insight of what's going on.
Also, make code clearer, less repetitive, and overall easier to
follow.
Add support to "cibtool event add" for branch deletion, and patch
creation and update events. Use this in a scenario that adds every
type of event to the queue and processes them. This ensures the CI
broker can actually handle any kind of CI event.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
`subplot docgen` fails if an embedded file is not used. Drop the three
files that are no longer used.
This would've been found earlier if I gated merges on CI passing.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This will help with post-processing and filtering logs without having
to rely on the text of the log message.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Switch from the "slog" family of crates for structured logging to the
"tracing" family. There should be no significant changes to the log
messages, so I don't consider this to be a breaking change.
The benefit of this change is that it opens up the possibility to add
extra fields to the log messages as JSON values, instead of strings
that contain the values as JSON.
With slog we currently have this message::
{"msg":"broker database: /home/_rad/ci-broker.db"}
With slog or tracing we can change this to:
{"msg":"open database", "filename": "/home/_rad/ci-broker.db"}
With tracing we can have this:
{"msg":"open database","db":{"type":"sqlite","filename":"/home/_rad/ci-broker.db","size":12765}}
which would be, formatted prettily
{
"msg": "open database",
"db": {
"type": "sqlite",
"filename": "/home/_rad/ci-broker.db",
"size": 12765
}
}
Such extra fields can then be easily queried or otherwise processed
with programs, much more easily than having such programs parse text
fields as JSON before they can be processed.
Doing this with slog is supposed to be possible, but I have failed to
get it to work. The slog and tracing families of libraries seem
otherwise similar for our purposes.
Signed-off-by: Lars Wirzenius <liw@liw.fi>