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

Just exit normally when booted into a container #1117

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions dist/systemd/system/zincati.service
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ Environment=ZINCATI_VERBOSITY="-v"
Type=notify
ExecStart=/usr/libexec/zincati agent ${ZINCATI_VERBOSITY}
Restart=on-failure
# This status signals a non-restartable condition
RestartPreventExitStatus=7
RestartSec=10s

[Install]
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ fn run() -> i32 {
Err(e) => {
log_error_chain(&e);
if e.root_cause()
.downcast_ref::<crate::rpm_ostree::FatalError>()
.downcast_ref::<crate::rpm_ostree::SystemInoperable>()
.is_some()
{
7
0
} else {
libc::EXIT_FAILURE
}
Expand Down
9 changes: 5 additions & 4 deletions src/rpm_ostree/cli_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ lazy_static::lazy_static! {

/// An error which should not result in a retry/restart.
#[derive(Debug, Clone)]
pub struct FatalError(String);
pub struct SystemInoperable(String);

impl std::fmt::Display for FatalError {
impl std::fmt::Display for SystemInoperable {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.0.fmt(f)
}
}

impl std::error::Error for FatalError {}
impl std::error::Error for SystemInoperable {}

/// JSON output from `rpm-ostree status --json`
#[derive(Clone, Debug, Deserialize)]
Expand Down Expand Up @@ -101,8 +101,9 @@ pub fn parse_booted(status: &Status) -> Result<Release> {
let status = booted_status(status)?;
if let Some(img) = status.container_image_reference.as_ref() {
let msg = format!("Automatic updates disabled; booted into container image {img}");
crate::utils::notify_ready();
crate::utils::update_unit_status(&msg);
return Err(anyhow::Error::new(FatalError(msg)));
return Err(anyhow::Error::new(SystemInoperable(msg)));
}
Ok(status.into_release())
}
Expand Down
4 changes: 3 additions & 1 deletion src/rpm_ostree/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
mod cli_deploy;
mod cli_finalize;
mod cli_status;
pub use cli_status::{invoke_cli_status, parse_booted, parse_booted_updates_stream, FatalError};
pub use cli_status::{
invoke_cli_status, parse_booted, parse_booted_updates_stream, SystemInoperable,
};

mod actor;
pub use actor::{
Expand Down