Skip to content

Commit

Permalink
error handling for non rpm-ostree system
Browse files Browse the repository at this point in the history
Signed-off-by: Sayan Paul <saypaul@redhat.com>
  • Loading branch information
say-paul committed Oct 18, 2023
1 parent 36c5385 commit d96a78b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,10 @@ jobs:
skip: "./docs/Gemfile.lock,./docs/_config.yml,./.github,./.git,./greenboot.spec,./dist"

fmt:
name: Cargo fmt
name: Cargo fmt
runs-on: ubuntu-latest
container: fedora:latest
steps:
- name: Install deps
run: |
dnf install -y cargo rustfmt
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
Expand Down
14 changes: 10 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl LogLevel {
enum Commands {
HealthCheck,
Rollback,
Poc,
PocRollback,
}

/// this runs the scripts in required.d and wanted.d
Expand Down Expand Up @@ -245,8 +245,14 @@ pub fn poc_rollback_policy(duration: u32) -> Result<()> {
let s = Command::new("rpm-ostree")
.arg("status")
.arg("--json")
.output()
.unwrap();
.output();
if s.is_err() {
bail!("Unable to invoke rpm-ostree");
}
let s = s.unwrap();
if s.status.code() != Some(0) {
bail!("Unable to invoke rpm-ostree");
}
let j: serde_json::Value = match str::from_utf8(&s.stdout[..]) {
Ok(v) => serde_json::from_str(v).unwrap(),
Err(_) => bail!("cannot_convert to json"),
Expand Down Expand Up @@ -277,7 +283,7 @@ fn main() -> Result<()> {
match cli.command {
Commands::HealthCheck => health_check(),
Commands::Rollback => trigger_rollback(),
Commands::Poc => poc_rollback_policy(1),
Commands::PocRollback => poc_rollback_policy(1),
}
}

Expand Down

0 comments on commit d96a78b

Please sign in to comment.