Skip to content

Commit cb3d713

Browse files
authored
Don't force-attach devinfo tree when detecting if system is a Gimlet (#2400)
1 parent 3faa9e7 commit cb3d713

File tree

1 file changed

+1
-21
lines changed
  • sled-agent/src/hardware/illumos

1 file changed

+1
-21
lines changed

sled-agent/src/hardware/illumos/mod.rs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,35 +43,15 @@ enum Error {
4343
const GIMLET_ROOT_NODE_NAME: &str = "Oxide,Gimlet";
4444

4545
/// Return true if the host system is an Oxide Gimlet.
46-
#[cfg(not(test))]
4746
pub fn is_gimlet() -> anyhow::Result<bool> {
48-
let mut device_info = DevInfo::new_force_load()?;
47+
let mut device_info = DevInfo::new()?;
4948
let mut node_walker = device_info.walk_node();
5049
let Some(root) = node_walker.next().transpose()? else {
5150
anyhow::bail!("No nodes in device tree");
5251
};
5352
Ok(root.node_name() == GIMLET_ROOT_NODE_NAME)
5453
}
5554

56-
/// Return true if the host system is an Oxide Gimlet.
57-
//
58-
// TODO-testing: This assumes we never test on real Gimlets. That's likely to be
59-
// a bad assumption in the long-term. For now, however, we catch permissions
60-
// errors and return `Ok(false)`, on the assumption that (1) either you're not a
61-
// Gimlet, so that's the correct answer or (2) if you are on a Gimlet, you are
62-
// root or have configured the right permissions anyway.
63-
#[cfg(test)]
64-
pub fn is_gimlet() -> anyhow::Result<bool> {
65-
let Ok(mut device_info) = DevInfo::new_force_load() else {
66-
return Ok(false);
67-
};
68-
let mut node_walker = device_info.walk_node();
69-
let Ok(Some(root)) = node_walker.next().transpose() else {
70-
return Ok(false);
71-
};
72-
Ok(root.node_name() == GIMLET_ROOT_NODE_NAME)
73-
}
74-
7555
// A snapshot of information about the underlying Tofino device
7656
#[derive(Copy, Clone)]
7757
struct TofinoSnapshot {

0 commit comments

Comments
 (0)