Commit 43049e6
Enable TLS-over-Rocket on mock_services with ALPN rs
Summary:
Closes the −9.9pp `RPC-AsyncIO` and −3.3pp `Encryption` CPU gaps observed in t31v5 BGM (vs prod `multifeed/aggregator_main`). The prior attempt in this stack omitted TLS because `folly::AsyncSSLSocket` + `RocketClientChannel::newChannel(...)` was failing the probe RPC with timeout; root cause was missing ALPN `"rs"` advertisement (required by ThriftServer with `setSSLPolicy::REQUIRED` to route the connection into the Rocket transport — without it, the server rejects the Rocket setup frame because the TLS-layer protocol selection picked the wrong path). This change adds the missing ALPN bits on both sides and matches the canonical pattern at `thrift/lib/cpp2/test/server/ThriftServerTest.cpp` `RocketOverSSLNoALPN` in the pinned fbthrift v2026.01.05.00.
Server (`MockServiceMain.cc`):
- New `--tls_cert` / `--tls_key` gflags. When both set, build a `wangle::SSLContextConfig`, set the cert/key, set `clientVerification = DO_NOT_REQUEST` (no peer cert needed), and **call `setNextProtocols({"rs"})`** so the server advertises Rocket-over-TLS via ALPN.
- `server->setSSLConfig(sslCfg)` + `server->setSSLPolicy(REQUIRED)`.
Client (`MockServicesClient.cc`):
- Read `MOCK_TLS` env var (LeafNodeRank uses gengetopt for CLI, rejects unknown flags, so env-var is the only viable injection path).
- When set: build a `folly::SSLContext` with `authenticate(false, false)` + `setVerificationOption(NO_VERIFY)` (self-signed cert) + **`setAdvertisedNextProtocols({"rs"})`**.
- Construct `folly::AsyncSSLSocket::UniquePtr` from that context, call `ssl_sock->connect(nullptr, addr)`, then `socket = std::move(ssl_sock)` so the UniquePtr conversion to `AsyncSocket::UniquePtr` preserves the SSL type. Hand to `RocketClientChannel::newChannel(...)`. AsyncSSLSocket buffers writes until the TLS handshake completes, so Rocket's setup frame goes out only after TLS is up.
Shell-script plumbing:
- `run-feedsim-multi.sh`: when `FEEDSIM_TLS=1`, pass `--tls_cert=${FEEDSIM_ROOT}/certs/example.crt --tls_key=...` to each mock_services instance. Fail fast if certs are missing.
- `run.sh`: when `FEEDSIM_TLS=1`, export `MOCK_TLS=1` so LeafNodeRank's child env inherits it.
Cert plumbing was already in place from the prior diff in this stack (install_feedsim.sh extracts `packages/common/certs.tar.gz` with `--strip-components=1` to `${FEEDSIM_ROOT}/certs/example.{crt,key}`).
Reviewed By: YifanYuan3
Differential Revision: D1073276061 parent 5215a55 commit 43049e6
4 files changed
Lines changed: 91 additions & 18 deletions
File tree
- packages/feedsim
- third_party/src/workloads/ranking
- mock_services
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | | - | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
168 | 182 | | |
169 | 183 | | |
170 | 184 | | |
| |||
173 | 187 | | |
174 | 188 | | |
175 | 189 | | |
| 190 | + | |
176 | 191 | | |
177 | 192 | | |
178 | 193 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
729 | 729 | | |
730 | 730 | | |
731 | 731 | | |
732 | | - | |
733 | | - | |
734 | | - | |
735 | | - | |
736 | | - | |
737 | | - | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
738 | 742 | | |
739 | 743 | | |
740 | 744 | | |
| |||
Lines changed: 31 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
36 | | - | |
37 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
38 | 42 | | |
39 | 43 | | |
40 | 44 | | |
| |||
118 | 122 | | |
119 | 123 | | |
120 | 124 | | |
| 125 | + | |
121 | 126 | | |
122 | | - | |
| 127 | + | |
123 | 128 | | |
124 | | - | |
125 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
126 | 152 | | |
127 | 153 | | |
128 | 154 | | |
| |||
Lines changed: 34 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
80 | 88 | | |
81 | 89 | | |
82 | 90 | | |
| |||
102 | 110 | | |
103 | 111 | | |
104 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
105 | 132 | | |
106 | 133 | | |
107 | 134 | | |
108 | 135 | | |
109 | | - | |
| 136 | + | |
| 137 | + | |
110 | 138 | | |
111 | 139 | | |
112 | 140 | | |
| |||
0 commit comments