Move console to runc-shim
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
parent
115029bb63
commit
33d37c0c0d
|
|
@ -31,6 +31,7 @@ serde = { version = "1.0.133", features = ["derive"] }
|
|||
serde_json = "1.0.74"
|
||||
oci-spec = "0.6.0"
|
||||
crossbeam = "0.8.1"
|
||||
uuid = { version = "1.0.0", features = ["v4"] }
|
||||
|
||||
# Async dependencies
|
||||
async-trait = { workspace = true, optional = true }
|
||||
|
|
|
|||
|
|
@ -16,14 +16,12 @@
|
|||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use containerd_shim::{io_error, util::mkdir, Error, Result};
|
||||
use log::warn;
|
||||
use tokio::net::{UnixListener, UnixStream};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
util::{mkdir, xdg_runtime_dir},
|
||||
Error, Result,
|
||||
};
|
||||
use crate::common::xdg_runtime_dir;
|
||||
|
||||
pub struct ConsoleSocket {
|
||||
pub listener: UnixListener,
|
||||
|
|
@ -42,6 +42,7 @@ use crate::{
|
|||
common::{create_runc, has_shared_pid_namespace, ShimExecutor, GROUP_LABELS},
|
||||
};
|
||||
|
||||
mod console;
|
||||
mod container;
|
||||
mod runc;
|
||||
mod task;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ use async_trait::async_trait;
|
|||
use containerd_shim::{
|
||||
api::{CreateTaskRequest, ExecProcessRequest, Options, Status},
|
||||
asynchronous::{
|
||||
console::ConsoleSocket,
|
||||
monitor::{monitor_subscribe, monitor_unsubscribe, Subscription},
|
||||
processes::{ProcessLifecycle, ProcessTemplate},
|
||||
},
|
||||
|
|
@ -54,7 +53,10 @@ use tokio::{
|
|||
io::{AsyncBufReadExt, AsyncRead, AsyncReadExt, AsyncWrite, BufReader},
|
||||
};
|
||||
|
||||
use super::container::{ContainerFactory, ContainerTemplate, ProcessFactory};
|
||||
use super::{
|
||||
console::ConsoleSocket,
|
||||
container::{ContainerFactory, ContainerTemplate, ProcessFactory},
|
||||
};
|
||||
use crate::common::{
|
||||
check_kill_error, create_io, create_runc, get_spec_from_request, receive_socket, CreateConfig,
|
||||
Log, ProcessIO, ShimExecutor, INIT_PID_FILE, LOG_JSON_FILE,
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
use std::{io::IoSliceMut, ops::Deref, os::unix::io::RawFd, path::Path, sync::Arc};
|
||||
use std::{env, io::IoSliceMut, ops::Deref, os::unix::io::RawFd, path::Path, sync::Arc};
|
||||
|
||||
use containerd_shim::{
|
||||
api::{ExecProcessRequest, Options},
|
||||
|
|
@ -232,3 +232,10 @@ pub fn has_shared_pid_namespace(spec: &Spec) -> bool {
|
|||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a temp dir. If the environment variable "XDG_RUNTIME_DIR" is set, return its value.
|
||||
/// Otherwise if `std::env::temp_dir()` failed, return current dir or return the temp dir depended on OS.
|
||||
pub(crate) fn xdg_runtime_dir() -> String {
|
||||
env::var("XDG_RUNTIME_DIR")
|
||||
.unwrap_or_else(|_| env::temp_dir().to_str().unwrap_or(".").to_string())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,13 +19,11 @@ use std::{
|
|||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use containerd_shim::{io_error, util::mkdir, Error, Result};
|
||||
use log::warn;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
util::{mkdir, xdg_runtime_dir},
|
||||
Error, Result,
|
||||
};
|
||||
use crate::common::xdg_runtime_dir;
|
||||
|
||||
pub struct ConsoleSocket {
|
||||
pub listener: UnixListener,
|
||||
|
|
@ -31,7 +31,6 @@ use log::debug;
|
|||
use oci_spec::runtime::LinuxResources;
|
||||
use shim::{
|
||||
api::*,
|
||||
console::ConsoleSocket,
|
||||
error::{Error, Result},
|
||||
io::Stdio,
|
||||
io_error, ioctl_set_winsz, other, other_error,
|
||||
|
|
@ -41,6 +40,7 @@ use shim::{
|
|||
};
|
||||
use time::OffsetDateTime;
|
||||
|
||||
use super::console::ConsoleSocket;
|
||||
use crate::{
|
||||
common::{receive_socket, ProcessIO},
|
||||
synchronous::io::spawn_copy_for_tty,
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use std::sync::Arc;
|
|||
|
||||
use containerd_shim::ExitSignal;
|
||||
|
||||
mod console;
|
||||
mod container;
|
||||
mod io;
|
||||
mod runc;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ use oci_spec::runtime::LinuxResources;
|
|||
use runc::{Command, Spawner};
|
||||
use shim::{
|
||||
api::*,
|
||||
console::ConsoleSocket,
|
||||
error::{Error, Result},
|
||||
io::Stdio,
|
||||
monitor::{monitor_subscribe, wait_pid, Topic},
|
||||
|
|
@ -55,6 +54,7 @@ use shim::{
|
|||
};
|
||||
use time::OffsetDateTime;
|
||||
|
||||
use super::console::ConsoleSocket;
|
||||
use crate::{
|
||||
common,
|
||||
common::{
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ time = { version = "0.3.7", features = ["serde", "std"] }
|
|||
serde_json = "1.0.78"
|
||||
serde_derive = "1.0.136"
|
||||
serde = "1.0.136"
|
||||
uuid = { version = "1.0.0", features = ["v4"] }
|
||||
signal-hook = "0.3.13"
|
||||
oci-spec = "0.6.0"
|
||||
prctl = "1.0.0"
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@ use crate::{
|
|||
Config, StartOpts, SOCKET_FD, TTRPC_ADDRESS,
|
||||
};
|
||||
|
||||
pub mod console;
|
||||
pub mod monitor;
|
||||
pub mod processes;
|
||||
pub mod publisher;
|
||||
|
|
|
|||
|
|
@ -101,7 +101,6 @@ macro_rules! cfg_async {
|
|||
|
||||
cfg_not_async! {
|
||||
pub use crate::synchronous::*;
|
||||
pub use crate::synchronous::console;
|
||||
pub use crate::synchronous::publisher;
|
||||
pub use protos::shim::shim_ttrpc::Task;
|
||||
pub use protos::ttrpc::TtrpcContext;
|
||||
|
|
@ -109,7 +108,6 @@ cfg_not_async! {
|
|||
|
||||
cfg_async! {
|
||||
pub use crate::asynchronous::*;
|
||||
pub use crate::asynchronous::console;
|
||||
pub use crate::asynchronous::processes;
|
||||
pub use crate::asynchronous::publisher;
|
||||
pub use protos::shim_async::Task;
|
||||
|
|
|
|||
|
|
@ -73,8 +73,6 @@ pub mod monitor;
|
|||
pub mod publisher;
|
||||
pub mod util;
|
||||
|
||||
pub mod console;
|
||||
|
||||
/// Helper structure that wraps atomic bool to signal shim server when to shutdown the TTRPC server.
|
||||
///
|
||||
/// Shim implementations are responsible for calling [`Self::signal`].
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
*/
|
||||
|
||||
use std::{
|
||||
env,
|
||||
os::unix::io::RawFd,
|
||||
time::{SystemTime, UNIX_EPOCH},
|
||||
};
|
||||
|
|
@ -166,13 +165,6 @@ pub fn convert_to_any(obj: Box<dyn MessageDyn>) -> Result<Any> {
|
|||
Ok(any)
|
||||
}
|
||||
|
||||
/// Returns a temp dir. If the environment variable "XDG_RUNTIME_DIR" is set, return its value.
|
||||
/// Otherwise if `std::env::temp_dir()` failed, return current dir or return the temp dir depended on OS.
|
||||
pub(crate) fn xdg_runtime_dir() -> String {
|
||||
env::var("XDG_RUNTIME_DIR")
|
||||
.unwrap_or_else(|_| env::temp_dir().to_str().unwrap_or(".").to_string())
|
||||
}
|
||||
|
||||
pub trait IntoOption
|
||||
where
|
||||
Self: Sized,
|
||||
|
|
|
|||
Loading…
Reference in New Issue