From 848920bd482de22196fad2f9ffc654c037e26ba6 Mon Sep 17 00:00:00 2001 From: Aviram Hassan Date: Wed, 6 Jul 2022 17:51:04 +0300 Subject: [PATCH] Fix fcntl m1 (#188) * - Fix `fcntl` error on macOS [#184](https://github.com/metalbear-co/mirrord/issues/184) by a workaround. * re-enable Python E2E tests --- CHANGELOG.md | 1 + mirrord-layer/src/sockets.rs | 9 +++++++++ tests/src/sanity.rs | 12 +++++------- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd5ac2ae4e1..581301859ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how ### Fixed - Support connections that start with tcp flags in addition to Syn (on macOS CI we saw CWR + NS) +- `fcntl` error on macOS [#184](https://github.com/metalbear-co/mirrord/issues/184) by a workaround. ## 2.3.1 diff --git a/mirrord-layer/src/sockets.rs b/mirrord-layer/src/sockets.rs index f4dc397931f..e326d59f3d3 100644 --- a/mirrord-layer/src/sockets.rs +++ b/mirrord-layer/src/sockets.rs @@ -521,6 +521,15 @@ fn fcntl(orig_fd: c_int, cmd: c_int, fcntl_fd: i32) -> c_int { fcntl_fd } +#[cfg(all(target_arch = "aarch64", target_os = "macos"))] +/// We have a different version for macOS as a workaround for https://github.com/metalbear-co/mirrord/issues/184 +unsafe extern "C" fn fcntl_detour(fd: c_int, cmd: c_int, mut arg: ...) -> c_int { + let arg = arg.arg::(); + let fcntl_fd = libc::fcntl(fd, cmd, arg); + fcntl(fd, cmd, fcntl_fd) +} + +#[cfg(not(all(target_arch = "aarch64", target_os = "macos")))] unsafe extern "C" fn fcntl_detour(fd: c_int, cmd: c_int, arg: ...) -> c_int { let fcntl_fd = libc::fcntl(fd, cmd, arg); fcntl(fd, cmd, fcntl_fd) diff --git a/tests/src/sanity.rs b/tests/src/sanity.rs index 92cfe2d4eef..0aceca0334c 100644 --- a/tests/src/sanity.rs +++ b/tests/src/sanity.rs @@ -67,8 +67,7 @@ mod tests { } enum Application { - // Comment back PythonHTTP after we solve - // PythonHTTP, + PythonHTTP, NodeHTTP, } @@ -158,7 +157,9 @@ mod tests { args: Option>, ) -> TestProcess { let process_cmd = match self { - // Application::Python => vec!["python3", "-u", "python-e2e/app.py"], + Application::PythonHTTP => { + vec!["python3", "-u", "python-e2e/app.py"] + } Application::NodeHTTP => vec!["node", "node-e2e/app.js"], }; run(process_cmd, pod_name, namespace, args).await @@ -485,10 +486,7 @@ mod tests { async fn test_mirror_http_traffic( #[future] service: EchoService, #[future] kube_client: Client, - #[values( - // Application::PythonHTTP, - Application::NodeHTTP)] - application: Application, + #[values(Application::PythonHTTP, Application::NodeHTTP)] application: Application, ) { let service = service.await; let kube_client = kube_client.await;