Skip to content

Commit 9c4abf3

Browse files
tronbotopront
andauthored
fix(shutdown): emit VectorStopped after topology drains (#25083)
* move VectorStopped event * add changelog * Add VectorStopping event * Update changelog.d/24532_vector_stopped_log_ordering.fix.md * Apply suggestion from @pront --------- Co-authored-by: Pavlos Rontidis <pavlos.rontidis@gmail.com>
1 parent 985f669 commit 9c4abf3

3 files changed

Lines changed: 32 additions & 10 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Fixed log message ordering on shutdown where `Vector has stopped.` was logged before components had finished draining, causing confusing output interleaved with `Waiting on running components` messages.
2+
3+
A new `VectorStoppping` event was added in the place of the `VectorStopped` event.
4+
5+
authors: tronboto

src/app.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ use crate::{
2828
config::{self, ComponentConfig, ComponentType, Config, ConfigPath},
2929
extra_context::ExtraContext,
3030
heartbeat,
31-
internal_events::{VectorConfigLoadError, VectorQuit, VectorStarted, VectorStopped},
31+
internal_events::{
32+
VectorConfigLoadError, VectorQuit, VectorStarted, VectorStopped, VectorStopping,
33+
},
3234
signal::{SignalHandler, SignalPair, SignalRx, SignalTo},
3335
topology::{
3436
ReloadOutcome, RunningTopology, SharedTopologyController, ShutdownErrorReceiver,
@@ -493,16 +495,19 @@ impl FinishedApplication {
493495
}
494496

495497
async fn stop(topology_controller: TopologyController, mut signal_rx: SignalRx) -> ExitStatus {
496-
emit!(VectorStopped);
498+
emit!(VectorStopping);
497499
tokio::select! {
498-
_ = topology_controller.stop() => ExitStatus::from_raw({
499-
#[cfg(windows)]
500-
{
501-
exitcode::OK as u32
502-
}
503-
#[cfg(unix)]
504-
exitcode::OK
505-
}), // Graceful shutdown finished
500+
_ = topology_controller.stop() => {
501+
emit!(VectorStopped);
502+
ExitStatus::from_raw({
503+
#[cfg(windows)]
504+
{
505+
exitcode::OK as u32
506+
}
507+
#[cfg(unix)]
508+
exitcode::OK
509+
})
510+
}, // Graceful shutdown finished
506511
_ = signal_rx.recv() => Self::quit(),
507512
}
508513
}

src/internal_events/process.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ impl InternalEvent for VectorReloaded<'_> {
3838
}
3939
}
4040

41+
#[derive(Debug, NamedInternalEvent)]
42+
pub struct VectorStopping;
43+
44+
impl InternalEvent for VectorStopping {
45+
fn emit(self) {
46+
info!(
47+
target: "vector",
48+
message = "Vector is stopping.",
49+
);
50+
}
51+
}
52+
4153
#[derive(Debug, NamedInternalEvent)]
4254
pub struct VectorStopped;
4355

0 commit comments

Comments
 (0)