sozu icon indicating copy to clipboard operation
sozu copied to clipboard

Call to test an upcoming feature on MacOs

Open Wonshtrum opened this issue 2 years ago • 7 comments

Dear users of MacOs, @airscholar, @pims, @av-elier,

We would need your help on a Unix compatibility issue.

Sozu Http representation and parsers are undergoing a complete rewrite to use Kawa (a separate crate we write in parallel). It has also been an opportunity to revamp the access logs and add metrics, like server and client RTT (Round Trip Time, similar to ping).

RTT is extracted from kernel-specific internal structs. The Unix version is stable, but we haven't had the opportunity to test the Mac version. Dear users of MacOs, would you be so kind and test out this feature?

You would have to check out on the htx branch and run the following test:

git pull
git checkout htx
cargo test -- rtt --nocapture

If all goes well it should print the internal struct as well as the RTT extracted:

Some (
    TcpInfo {
        tcpi_state: 0,
        tcpi_snd_wscale: 0,
        tcpi_rcv_wscale: 0,
        __pad1: 0,
        tcpi_options: 0,
        tcpi_flags: 0,
        tcpi_rto: 0,
        tcpi_maxseg: 0,
        tcpi_snd_ssthresh: 0,
        tcpi_snd_cwnd: 0,
        tcpi_snd_wnd: 0,
        tcpi_snd_sbbytes: 0,
        tcpi_rcv_wnd: 0,
        tcpi_rttcur: 0,
        tcpi_srtt: 1709,
        tcpi_rttvar: 0,
        tcpi_tfo: 0,
        tcpi_txpackets: 0,
        tcpi_txbytes: 0,
        tcpi_txretransmitbytes: 0,
        tcpi_rxpackets: 0,
        tcpi_rxbytes: 0,
        tcpi_rxoutoforderbytes: 0,
        tcpi_txretransmitpackets: 0,
    }
)
rtt: 17ms

We would like the output you get, whether or not it looks like the above. We thank you a lot in advance.

Wonshtrum avatar Jun 05 '23 12:06 Wonshtrum

tim@laptop sozu % cargo test -- rtt --nocapture
   Compiling sozu-command-lib v0.14.3 (/Users/tim/code/rust/sozu/command)
   Compiling jemalloc-sys v0.5.3+5.3.0-patched
   Compiling async-net v1.7.0
   Compiling async-fs v1.6.0
   Compiling async-process v1.7.0
   Compiling anstyle-query v1.0.0
   Compiling anstyle v1.0.0
   Compiling colorchoice v1.0.0
   Compiling signal-hook v0.3.15
   Compiling dirs-next v2.0.0
   Compiling anstream v0.3.2
   Compiling hyper-rustls v0.24.0
   Compiling clap_lex v0.4.1
   Compiling strsim v0.10.0
   Compiling term v0.7.0
   Compiling clap_builder v4.2.7
   Compiling async-executor v1.5.1
   Compiling simple-mutex v1.1.5
   Compiling clap_derive v4.2.0
   Compiling paw-attributes v1.0.2
   Compiling unicode-width v0.1.10
   Compiling encode_unicode v1.0.0
   Compiling sozu v0.14.3 (/Users/tim/code/rust/sozu/bin)
   Compiling numtoa v0.1.0
   Compiling paw-raw v1.0.0
   Compiling paw v1.0.0
   Compiling sozu-lib v0.14.3 (/Users/tim/code/rust/sozu/lib)
   Compiling prettytable-rs v0.10.0
   Compiling termion v2.0.1
   Compiling async-dup v1.2.2
error[E0425]: cannot find value `SOL_TCP` in crate `libc`
   --> lib/src/socket.rs:483:50
    |
483 |         pub const OPT_LEVEL: libc::c_int = libc::SOL_TCP;
    |                                                  ^^^^^^^ not found in `libc`

warning: unused imports: `ErrorKind`, `Error`, `os::unix::io::AsRawFd`
 --> lib/src/metrics/writer.rs:4:16
  |
4 |     io::{self, Error, ErrorKind, Write},
  |                ^^^^^  ^^^^^^^^^
5 |     net::SocketAddr,
6 |     os::unix::io::AsRawFd,
  |     ^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused imports: `c_uint`, `c_void`, `iovec`, `msghdr`
 --> lib/src/metrics/writer.rs:9:12
  |
9 | use libc::{c_uint, c_void, iovec, msghdr};
  |            ^^^^^^  ^^^^^^  ^^^^^  ^^^^^^

   Compiling smol v1.3.0
   Compiling clap v4.2.7
For more information about this error, try `rustc --explain E0425`.
warning: `sozu-lib` (lib) generated 2 warnings
error: could not compile `sozu-lib` (lib) due to previous error; 2 warnings emitted
warning: build failed, waiting for other jobs to finish...
warning: `sozu-lib` (lib test) generated 2 warnings (2 duplicates)
error: could not compile `sozu-lib` (lib test) due to previous error; 2 warnings emitted

On a Apple M2 laptop running MacOS 12.6.6.

pims avatar Jun 05 '23 20:06 pims

error[E0425]: cannot find value `SOL_TCP` in crate `libc`
   --> lib/src/socket.rs:483:50
    |
483 |         pub const OPT_LEVEL: libc::c_int = libc::SOL_TCP;
    |                                                  ^^^^^^^ not found in `libc`

warning: unused imports: `ErrorKind`, `Error`, `os::unix::io::AsRawFd`
 --> lib/src/metrics/writer.rs:4:16
  |
4 |     io::{self, Error, ErrorKind, Write},
  |                ^^^^^  ^^^^^^^^^
5 |     net::SocketAddr,
6 |     os::unix::io::AsRawFd,
  |     ^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused imports: `c_uint`, `c_void`, `iovec`, `msghdr`
 --> lib/src/metrics/writer.rs:9:12
  |
9 | use libc::{c_uint, c_void, iovec, msghdr};
  |            ^^^^^^  ^^^^^^  ^^^^^  ^^^^^^

For more information about this error, try `rustc --explain E0425`.
warning: `sozu-lib` (lib) generated 2 warnings
error: could not compile `sozu-lib` (lib) due to previous error; 2 warnings emitted
warning: build failed, waiting for other jobs to finish...

On an Intel OSX 10.13.6

miton18 avatar Jun 06 '23 09:06 miton18

   Compiling autocfg v1.1.0
   Compiling libc v0.2.144
   Compiling cfg-if v1.0.0
   Compiling proc-macro2 v1.0.57
   Compiling unicode-ident v1.0.8
   Compiling quote v1.0.27
   Compiling memchr v2.5.0
   Compiling log v0.4.17
   Compiling syn v1.0.109
   .
   .
   .
   Compiling rustls-webpki v0.100.1
   Compiling webpki v0.22.0
   Compiling try-lock v0.2.4
   Compiling ascii v1.1.0
   Compiling chunked_transfer v1.4.1
   Compiling async-task v4.4.0
   Compiling webpki-roots v0.22.6
   Compiling tiny_http v0.12.0
   Compiling want v0.3.0
   Compiling tracing v0.1.37
   Compiling http-body v0.4.5
   Compiling quickcheck v1.0.3
   Compiling async-channel v1.8.0
   Compiling is-terminal v0.4.7
   Compiling sozu-lib v0.14.3 (/Users/airscholar/Dev/Projects/sozu/lib)
   Compiling utf8parse v0.2.1
   Compiling atomic-waker v1.1.1
   Compiling signal-hook v0.3.15
   Compiling ureq v2.6.2
   Compiling tower-service v0.3.2
   Compiling hyper v0.14.26
error[E0425]: cannot find value `SOL_TCP` in crate `libc`
   --> lib/src/socket.rs:483:50
    |
483 |         pub const OPT_LEVEL: libc::c_int = libc::SOL_TCP;
    |                                                  ^^^^^^^ not found in `libc`

warning: unused imports: `ErrorKind`, `Error`, `os::unix::io::AsRawFd`
 --> lib/src/metrics/writer.rs:4:16
  |
4 |     io::{self, Error, ErrorKind, Write},
  |                ^^^^^  ^^^^^^^^^
5 |     net::SocketAddr,
6 |     os::unix::io::AsRawFd,
  |     ^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused imports: `c_uint`, `c_void`, `iovec`, `msghdr`
 --> lib/src/metrics/writer.rs:9:12
  |
9 | use libc::{c_uint, c_void, iovec, msghdr};
  |            ^^^^^^  ^^^^^^  ^^^^^  ^^^^^^

   Compiling blocking v1.3.1
   Compiling anstyle-parse v0.2.0
   Compiling tokio-rustls v0.24.0
   Compiling webpki-roots v0.23.0
For more information about this error, try `rustc --explain E0425`.
   Compiling signal-hook-registry v1.4.1
warning: `sozu-lib` (lib) generated 2 warnings
error: could not compile `sozu-lib` due to previous error; 2 warnings emitted
warning: build failed, waiting for other jobs to finish...

Apple M1 OSX 13.4 (Ventura)

airscholar avatar Jun 06 '23 12:06 airscholar

Thanks a lot for your replies !

Keksoj avatar Jun 09 '23 13:06 Keksoj

Thanks a lot to you all! It's been a long time since we built Sozu on Mac, and we had more errors than expected. I checked the code and fixed some issues.

Would you be so kind to repeat the same test on the latest commit of the htx branch?

git pull
git checkout htx
cargo test -- rtt --nocapture

Wonshtrum avatar Jun 12 '23 07:06 Wonshtrum

tim@laptop sozu % cargo test -- rtt --nocapture | pbcopy
warning: unused imports: `ErrorKind`, `Error`, `os::unix::io::AsRawFd`
 --> lib/src/metrics/writer.rs:4:16
  |
4 |     io::{self, Error, ErrorKind, Write},
  |                ^^^^^  ^^^^^^^^^
5 |     net::SocketAddr,
6 |     os::unix::io::AsRawFd,
  |     ^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused imports: `c_uint`, `c_void`, `iovec`, `msghdr`
 --> lib/src/metrics/writer.rs:9:12
  |
9 | use libc::{c_uint, c_void, iovec, msghdr};
  |            ^^^^^^  ^^^^^^  ^^^^^  ^^^^^^

warning: `sozu-lib` (lib) generated 2 warnings (run `cargo fix --lib -p sozu-lib` to apply 2 suggestions)
   Compiling sozu-e2e v0.14.3 (/Users/tim/code/rust/sozu/e2e)
warning: unused import: `std::ffi::CString`
 --> bin/src/worker.rs:4:5
  |
4 | use std::ffi::CString;
  |     ^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused import: `std::iter::repeat`
 --> bin/src/worker.rs:6:5
  |
6 | use std::iter::repeat;
  |     ^^^^^^^^^^^^^^^^^

warning: unused import: `std::ptr::null_mut`
  --> bin/src/worker.rs:12:5
   |
12 | use std::ptr::null_mut;
   |     ^^^^^^^^^^^^^^^^^^

warning: unused import: `bail`
  --> bin/src/worker.rs:23:14
   |
23 | use anyhow::{bail, Context};
   |              ^^^^

warning: unused import: `PATH_MAX`
  --> bin/src/worker.rs:27:20
   |
27 | use libc::{c_char, PATH_MAX};
   |                    ^^^^^^^^

warning: unused import: `bail`
  --> bin/src/main.rs:57:14
   |
57 | use anyhow::{bail, Context};
   |              ^^^^

warning: `sozu` (bin "sozu" test) generated 6 warnings (run `cargo fix --bin "sozu" --tests` to apply 6 suggestions)
warning: `sozu-lib` (lib test) generated 2 warnings (2 duplicates)
error[E0277]: the trait bound `i32: From<u32>` is not satisfied
  --> e2e/src/mock/sync_backend.rs:51:46
   |
51 |             tv_usec: timeout.subsec_micros().into(),
   |                                              ^^^^ the trait `From<u32>` is not implemented for `i32`
   |
   = help: the following other types implement trait `From<T>`:
             <i32 as From<EventKind>>
             <i32 as From<ListenerType>>
             <i32 as From<LoadBalancingAlgorithms>>
             <i32 as From<LoadMetric>>
             <i32 as From<MetricsConfiguration>>
             <i32 as From<NonZeroI32>>
             <i32 as From<PathRuleKind>>
             <i32 as From<ProxyProtocolConfig>>
           and 16 others
   = note: required for `u32` to implement `Into<i32>`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `sozu-e2e` (lib) due to previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `sozu-e2e` (lib test) due to previous error

pims avatar Jun 12 '23 15:06 pims

We merged the htx branch in #904 , should we close this issue ? Or should we call MacOS users to redo this check on the main branch ?

git pull
cargo test -- rtt --nocapture

Keksoj avatar Sep 11 '23 14:09 Keksoj