mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 20:24:31 +00:00
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:
parent
61a8eabf8e
commit
d74639d8c6
@ -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>;
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user