Skip to content

Commit

Permalink
refactor(update-verifier): use orb-telemetry (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheButlah authored Dec 11, 2024
1 parent cb61a08 commit 84525c0
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 110 deletions.
36 changes: 17 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ hex-literal = "0.4.1"
jose-jwk = { version = "0.1.2", default-features = false }
libc = "0.2.153"
nix = { version = "0.28", default-features = false, features = [] }
prost = "0.13.4"
prost-build = "0.13.4"
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "stream"] }
ring = "0.16"
rustix = "0.38.37"
Expand Down
22 changes: 10 additions & 12 deletions update-verifier/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "orb-update-verifier"
version = "0.2.5"
version = "0.2.6"
description = """
Checks general system health and manages the slot and rootfs state of the Orb.
"""
Expand All @@ -18,22 +18,20 @@ rust-version.workspace = true
[dependencies]
can-rs.workspace = true
clap = { workspace = true, features = ["derive"] }
eyre = "0.6.8"
color-eyre.workspace = true
flume = "0.11.0"
jod-thread = "0.1.2"
libc = "0.2.137"
log = "0.4.18"
libc.workspace = true
orb-build-info.workspace = true
orb-messages.workspace = true
orb-slot-ctrl.workspace = true
orb-telemetry.workspace = true
polling = "2.2.0"
prost = "0.12.4"
prost = "0.12.6"
semver = "1.0.22"
tap = "1.0.1"
thiserror = "1.0.37"
tracing = "0.1.37"
tracing-journald.workspace = true
tracing-subscriber = { workspace = true, features = ["env-filter"] }
thiserror.workspace = true
tracing.workspace = true
zbus.workspace = true
zbus_systemd = { workspace = true, features = ["login1"] }

Expand All @@ -46,11 +44,11 @@ features = ["blocking", "json"]
orb-build-info = { workspace = true, features = ["build-script"] }

[dev-dependencies]
serde = { version = "1.0.147", features = ["derive"] }
# isahc = { version = "1.7", features = ["static-ssl"] }
httpmock = "0.7"
serde_json = "1.0.94"
prost-build = "0.12.4"
prost-build = "0.12.6"
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true

[package.metadata.orb]
unsupported_targets = [
Expand Down
11 changes: 5 additions & 6 deletions update-verifier/src/checks/mcu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use crate::checks::mcu::Device::{JetsonFromMain, JetsonFromSecurity};
use can_rs::stream::FrameStream;
use can_rs::CANFD_DATA_LEN;
use can_rs::{Frame, Id};
use eyre::WrapErr as _;
use log::warn;
use color_eyre::eyre::WrapErr as _;
use orb_messages::mcu_main as main_messages;
use orb_messages::mcu_sec as sec_messages;
use polling::{Event, Poller};
Expand All @@ -12,7 +11,7 @@ use std::{
time,
time::{Duration, SystemTime},
};
use tracing::{error, info};
use tracing::{error, info, warn};
use zbus::blocking::{Connection, Proxy};

const ARBITRARY_EVENT_KEY: usize = 1337;
Expand Down Expand Up @@ -339,7 +338,7 @@ impl super::Check for Mcu {
}
}

fn trigger_shutdown() -> eyre::Result<()> {
fn trigger_shutdown() -> color_eyre::eyre::Result<()> {
let connection = Connection::system()?;

let proxy: Proxy<'_> = zbus::blocking::proxy::Builder::new(&connection)
Expand Down Expand Up @@ -383,7 +382,7 @@ struct MessageStream {
// that `_thread` can drop without blocking.
ack_rx: flume::Receiver<Payload>,
msg_rx: flume::Receiver<Payload>,
_thread: jod_thread::JoinHandle<eyre::Result<()>>,
_thread: jod_thread::JoinHandle<color_eyre::eyre::Result<()>>,
}

impl MessageStream {
Expand Down Expand Up @@ -587,7 +586,7 @@ impl MessageStream {
remote: Device,
ack_tx: &flume::Sender<Payload>,
msg_tx: &flume::Sender<Payload>,
) -> eyre::Result<()> {
) -> color_eyre::eyre::Result<()> {
let poller = Poller::new().wrap_err("failed creating a new event poller")?;
poller
.add(stream, Event::readable(ARBITRARY_EVENT_KEY))
Expand Down
1 change: 1 addition & 0 deletions update-verifier/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use crate::checks::mcu::{Error, Mcu};
use crate::checks::Check;
use color_eyre::eyre;
use orb_build_info::{make_build_info, BuildInfo};
use orb_slot_ctrl::OrbSlotCtrl;
use tracing::{error, info, instrument, warn};
Expand Down
18 changes: 9 additions & 9 deletions update-verifier/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
mod telemetry;

use crate::telemetry::ExecContext;
use clap::{
builder::{styling::AnsiColor, Styles},
Parser,
};
use eyre::{self, Context};
use color_eyre::eyre::{self, Context};
use orb_slot_ctrl::{EfiVarDb, OrbSlotCtrl};
use orb_update_verifier::BUILD_INFO;
use tracing::{error, metadata::LevelFilter};
use tracing::error;

const SYSLOG_IDENTIFIER: &str = "worldcoin-update-verifier";

#[derive(Parser, Debug)]
#[clap(
Expand All @@ -26,14 +25,15 @@ fn clap_v3_styles() -> Styles {
.placeholder(AnsiColor::Green.on_default())
}

fn main() -> eyre::Result<()> {
fn main() -> color_eyre::Result<()> {
color_eyre::install()?;
orb_telemetry::TelemetryConfig::new()
.with_journald(SYSLOG_IDENTIFIER)
.init();
run().inspect_err(|error| error!(?error, "failed to run update-verifier"))
}

fn run() -> eyre::Result<()> {
telemetry::start::<ExecContext, _>(LevelFilter::INFO, std::io::stdout)
.wrap_err("update verifier encountered error while starting telemetry")?;

let _args = Cli::parse();

let efi_var_db = EfiVarDb::from_rootfs("/")?;
Expand Down
64 changes: 0 additions & 64 deletions update-verifier/src/telemetry.rs

This file was deleted.

0 comments on commit 84525c0

Please sign in to comment.