I didn't like having asserts, and didn't want debug_asserts. With
plain asserts, the program would have panicked. With debug_asserts, the
program would have silently overwritten the item in the queue.
Instead, change the method to return whether it was able to set, and
have the caller cope with not being able to set. The caller needs to
be able handle that (and was already doing so).
Found-by: Fintan
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Feed child process stdin via a temporary file. This is simpler than
opening a pipe and spawning a thread that feeds the pipe, when it's
not full.
Capture child stderr into a buffer without trying to let the
caller (another thread) process it line by line. We don't seem to have
use for that, and this simplifies things a fair bit.
Simplify the capture of child stdout to use a simpler thread and data
structure, compared to the previous multi-thread setup. Splitting
stdout into lines is now done by the thread that consumes the lines,
making the code that captures it simpler.
Also update the timeout subcommand to work with the changes. Other
callers of this code aren't yet updated.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This will be useful for inter-thread synchronization in situations
where the producer thread should not produce anything until at least
one consumer is ready for it.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This doesn't yet affect anything, but it's a step towards implementing
concurrent adapters. The default is 1, which will be no change from
previous behavior, once I add support.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Make TagName into a new type (struct), instead of a type alias for
RefString. This provide stronger type safety, for the cost of a little
more implementation work. For the needs of the CI broker, that's two
methods and two trait impls.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
We need to parse the run info in the database as JSON to get at the
adapter run info. This fails if the run info can't be parsed. That can
happen if the database has run info from a development version. Change
`cibtool run remove` so that it takes only broker run ids by default
so that we can delete using those even if the run info is broken.
Allow removing by adapter run id with the `--adapter` option.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
If the run info can't be parsed as JSON, loading it will fail. Change
`cibtool run list` so that it only lists the run ids by default.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This makes them more obvious than at the debug level. These are not
messages that repeat, so they won't be log spam.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
When we get a CI event, we parse the namespaced name in the event to
see if it's a patch, or branch update. However, if might not be a
either: it might, for example, be a sigrefs update. Create a
branch event only if it's a branch event. Previously we would assume
it's branch event if not a patch event, and return an error if it's
not actually a branch.
If it's not a patch or branch change, ignore the event, as there's
nothing useful we can do about it, at least for now.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Don't log unstructured messages from various places in processing
events and the execution of a CI run. I think these are unnecessary
messages anyway, by now. If it turns out we need them, we'll add them
back as structured log messages.
Drop the now-unused logger::debug, debug2, trace, and trace2
functions, may the never return.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Previously, we might not remove the event from the queue if something
went wrong while processing it. This could result in the CI broker
picking again in the future, and it might fail again, and repeat ad
nauseam.
It's better to remove the event from the queue at once, and log any
problems while processing it, and let humans deal with failures, and
decide if re-processing is needed.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This means that even if the thread ends due to an error, the error
gets logged. This will help with diagnosing problems.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This means that even if the thread ends due to an error, the error
gets logged. This will help with diagnosing problems.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This means that even if the thread ends due to an error, the error
gets logged. This will help with diagnosing problems.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This is a huge change, but it's mostly a few kinds of similar changes
in a lot of places. Unfortunately, they were not easy to tease apart
into small, easily reviewed commits.
Use the Git ref types created by the new refs module. Fix problems
this exposes.
The CiEvent enum variants for branch events now use the BranchName
type for branch names. In other words, they have a plain branch name.
The CiEvent::from_node_event constructor also always sets the branch
name to a plain branch name, instead of a name spaced ref for updated
or deleted branches. The ci_event.rs module's unit tests have been
fixed to use the correct kind of Git ref in each test. (It used to be
a mess.)
The CI event filter "Branch" now contains a BranchName, previously a
RefString. This should not break anything, as a RefString will always
work as a BranchName.
The DefaultBranch filter now works, because it compares plain branch
names, where it previously would compare a plain and a name spaced
branch name, and those are never equal.
"cibtool trigger" and "cibtool event add" now add branch events with a plain
branch instead of a name spaced ref.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Add helper functions to construct plain branch names ("main"), full
branch refs ("refs/heads/main"), and namespaced full branch
names ("refs/namespaces/$NID/refs/heads/main").
Keeping track of while only using RefStrings is too hard to get right.
We need to use the types provided by the radicle crate: BranchName,
Qualified, and Namespaced. Even if I find the type names less than
obvious, they're much better than plain RefStrings.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Very long RSS feeds can cause problems for some readers. Apparently
they forget they've already seen very old entries and show them as
new. To work around this, only include the ten newest CI runs.
Signed-off-by: Lars Wirzenius <liw@liw.fi>