Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

Fix lnetctl not found #2402

Merged
merged 1 commit into from
Nov 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions iml-agent/src/network_interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ use crate::{
agent_error::ImlAgentError, network_interface::parse as parse_interfaces,
network_interface_stats,
};
use iml_cmd::{CheckedCommandExt, Command};
use iml_cmd::{CheckedCommandExt, CmdError, Command};
use iml_wire_types::{LNet, NetworkInterface};
use std::io;

fn ip_addr_cmd() -> Command {
let mut cmd = Command::new("ip");
Expand Down Expand Up @@ -48,9 +49,19 @@ pub async fn get_interfaces() -> Result<Vec<NetworkInterface>, ImlAgentError> {
}

pub async fn get_lnet_data() -> Result<LNet, ImlAgentError> {
let output = get_lnet_data_cmd().checked_output().await?;
let r = get_lnet_data_cmd().checked_output().await;

let lnet_data = std::str::from_utf8(&output.stdout)?.trim();
let x = match r {
Ok(x) => Ok(x.stdout),
Err(CmdError::Io(ref err)) if err.kind() == io::ErrorKind::NotFound => {
tracing::debug!("lnetctl was not found. Will not send net data");
ip1981 marked this conversation as resolved.
Show resolved Hide resolved

Ok(vec![])
}
Err(e) => Err(e),
}?;

let lnet_data = std::str::from_utf8(&x)?.trim();

if lnet_data.is_empty() {
return Ok(LNet::default());
Expand Down