diff options
Diffstat (limited to 'tests/inst/src/rpmostree.rs')
-rw-r--r-- | tests/inst/src/rpmostree.rs | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/tests/inst/src/rpmostree.rs b/tests/inst/src/rpmostree.rs index fee97355..b579c4e6 100644 --- a/tests/inst/src/rpmostree.rs +++ b/tests/inst/src/rpmostree.rs @@ -1,7 +1,6 @@ -use anyhow::Result; +use anyhow::{Context, Result}; use serde_derive::Deserialize; -use serde_json; -use std::process::{Command, Stdio}; +use std::process::Command; #[derive(Deserialize)] #[serde(rename_all = "kebab-case")] @@ -25,9 +24,29 @@ pub(crate) struct Deployment { } pub(crate) fn query_status() -> Result<Status> { - let cmd = Command::new("rpm-ostree") - .args(&["status", "--json"]) - .stdout(Stdio::piped()) - .spawn()?; - Ok(serde_json::from_reader(cmd.stdout.unwrap())?) + // Retry on temporary activation failures, see + // https://github.com/coreos/rpm-ostree/issues/2531 + let pause = std::time::Duration::from_secs(1); + let mut retries = 0; + let cmd_res = loop { + retries += 1; + let res = Command::new("rpm-ostree") + .args(&["status", "--json"]) + .output() + .context("failed to spawn 'rpm-ostree status'")?; + + if res.status.success() || retries >= 10 { + break res; + } + std::thread::sleep(pause); + }; + + if !cmd_res.status.success() { + anyhow::bail!( + "running 'rpm-ostree status' failed: {}", + String::from_utf8_lossy(&cmd_res.stderr) + ); + } + + serde_json::from_slice(&cmd_res.stdout).context("failed to parse 'rpm-ostree status' output") } |