From 555b15465297818a1b80100193149b547221ac81 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Fri, 26 Apr 2024 12:34:49 -0400 Subject: [PATCH] update_agent: add hidden knob to override interactive session check An issue as old as ~time~Fedora CoreOS is that when you're testing something related to updates, you want Zincati to reboot but because `cosa run` gives you an interactive session and you can't *not* have a session without losing the VM, you're stuck waiting for the 10 minutes grace period to expire. Just add a hidden knob for this to make that scenario less painful. The API is pretty much: when you're ready to have Zincati reboot, just `touch /run/zincati/override-interactive-check`. --- src/update_agent/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/update_agent/mod.rs b/src/update_agent/mod.rs index a21ce491..a4111d75 100644 --- a/src/update_agent/mod.rs +++ b/src/update_agent/mod.rs @@ -16,6 +16,7 @@ use serde::{Deserialize, Deserializer}; use std::cell::Cell; use std::collections::BTreeSet; use std::fs; +use std::path::Path; use std::rc::Rc; use std::time::Duration; use tokio::sync::RwLock; @@ -37,6 +38,10 @@ const DEFAULT_POSTPONEMENT_TIME_SECS: u64 = 60; // 1 minute. /// before abandoning a target update. const MAX_DEPLOY_ATTEMPTS: u8 = 12; +/// This is undocumented; it's for testing Zincati in e.g. cosa where you have +/// an interactive session but you don't want to wait for the full timeout. +const INTERACTIVE_SESSION_OVERRIDE: &str = "/run/zincati/override-interactive-check"; + /// Maximum number of postponements to finalizing an update in the /// `UpdateStaged` state before forcing an update finalization and reboot. pub(crate) const MAX_FINALIZE_POSTPONEMENTS: u8 = 10; @@ -284,6 +289,15 @@ impl UpdateAgentMachineState { return true; } + // Allow even with interactive sessions if we're overriding this check + if Path::new(INTERACTIVE_SESSION_OVERRIDE).exists() { + log::debug!( + "ignoring interactive sessions due to {}", + INTERACTIVE_SESSION_OVERRIDE + ); + return true; + } + let (release, postponements_remaining) = match self { UpdateAgentMachineState::UpdateStaged((r, p)) => (r, *p), _ => unreachable!(