Each additional version makes the upgrade test take longer, and we
only really need to care about recent releases, I think.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Change src/adapter.rs to send notification via the run notification
channel when the adapter is spawned, and when the adapter sends a
"triggered" message.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Add new NotificationChannel constructors, for different kinds of
channels. Store the receive timeout in the receiver; it depends on
kind of channel.
Also add methods to send and receive notifications to senders and
receivers. This hides the std::sync::mpsc machinery better, and makes
the types easier to use.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Add the `Node(nid)` event filter.
Add the `from_node` field to the `BranchDeleted` event so that it too
can be filtered based on node.
Adjust debug logging for event filtering so that it reports the
filtering decision.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
It's awkward if enum variants have wildly different sizes. Change
BrokerError::NotTrigger to store the Request value in a Box, so that
it's not in the enum directly. This makes all variants about the same
size, and thus the decorators that allow the
clippy::large_enum_variant can be dropped.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This will help us avoid breaking changes in the future, when CI events
need to be modified, and CI broker instances need to cope with the
event queues in their databases.
Previously we had
enum CiEvent {
BranchCreated { ... },
BranchUpdatee { ... },
....
}
Change that to:
enum CiEvent {
V1(CiEventV1),
}
enum CiEventV1 {
BranchCreated { ... },
BranchUpdatee { ... },
....
}
This will allow us to add new version variants to CiEvent, without
losing access to the already enqueued V1 events.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
An unwrap (or unwrap_err, or their expect variants) can result in run
time panics: unwrapping an Option that is None can't return a useful
result, so it panics. Similar for a Result. I've previously tried to
grep for uses of unwrap, but the clippy warning is much more precise.
Add "deny(clippy::unwrap_used)" to the top of src/lib.rs, so it
affects the whole crate. Then fix any places where unwrap is used.
It's OK to use unwrap in tests: if the value is expected, but isn't
there, the test should fail, and panic is a fine way to fail the test.
Everywhere else it's better to make sure unwrap can't fail, and if it
can, return a Result and have the caller handle that.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
For bad historical reasons, the CI broker was using a synthetic
"shutdown" event to signal from one thread to another that the node
connection has been disconnected. At an earlier stage of development,
this the only way for the "read node events" thread to notify the
"process queued events" thread that there would never be any more
events.
Now we have inter-thread message channels and we can use their closing
to do the signaling.
However, this meant that the queue would have a spurious shutdown
event. This led to the following sequence of things happening:
* node shuts down
* CI broker notices this, adds a shutdown event to queue, then
terminates the event-reading thread, thereby closing the message
channel
* the queue processing notices the message channel is closed, and
terminates
* the CI broker process terminates
* systemd restarts the CI broker
* the CI broker finds a shutdown event in the queue and terminates
The shutdown event is still needed so that the node admin has a
convenient way to tell the CI broker to terminate, even if they don't
have the privilege to stop systemd units.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
To process old queued events, run older version of CI broker until
queue is empty ("cib queued"), then upgrade.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Add a new table for a queue of CI events. Drop most of the methods
that operate on the old queue of broker events, but leave a method to
check if its empty.
We can't use the existing table event_queue, as that contains
serialized broker events, which are entirely incompatible with CI
events.