Skip to content

Commit

Permalink
Merge pull request #66 from lucab/ups/rpm-ostree-deploy-metrics
Browse files Browse the repository at this point in the history
rpm_ostree/deploy: record metrics
  • Loading branch information
Luca Bruno authored Jul 10, 2019
2 parents fce46d6 + c06c356 commit ee6ff8a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/rpm_ostree/cli_deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,22 @@
use super::Release;
use failure::{bail, format_err, Fallible, ResultExt};
use prometheus::IntCounter;

lazy_static::lazy_static! {
static ref DEPLOY_ATTEMPTS: IntCounter = register_int_counter!(opts!(
"zincati_rpm_ostree_deploy_attempts_total",
"Total number of 'rpm-ostree deploy' attempts."
)).unwrap();
static ref DEPLOY_FAILURES: IntCounter = register_int_counter!(opts!(
"zincati_rpm_ostree_deploy_failures_total",
"Total number of 'rpm-ostree deploy' failures."
)).unwrap();
}

/// Deploy an upgrade (by checksum) and leave the new deployment locked.
pub fn deploy_locked(release: Release) -> Fallible<Release> {
DEPLOY_ATTEMPTS.inc();
let cmd = std::process::Command::new("rpm-ostree")
.arg("deploy")
.arg("--lock-finalization")
Expand All @@ -13,8 +26,9 @@ pub fn deploy_locked(release: Release) -> Fallible<Release> {
.with_context(|e| format_err!("failed to run rpm-ostree: {}", e))?;

if !cmd.status.success() {
DEPLOY_FAILURES.inc();
bail!(
"rpm-ostree upgrade failed:\n{}",
"rpm-ostree deploy failed:\n{}",
String::from_utf8_lossy(&cmd.stderr)
);
}
Expand Down

0 comments on commit ee6ff8a

Please sign in to comment.