Skip to content

Commit

Permalink
Fix fcntl m1 (#188)
Browse files Browse the repository at this point in the history
* - Fix `fcntl` error on macOS [#184](#184) by a workaround.

* re-enable Python E2E tests
  • Loading branch information
aviramha authored Jul 6, 2022
1 parent 8ab77c8 commit 848920b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions mirrord-layer/src/sockets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<usize>();
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)
Expand Down
12 changes: 5 additions & 7 deletions tests/src/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ mod tests {
}

enum Application {
// Comment back PythonHTTP after we solve
// PythonHTTP,
PythonHTTP,
NodeHTTP,
}

Expand Down Expand Up @@ -158,7 +157,9 @@ mod tests {
args: Option<Vec<&str>>,
) -> 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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 848920b

Please sign in to comment.