Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update_agent: add hidden knob to override interactive session check #1178

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems OK as is, but I personally would have probably leaned towards making this an environment variable and told people to systemctl edit --runtime zincati instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I debated on this a bit. It's just... so much easier to touch a file than to type out a dropin. Though we could also have added a cosa run --add-ignition zincati-override-interactive-check to help.


/// 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
Loading