From 76f4332d42fb164b542d043d8c8fb274d9939810 Mon Sep 17 00:00:00 2001 From: Dominic Burkart Date: Wed, 24 May 2023 19:18:45 +0200 Subject: [PATCH] Revert "feat(make shutdown duration configurable): move graceful_shutdown_duration to top-level config" This reverts commit c20100c62ad9c582702e9547a7e2bab162ffed6c. --- lib/vector-core/src/config/global_options.rs | 7 +++++++ src/app.rs | 2 +- src/config/builder.rs | 7 ------- src/config/compiler.rs | 2 -- src/config/mod.rs | 1 - src/topology/running.rs | 2 +- 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/vector-core/src/config/global_options.rs b/lib/vector-core/src/config/global_options.rs index 222560bd995d45..38a0dc0627f6e8 100644 --- a/lib/vector-core/src/config/global_options.rs +++ b/lib/vector-core/src/config/global_options.rs @@ -115,6 +115,12 @@ pub struct GlobalOptions { skip_serializing_if = "crate::serde::skip_serializing_if_default" )] pub expire_metrics_secs: Option, + + /// The amount of time, in seconds, that Vector waits for internal processes to stop gracefully + /// after a SIGINT or SIGTERM is received. Default is 60 seconds. Set to -1 to never force + /// shutdown after SIGINT/SIGTERM received. + #[serde(default)] + pub graceful_shutdown_duration: i64, } impl GlobalOptions { @@ -228,6 +234,7 @@ impl GlobalOptions { proxy: self.proxy.merge(&with.proxy), expire_metrics: self.expire_metrics.or(with.expire_metrics), expire_metrics_secs: self.expire_metrics_secs.or(with.expire_metrics_secs), + graceful_shutdown_duration: self.graceful_shutdown_duration, }) } else { Err(errors) diff --git a/src/app.rs b/src/app.rs index 906193eb2cc028..24a8d4ea9caf16 100644 --- a/src/app.rs +++ b/src/app.rs @@ -442,7 +442,7 @@ pub async fn load_configs( info!("Health checks are disabled."); } config.healthchecks.set_require_healthy(require_healthy); - config.graceful_shutdown_duration = graceful_shutdown_duration; + config.global.graceful_shutdown_duration = graceful_shutdown_duration; Ok(config) } diff --git a/src/config/builder.rs b/src/config/builder.rs index ab89ee4ea1e41b..a758bac25316bb 100644 --- a/src/config/builder.rs +++ b/src/config/builder.rs @@ -78,11 +78,6 @@ pub struct ConfigBuilder { /// All configured secrets backends. #[serde(default)] pub secret: IndexMap, - - /// Set the duration in seconds to wait for graceful shutdown after SIGINT or SIGTERM are received. - /// After the duration has passed, Vector will force shutdown. Default value is 60 seconds. If set - /// to -1, Vector will never force shutdown. - pub graceful_shutdown_duration: i64, } #[cfg(feature = "enterprise")] @@ -200,7 +195,6 @@ impl From for ConfigBuilder { transforms, tests, secret, - graceful_shutdown_duration, hash: _, } = config; @@ -231,7 +225,6 @@ impl From for ConfigBuilder { provider: None, tests, secret, - graceful_shutdown_duration, } } } diff --git a/src/config/compiler.rs b/src/config/compiler.rs index 32465a479ab44a..90ca43ddd7adfa 100644 --- a/src/config/compiler.rs +++ b/src/config/compiler.rs @@ -56,7 +56,6 @@ pub fn compile(mut builder: ConfigBuilder) -> Result<(Config, Vec), Vec< tests, provider: _, secret, - graceful_shutdown_duration, } = builder; let graph = match Graph::new(&sources, &transforms, &sinks, schema) { @@ -112,7 +111,6 @@ pub fn compile(mut builder: ConfigBuilder) -> Result<(Config, Vec), Vec< transforms, tests, secret, - graceful_shutdown_duration, }; config.propagate_acknowledgements()?; diff --git a/src/config/mod.rs b/src/config/mod.rs index b264731696ebf3..473961f2eaf7cf 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -103,7 +103,6 @@ pub struct Config { pub enrichment_tables: IndexMap, tests: Vec, secret: IndexMap, - pub graceful_shutdown_duration: i64, } impl Config { diff --git a/src/topology/running.rs b/src/topology/running.rs index 2c9c3680a5e610..e7a369a4eafec6 100644 --- a/src/topology/running.rs +++ b/src/topology/running.rs @@ -62,7 +62,7 @@ impl RunningTopology { abort_tx, watch: watch::channel(TapResource::default()), running: Arc::new(AtomicBool::new(true)), - graceful_shutdown_duration: match config.graceful_shutdown_duration { + graceful_shutdown_duration: match config.global.graceful_shutdown_duration { -1 => None, seconds => Some(Duration::from_secs(seconds as u64)), // clap validator makes sure value is >= -1 },