hooks: Fix flaky test on MacOS
We have observed intermittent failures on `TestServer_PackObjectsHook_separateContext` on our MacOS runners. The error occurs ~10% of the time on MacOS, but has been completely unreproducible on Linux. This appears to be a long-standing issue with FreeBSD, dating back to 2005[0], which MacOS has inherited. Unix domain sockets that are closed after a partial read may return `ENOTCONN`, instead of `EPIPE` as seen on Linux. This is exactly the scenario performed in this test. Using the original reproduction script provided in the linked bug report, the `ENOTCONN` issue occurs ~10% of the time, matching Gitaly's failure rate. Given that this functionality works as expected on Linux and the OS itself is what is non-deterministic, the simplest fix is to accept either `EPIPE` or `ENOTCONN` when on MacOS. We are forced to check for the expected error string instead of `errors.Is(err, syscall.ENOTCONN)` as the syscall information is lost when returned over gRPC to the test program. [0] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=79138
Please register or sign in to comment