diff --git a/src/tools/kata-ctl/src/ops/exec_ops.rs b/src/tools/kata-ctl/src/ops/exec_ops.rs index 51651188b9..f7ad0170cb 100644 --- a/src/tools/kata-ctl/src/ops/exec_ops.rs +++ b/src/tools/kata-ctl/src/ops/exec_ops.rs @@ -25,6 +25,8 @@ use vmm_sys_util::terminal::Terminal; use crate::args::ExecArguments; use shim_interface::shim_mgmt::{client::MgmtClient, AGENT_URL}; +use crate::utils::TIMEOUT; + const CMD_CONNECT: &str = "CONNECT"; const CMD_OK: &str = "OK"; const SCHEME_VSOCK: &str = "VSOCK"; @@ -32,7 +34,6 @@ const SCHEME_HYBRID_VSOCK: &str = "HVSOCK"; const EPOLL_EVENTS_LEN: usize = 16; const KATA_AGENT_VSOCK_TIMEOUT: u64 = 5; -const TIMEOUT: Duration = Duration::from_millis(2000); type Result = std::result::Result; diff --git a/src/tools/kata-ctl/src/ops/volume_ops.rs b/src/tools/kata-ctl/src/ops/volume_ops.rs index 94243743cf..a8c6818fe3 100644 --- a/src/tools/kata-ctl/src/ops/volume_ops.rs +++ b/src/tools/kata-ctl/src/ops/volume_ops.rs @@ -14,7 +14,7 @@ use kata_types::mount::{ use nix; use reqwest::StatusCode; use slog::{info, o}; -use std::{fs, time::Duration}; +use std::fs; use url; use agent::ResizeVolumeRequest; @@ -23,7 +23,8 @@ use shim_interface::shim_mgmt::{ DIRECT_VOLUME_PATH_KEY, DIRECT_VOLUME_RESIZE_URL, DIRECT_VOLUME_STATS_URL, }; -const TIMEOUT: Duration = Duration::from_millis(2000); +use crate::utils::TIMEOUT; + const CONTENT_TYPE_JSON: &str = "application/json"; macro_rules! sl { diff --git a/src/tools/kata-ctl/src/utils.rs b/src/tools/kata-ctl/src/utils.rs index 3b6e4daee0..f020a077e5 100644 --- a/src/tools/kata-ctl/src/utils.rs +++ b/src/tools/kata-ctl/src/utils.rs @@ -8,10 +8,12 @@ use crate::arch::arch_specific; use anyhow::{anyhow, Context, Result}; -use std::fs; +use std::{fs, time::Duration}; const NON_PRIV_USER: &str = "nobody"; +pub const TIMEOUT: Duration = Duration::from_millis(2000); + pub fn drop_privs() -> Result<()> { if nix::unistd::Uid::effective().is_root() { privdrop::PrivDrop::default()