kata-ctl: provide the global TIMEOUT for creating MgmtClient

Several functions in kata-ctl need to establish a connection with runtime-rs through MgmtClient.
This PR provides a global TIMEOUT to avoid multiple definitions.

Fixes: #5017

Signed-off-by: Yuan-Zhuo <yuanzhuo0118@outlook.com>
This commit is contained in:
Yuan-Zhuo 2023-07-28 17:23:37 +08:00
parent 61a8eabf8e
commit d74639d8c6
3 changed files with 8 additions and 4 deletions

View File

@ -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<T> = std::result::Result<T, Error>;

View File

@ -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 {

View File

@ -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()