Skip to content

Commit

Permalink
update_agent: add hidden knob to override interactive session check
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
jlebon committed Apr 26, 2024
1 parent 495cd1c commit 555b154
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/update_agent/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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!(
Expand Down

0 comments on commit 555b154

Please sign in to comment.