ocurrent/obuilder

The FreeBSD sandbox can't access its local network when not in (network host) mode

kit-ty-kate opened this issue · 4 comments

I'm seeing issues such as this one:

#=== ERROR while compiling shuttle_http.0.11.0 ================================#
# context              2.1.5 | freebsd/x86_64 | ocaml-base-compiler.4.14.1 | pinned(https://git.sr.ht/~soni/shuttle_http/archive/0.11.0.tar.gz)
# path                 /usr/home/opam/.opam/4.14.1/.opam-switch/build/shuttle_http.0.11.0
# command              /usr/home/opam/.opam/4.14.1/bin/dune build -p shuttle_http -j 15 @install @runtest
# exit-code            1
# env-file             /usr/home/opam/.opam/log/shuttle_http-53998-ef21c7.env
# output-file          /usr/home/opam/.opam/log/shuttle_http-53998-ef21c7.out
### output ###
# File "http/test/test_http.ml", line 1, characters 0-0:
# /usr/local/bin/git --no-pager diff --no-index --color=always -u _build/default/http/test/test_http.ml _build/default/http/test/test_http.ml.corrected
# diff --git a/_build/default/http/test/test_http.ml b/_build/default/http/test/test_http.ml.corrected
# index 0ea1623..c11486a 100644
# --- a/_build/default/http/test/test_http.ml
# +++ b/_build/default/http/test/test_http.ml.corrected
# @@ -29,7 +29,29 @@ let%expect_test "Simple http endpoint" =
#        let%map () =
#          Helper.send_request_and_log_response r w test_post_req_with_fixed_body
#        in
# -      [%expect {| "HTTP/1.1 200 \r\nContent-Length: 11\r\n\r\nHello World" |}]))
# +      [%expect.unreachable]))
# +[@@expect.uncaught_exn {|
# +  (* CR expect_test_collector: This test expectation appears to contain a backtrace.
# +     This is strongly discouraged as backtraces are fragile.
# +     Please change this test to not include a backtrace. *)
# +
# +  (monitor.ml.Error
# +    (Unix.Unix_error "Protocol not supported" socket
# +      "((domain PF_INET) (kind SOCK_STREAM) (protocol 0) (close_on_exec (true)))")
# +    ("Raised at Core_unix.improve in file \"core_unix/src/core_unix.ml\", line 46, characters 4-43"
# +      "Called from Core_unix.socket in file \"core_unix/src/core_unix.ml\" (inlined), line 2521, characters 13-39"
# +      "Called from Async_unix__Unix_syscalls.Socket.create in file \"src/unix_syscalls.ml\", line 815, characters 6-144"
# +      "Called from Async_unix__Tcp.Server.Socket_creator.create.(fun) in file \"src/tcp.ml\", line 555, characters 28-85"
# +      "Called from Async_unix__Tcp.Server.Socket_creator.aux_bind_and_listen_maybe_retry' in file \"src/tcp.ml\", line 591, characters 19-37"
# +      "Called from Async_unix__Tcp.Server.create_sock_inet_internal in file \"src/tcp.ml\", line 667, characters 6-183"
# +      "Called from Shuttle_http__Server.run_inet in file \"http/src/server.ml\", line 338, characters 4-529"
# +      "Called from Test_shuttle_http__Helper.with_server in file \"http/test/helper.ml\", line 29, characters 4-261"
# +      "Called from Async_kernel__Monitor.Exported_for_scheduler.schedule'.upon_work_fill_i in file \"src/monitor.ml\", line 293, characters 42-51"
# +      "Called from Async_kernel__Job_queue.run_jobs in file \"src/job_queue.ml\", line 180, characters 6-47"
# +      "Caught by monitor block_on_async"))
# +  Raised at Base__Result.ok_exn in file "src/result.ml" (inlined), line 251, characters 17-26
# +  Called from Async_unix__Thread_safe.block_on_async_exn in file "src/thread_safe.ml", line 168, characters 29-63
# +  Called from Expect_test_collector.Make.Instance_io.exec in file "collector/expect_test_collector.ml", line 234, characters 12-19 |}]
#  ;;
#  
#  let%expect_test "Simple http endpoint with http client" =

Where the local network operation returns Protocol not supported

The cause appears to be that blocks without the statement (network host) do not have any network stack.

Added an isolated interface lo0 with IP 127.0.0.1/8 to jails without (network host) in this commit. This resolves the issue in the examples that there have seen so far.

A new solution was found to avoid sharing the same local network between different jobs on the same machine: mtelvers@2d30bde

#174 includes the isolated interface fix.