mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
Fix/timeout errors (#1051)
* wip: Working with docker timeouts * fix: Make the fixes * chore: small fixes * chore: Remove not used 143 * chore: Put back
This commit is contained in:
49
appmgr/Cargo.lock
generated
49
appmgr/Cargo.lock
generated
@@ -308,7 +308,7 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_urlencoded",
|
"serde_urlencoded",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tokio 1.12.0",
|
"tokio 1.15.0",
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
"url",
|
"url",
|
||||||
"winapi",
|
"winapi",
|
||||||
@@ -905,7 +905,7 @@ dependencies = [
|
|||||||
"stderrlog",
|
"stderrlog",
|
||||||
"tar",
|
"tar",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tokio 1.12.0",
|
"tokio 1.15.0",
|
||||||
"tokio-compat-02",
|
"tokio-compat-02",
|
||||||
"tokio-stream",
|
"tokio-stream",
|
||||||
"tokio-tar",
|
"tokio-tar",
|
||||||
@@ -1251,7 +1251,7 @@ dependencies = [
|
|||||||
"http",
|
"http",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"slab",
|
"slab",
|
||||||
"tokio 1.12.0",
|
"tokio 1.15.0",
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
@@ -1381,7 +1381,7 @@ dependencies = [
|
|||||||
"itoa",
|
"itoa",
|
||||||
"pin-project-lite 0.2.7",
|
"pin-project-lite 0.2.7",
|
||||||
"socket2",
|
"socket2",
|
||||||
"tokio 1.12.0",
|
"tokio 1.15.0",
|
||||||
"tower-service",
|
"tower-service",
|
||||||
"tracing",
|
"tracing",
|
||||||
"want",
|
"want",
|
||||||
@@ -1396,7 +1396,7 @@ dependencies = [
|
|||||||
"bytes 1.1.0",
|
"bytes 1.1.0",
|
||||||
"hyper",
|
"hyper",
|
||||||
"native-tls",
|
"native-tls",
|
||||||
"tokio 1.12.0",
|
"tokio 1.15.0",
|
||||||
"tokio-native-tls",
|
"tokio-native-tls",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1412,7 +1412,7 @@ dependencies = [
|
|||||||
"hyper",
|
"hyper",
|
||||||
"log",
|
"log",
|
||||||
"sha-1",
|
"sha-1",
|
||||||
"tokio 1.12.0",
|
"tokio 1.15.0",
|
||||||
"tokio-tungstenite",
|
"tokio-tungstenite",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1426,7 +1426,7 @@ dependencies = [
|
|||||||
"hex",
|
"hex",
|
||||||
"hyper",
|
"hyper",
|
||||||
"pin-project",
|
"pin-project",
|
||||||
"tokio 1.12.0",
|
"tokio 1.15.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2109,7 +2109,7 @@ dependencies = [
|
|||||||
"serde_cbor 0.11.1",
|
"serde_cbor 0.11.1",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tokio 1.12.0",
|
"tokio 1.15.0",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-error",
|
"tracing-error",
|
||||||
]
|
]
|
||||||
@@ -2601,7 +2601,7 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_urlencoded",
|
"serde_urlencoded",
|
||||||
"time 0.2.27",
|
"time 0.2.27",
|
||||||
"tokio 1.12.0",
|
"tokio 1.15.0",
|
||||||
"tokio-native-tls",
|
"tokio-native-tls",
|
||||||
"tokio-socks",
|
"tokio-socks",
|
||||||
"url",
|
"url",
|
||||||
@@ -2663,7 +2663,7 @@ dependencies = [
|
|||||||
"serde_cbor 0.11.2",
|
"serde_cbor 0.11.2",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tokio 1.12.0",
|
"tokio 1.15.0",
|
||||||
"url",
|
"url",
|
||||||
"yajrc",
|
"yajrc",
|
||||||
]
|
]
|
||||||
@@ -3180,7 +3180,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "0d1bd069de53442e7a320f525a6d4deb8bb0621ac7a55f7eccbc2b58b57f43d0"
|
checksum = "0d1bd069de53442e7a320f525a6d4deb8bb0621ac7a55f7eccbc2b58b57f43d0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"tokio 1.12.0",
|
"tokio 1.15.0",
|
||||||
"tokio-rustls",
|
"tokio-rustls",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -3533,11 +3533,10 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "1.12.0"
|
version = "1.15.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c2c2416fdedca8443ae44b4527de1ea633af61d8f7169ffa6e72c5b53d24efcc"
|
checksum = "fbbf1c778ec206785635ce8ad57fe52b3009ae9e0c9f574a728f3049d3e55838"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
|
||||||
"bytes 1.1.0",
|
"bytes 1.1.0",
|
||||||
"libc",
|
"libc",
|
||||||
"memchr",
|
"memchr",
|
||||||
@@ -3561,15 +3560,15 @@ dependencies = [
|
|||||||
"once_cell",
|
"once_cell",
|
||||||
"pin-project-lite 0.2.7",
|
"pin-project-lite 0.2.7",
|
||||||
"tokio 0.2.25",
|
"tokio 0.2.25",
|
||||||
"tokio 1.12.0",
|
"tokio 1.15.0",
|
||||||
"tokio-stream",
|
"tokio-stream",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio-macros"
|
name = "tokio-macros"
|
||||||
version = "1.4.1"
|
version = "1.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "154794c8f499c2619acd19e839294703e9e32e7630ef5f46ea80d4ef0fbee5eb"
|
checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.29",
|
"proc-macro2 1.0.29",
|
||||||
"quote 1.0.10",
|
"quote 1.0.10",
|
||||||
@@ -3583,7 +3582,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b"
|
checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"native-tls",
|
"native-tls",
|
||||||
"tokio 1.12.0",
|
"tokio 1.15.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3593,7 +3592,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6"
|
checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rustls",
|
"rustls",
|
||||||
"tokio 1.12.0",
|
"tokio 1.15.0",
|
||||||
"webpki",
|
"webpki",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -3606,7 +3605,7 @@ dependencies = [
|
|||||||
"either",
|
"either",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tokio 1.12.0",
|
"tokio 1.15.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3617,7 +3616,7 @@ checksum = "7b2f3f698253f03119ac0102beaa64f67a67e08074d03a22d18784104543727f"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"pin-project-lite 0.2.7",
|
"pin-project-lite 0.2.7",
|
||||||
"tokio 1.12.0",
|
"tokio 1.15.0",
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -3630,7 +3629,7 @@ dependencies = [
|
|||||||
"futures-core",
|
"futures-core",
|
||||||
"libc",
|
"libc",
|
||||||
"redox_syscall 0.2.10",
|
"redox_syscall 0.2.10",
|
||||||
"tokio 1.12.0",
|
"tokio 1.15.0",
|
||||||
"tokio-stream",
|
"tokio-stream",
|
||||||
"xattr",
|
"xattr",
|
||||||
]
|
]
|
||||||
@@ -3644,7 +3643,7 @@ dependencies = [
|
|||||||
"futures-util",
|
"futures-util",
|
||||||
"log",
|
"log",
|
||||||
"pin-project",
|
"pin-project",
|
||||||
"tokio 1.12.0",
|
"tokio 1.15.0",
|
||||||
"tungstenite",
|
"tungstenite",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -3659,7 +3658,7 @@ dependencies = [
|
|||||||
"futures-sink",
|
"futures-sink",
|
||||||
"log",
|
"log",
|
||||||
"pin-project-lite 0.2.7",
|
"pin-project-lite 0.2.7",
|
||||||
"tokio 1.12.0",
|
"tokio 1.15.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3688,7 +3687,7 @@ dependencies = [
|
|||||||
"serde_derive",
|
"serde_derive",
|
||||||
"sha2",
|
"sha2",
|
||||||
"sha3",
|
"sha3",
|
||||||
"tokio 1.12.0",
|
"tokio 1.15.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ sqlx = { version = "0.5", features = [
|
|||||||
stderrlog = "0.5.1"
|
stderrlog = "0.5.1"
|
||||||
tar = "0.4.37"
|
tar = "0.4.37"
|
||||||
thiserror = "1.0.29"
|
thiserror = "1.0.29"
|
||||||
tokio = { version = "1.12.0", features = ["full"] }
|
tokio = { version = "1.15.0", features = ["full"] }
|
||||||
tokio-compat-02 = "0.2.0"
|
tokio-compat-02 = "0.2.0"
|
||||||
tokio-stream = { version = "0.1.7", features = ["io-util", "sync"] }
|
tokio-stream = { version = "0.1.7", features = ["io-util", "sync"] }
|
||||||
tokio-tar = { git = "https://github.com/dr-bonez/tokio-tar.git" }
|
tokio-tar = { git = "https://github.com/dr-bonez/tokio-tar.git" }
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ use crate::util::Version;
|
|||||||
use crate::volume::{VolumeId, Volumes};
|
use crate::volume::{VolumeId, Volumes};
|
||||||
use crate::{Error, ResultExt, HOST_IP};
|
use crate::{Error, ResultExt, HOST_IP};
|
||||||
|
|
||||||
pub const NET_TLD: &'static str = "embassy";
|
pub const NET_TLD: &str = "embassy";
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
@@ -97,24 +97,7 @@ impl DockerAction {
|
|||||||
EitherFuture::Right(async move {
|
EitherFuture::Right(async move {
|
||||||
tokio::time::sleep(timeout).await;
|
tokio::time::sleep(timeout).await;
|
||||||
|
|
||||||
if let Some(id) = id {
|
Ok(())
|
||||||
signal::kill(Pid::from_raw(id as i32), nix::sys::signal::SIGTERM)
|
|
||||||
.with_kind(crate::ErrorKind::Docker)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
tokio::time::sleep(
|
|
||||||
self.sigterm_timeout
|
|
||||||
.map(|a| *a)
|
|
||||||
.unwrap_or(Duration::from_secs(30)),
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
|
|
||||||
if let Some(id) = id {
|
|
||||||
signal::kill(Pid::from_raw(id as i32), signal::SIGKILL)
|
|
||||||
.with_kind(crate::ErrorKind::Docker)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(futures::future::pending().await)
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
EitherFuture::Left(futures::future::pending::<Result<_, Error>>())
|
EitherFuture::Left(futures::future::pending::<Result<_, Error>>())
|
||||||
@@ -126,12 +109,29 @@ impl DockerAction {
|
|||||||
.await
|
.await
|
||||||
.with_kind(crate::ErrorKind::Docker)?;
|
.with_kind(crate::ErrorKind::Docker)?;
|
||||||
}
|
}
|
||||||
|
enum Race<T> {
|
||||||
|
Done(T),
|
||||||
|
TimedOut,
|
||||||
|
}
|
||||||
let res = tokio::select! {
|
let res = tokio::select! {
|
||||||
res = handle.wait_with_output() => res.with_kind(crate::ErrorKind::Docker)?,
|
res = handle.wait_with_output() => Race::Done(res.with_kind(crate::ErrorKind::Docker)?),
|
||||||
res = timeout_fut => res?,
|
res = timeout_fut => {
|
||||||
|
res?;
|
||||||
|
Race::TimedOut
|
||||||
|
},
|
||||||
|
};
|
||||||
|
let res = match res {
|
||||||
|
Race::Done(x) => x,
|
||||||
|
Race::TimedOut => {
|
||||||
|
if let Some(id) = id {
|
||||||
|
signal::kill(Pid::from_raw(id as i32), signal::SIGKILL)
|
||||||
|
.with_kind(crate::ErrorKind::Docker)?;
|
||||||
|
}
|
||||||
|
return Ok(Err((143, "Timed out. Retrying soon...".to_owned())));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
Ok(if res.status.success() || res.status.code() == Some(143) {
|
Ok(if res.status.success() || res.status.code() == Some(143) {
|
||||||
Ok(if let Some(format) = &self.io_format {
|
Ok(if let Some(format) = self.io_format {
|
||||||
match format.from_slice(&res.stdout) {
|
match format.from_slice(&res.stdout) {
|
||||||
Ok(a) => a,
|
Ok(a) => a,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
@@ -230,9 +230,9 @@ impl DockerAction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uncontainer_name<'a>(name: &'a str) -> Option<(PackageId<&'a str>, Option<&'a str>)> {
|
pub fn uncontainer_name(name: &str) -> Option<(PackageId<&str>, Option<&str>)> {
|
||||||
let (pre_tld, _) = name.split_once(".")?;
|
let (pre_tld, _) = name.split_once(".")?;
|
||||||
if pre_tld.contains("_") {
|
if pre_tld.contains('_') {
|
||||||
let (pkg, name) = name.split_once("_")?;
|
let (pkg, name) = name.split_once("_")?;
|
||||||
Some((Id::try_from(pkg).ok()?.into(), Some(name)))
|
Some((Id::try_from(pkg).ok()?.into(), Some(name)))
|
||||||
} else {
|
} else {
|
||||||
@@ -240,14 +240,14 @@ impl DockerAction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn docker_args<'a>(
|
async fn docker_args(
|
||||||
&'a self,
|
&self,
|
||||||
ctx: &RpcContext,
|
ctx: &RpcContext,
|
||||||
pkg_id: &PackageId,
|
pkg_id: &PackageId,
|
||||||
pkg_version: &Version,
|
pkg_version: &Version,
|
||||||
volumes: &Volumes,
|
volumes: &Volumes,
|
||||||
allow_inject: bool,
|
allow_inject: bool,
|
||||||
) -> Vec<Cow<'a, OsStr>> {
|
) -> Vec<Cow<'_, OsStr>> {
|
||||||
let mut res = Vec::with_capacity(
|
let mut res = Vec::with_capacity(
|
||||||
(2 * self.mounts.len()) // --mount <MOUNT_ARG>
|
(2 * self.mounts.len()) // --mount <MOUNT_ARG>
|
||||||
+ (2 * self.shm_size_mb.is_some() as usize) // --shm-size <SHM_SIZE>
|
+ (2 * self.shm_size_mb.is_some() as usize) // --shm-size <SHM_SIZE>
|
||||||
|
|||||||
Reference in New Issue
Block a user