From 5796d4af5712965fa09e926bd22de91c870d1971 Mon Sep 17 00:00:00 2001 From: Aviram Hassan Date: Thu, 11 Apr 2024 18:42:57 +0300 Subject: [PATCH] Fixed layer making process zombie by calling panic from hookerror (#2370) * Fixed layer making process zombie by calling panic from hookerror * sigkill --- changelog.d/+fix-panic.fixed.md | 1 + mirrord/layer/src/error.rs | 5 +++-- mirrord/layer/src/macros.rs | 5 ++--- 3 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 changelog.d/+fix-panic.fixed.md diff --git a/changelog.d/+fix-panic.fixed.md b/changelog.d/+fix-panic.fixed.md new file mode 100644 index 00000000000..b0dab95fcaa --- /dev/null +++ b/changelog.d/+fix-panic.fixed.md @@ -0,0 +1 @@ +Fixed layer making process zombie by calling panic from hookerror, also use `sigkill` instead of `sigterm` \ No newline at end of file diff --git a/mirrord/layer/src/error.rs b/mirrord/layer/src/error.rs index cefe234aca2..7d935ec0c0d 100644 --- a/mirrord/layer/src/error.rs +++ b/mirrord/layer/src/error.rs @@ -215,7 +215,7 @@ impl From for i64 { HookError::SocketUnsuportedIpv6 => { info!("{fail}") } - HookError::ProxyError(err) => { + HookError::ProxyError(ref err) => { graceful_exit!( "Proxy error, connectivity issue or a bug. \n\ You may report it to us on https://github.com/metalbear-co/mirrord/issues/new?assignees=&labels=bug&projects=&template=bug_report.yml \n{err}" @@ -263,7 +263,8 @@ impl From for i64 { err @ ResponseError::Forbidden { .. } => { graceful_exit!( "Stopping mirrord run. Please adjust your mirrord configuration.\n{err}" - ) + ); + libc::EINVAL } }, HookError::DNSNoName => libc::EFAULT, diff --git a/mirrord/layer/src/macros.rs b/mirrord/layer/src/macros.rs index f15f06f334d..cc4c17c38b0 100644 --- a/mirrord/layer/src/macros.rs +++ b/mirrord/layer/src/macros.rs @@ -183,10 +183,9 @@ macro_rules! graceful_exit { () => {{ nix::sys::signal::kill( nix::unistd::Pid::from_raw(std::process::id() as i32), - nix::sys::signal::Signal::SIGTERM, + nix::sys::signal::Signal::SIGKILL, ) - .expect("unable to graceful exit"); - panic!() + .expect("unable to graceful exit") }}; }