Skip to content

Commit

Permalink
Just exit normally when booted into a container
Browse files Browse the repository at this point in the history
The previous work resulted in an error, but let's just
exit with status zero because otherwise we end up tripping up
things like checks for failing units.

Anyone who has rebased into a container has very clearly
taken explicit control over the wheel and there's no
point in us erroring out.

Closes: coreos#859
  • Loading branch information
cgwalters committed Nov 3, 2023
1 parent a037a71 commit 8c3d5cc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
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

0 comments on commit 8c3d5cc

Please sign in to comment.