diff --git a/doc/userguide.md b/doc/userguide.md index 1402e363..69a700b5 100644 --- a/doc/userguide.md +++ b/doc/userguide.md @@ -265,7 +265,6 @@ The output will be in JSON (which also works as YAML input): "filters": [], "triggers": null, "report_dir": "html", - "status_update_interval_seconds": null, "db": "x.db", "max_run_time": { "secs": 3600, @@ -290,7 +289,7 @@ The configuration fields are: | `max_run_time` | maximum duration of a CI run | | `queue_len_interval` | how often the event queue length should be logged | | `report_dir` | directory where HTML and JSON report pages are written | -| `status_update_interval_seconds` | how often should `status.json` be updated? | +| `status_update_interval_seconds` | deprecated and ignore | | `triggers` | see [the "Triggering CI" chapter](#triggers) | The items in the `adapters` list may use the following fields: diff --git a/src/config.rs b/src/config.rs index 73bef0bc..85b7b471 100644 --- a/src/config.rs +++ b/src/config.rs @@ -12,12 +12,12 @@ use serde::{Deserialize, Serialize}; use crate::{ adapter::{Adapter, AdapterError, Adapters}, filter::{EventFilter, Trigger}, + logger, sensitive::Sensitive, }; const DEFAULT_MAX_RUN_TIME: Duration = Duration::from_secs(3600); const DEFAULT_QUEUE_LEN_INTERVAL: Duration = Duration::from_secs(3600); -const DEFAULT_STATUS_PAGE_UPDATE_INTERVAL: u64 = 10; #[derive(Debug, Serialize, Deserialize)] #[serde(deny_unknown_fields)] @@ -25,9 +25,16 @@ pub struct Config { default_adapter: Option, triggers: Option>, report_dir: Option, - status_update_interval_seconds: Option, db: PathBuf, + // This isn't actually used. The status page is updated about once + // a second, see `UPDATE_IMTERVAL` in `src/notif.rs`. However, we + // don't want to break existing configuration files, so we allow + // it. We just don't use it anywhere. + #[allow(dead_code)] + #[serde(skip)] + status_update_interval_seconds: Option, + #[serde(default)] adapters: HashMap, @@ -60,11 +67,15 @@ impl Config { std::fs::read(filename).map_err(|e| ConfigError::ReadConfig(filename.into(), e))?; let config: Config = serde_yml::from_slice(&config) .map_err(|e| ConfigError::ParseConfig(filename.into(), e))?; - config.check()?; + config.check(filename)?; Ok(config) } - fn check(&self) -> Result<(), ConfigError> { + fn check(&self, filename: &Path) -> Result<(), ConfigError> { + if self.status_update_interval_seconds.is_some() { + logger::config_deprecated("status_update_interval_seconds", filename); + } + if let Some(triggers) = &self.triggers { for trigger in triggers.iter() { if !self.adapters.contains_key(&trigger.adapter) { @@ -103,11 +114,6 @@ impl Config { .collect() } - pub fn status_page_update_interval(&self) -> u64 { - self.status_update_interval_seconds - .unwrap_or(DEFAULT_STATUS_PAGE_UPDATE_INTERVAL) - } - pub fn max_run_time(&self) -> Duration { self.max_run_time } diff --git a/src/logger.rs b/src/logger.rs index 16e7081e..8f6b6b10 100644 --- a/src/logger.rs +++ b/src/logger.rs @@ -134,6 +134,8 @@ enum Id { CibEndSuccess, CibStart, + ConfigDeprecated, + JobCreate, JobFailure, JobRunCreate, @@ -335,6 +337,16 @@ pub fn end_cib_in_error() { ); } +pub fn config_deprecated(field: &'static str, filename: &Path) { + warn!( + msg_id = ?Id::ConfigDeprecated, + kind = %Kind::Startup, + field, + ?filename, + "configuration field is deprecated and ignored", + ); +} + pub fn node_event_source_created(source: &NodeEventSource) { debug!( msg_id = ?Id::NodeEventSourceCreated,