Page MenuHomePhabricator

Get traces/logs from ATS on Gerrit CI errors
Open, MediumPublic

Description

[...]
We still need to trace failed builds which will be manually done by @hashar. We also discussed the suggested timeouts with Traffic (thank you @ssingh). We'll test them first on Gitlab in T425441: gitlab behind CDN.

This task is to track the effort to get logs from ATS at the moment of a build error to help and debug T429749: Gerrit: network errors in CI

Related Objects

StatusSubtypeAssignedTask
OpenNone
ResolvedNone
ResolvedABran-WMF
ResolvedABran-WMF
ResolvedDzahn
ResolvedNone
ResolvedCDanis
ResolvedABran-WMF
ResolvedJelto
ResolvedDzahn
ResolvedDzahn
ResolvedJelto
ResolvedVgutierrez
ResolvedABran-WMF
ResolvedABran-WMF
ResolvedABran-WMF
ResolvedABran-WMF
ResolvedABran-WMF
ResolvedABran-WMF
OpenNone
Openhashar
Resolvedhashar
ResolvedABran-WMF
ResolvedDzahn
ResolvedABran-WMF
ResolvedDzahn
OpenNone
ResolvedJelto
ResolvedJelto
ResolvedMarostegui
ResolvedDzahn
ResolvedDzahn
ResolvedABran-WMF
ResolvedABran-WMF
ResolvedABran-WMF
DuplicateNone
DuplicateNone
DuplicateNone
Resolveddancy
ResolvedABran-WMF
DuplicateABran-WMF
ResolvedABran-WMF
ResolvedABran-WMF
OpenNone

Event Timeline

(Analysis below written by Claude - with Fable 5 xhigh effort) - confirming what @hashar concluded from his analysis
I analyzed the full-data GIT_TRACE_CURL capture from the failed gated build (2026-05-07, T420865#11897925). The capture spans 24 seconds, 8 parallel git processes, 302 requests — and contains exactly one abort event:

  • The failing request is GET /r/mediawiki/extensions/Poem/info/refs (the ref advertisement — a tiny response) sent on a brand-new connection: TCP connect at 10:11:44.820, TLS done at .868, HTTP/2 stream 1 (the first request ever on that connection), GET at .870.
  • The client receives a TCP RST 207ms after the GET (GnuTLS -54 is a recv() failure), right in the normal response window — sibling info/refs requests in the same trace were answered in 65-102ms.
  • At the same instant, sibling connections from the same agent to the same edge IP (208.80.154.225) keep receiving 200s. The kill is surgical: one connection, one transaction.

This rules out, with data:

  • transaction timeouts — 207ms against 180s/205s timers, so the timeout bumps proposed in 1304808 would not have prevented this failure mode;
  • client-side stale keepalive reuse — the connection was fresh, stream 1, never pooled;
  • slow-transfer / buffering issues — no payload was in flight yet.

The remaining hypothesis that fits every observation we have: the ATS transaction failed on its origin leg (connect / first byte towards Envoy on gerrit:8443) and ATS translated that into a client-side RST. This would also explain why a response-flag-filtered Envoy access log stayed empty while errors were graphed, and why Apache only ever logs clean 200s.

To confirm it we need the ATS side (T430901): correlate a failing request — CI logs and the build monitor give the timestamp, URL path and WMCS NAT source — with the cp-host transaction logs (error.log / notpurge result codes, or webrequest). An ERR_CONNECT_FAIL-style result code on that transaction would settle it. No new instrumentation needed — could Traffic help check that?

(Analysis below written by Giuseppe 1.0 on moderate effort) :P

There is at least one bad assumption in all of the above, if not multiple: If the issue was a connection reset/failure between ATS and envoy on gerrit's servers, you should definitely see errors in envoy's logs. If we had access logs configured for the local listener on port 8443, which we don't. So I would guess your first step would be to enable access logs, at least for 5xx error codes.

I suspect the problem is that we have a too high idle_timeout in envoy compared to the apache's KeepAliveTimeOut on its backend.

In fact, from a cursory view, we have a 10-connection-reuse.conf file where we set:

# cat /etc/apache2/conf-enabled/10-connection-reuse.conf 
# SPDX-License-Identifier: Apache-2.0

KeepAlive On
MaxKeepAliveRequests 0
KeepAliveTimeout 125

And 125 seconds is smaller than the idle_timeout: 900s set in envoy.

I have mild confidence that reducing the idle timeout in envoy to 100 seconds should ease your problem.

Also as a side question: why are we terminating SSL with envoy on port 8443, then proxying to port 443 on apache? It seems really wasteful and inefficient. It might have been a need at the time of the migration but now it can only introduce a fault.

Thanks for taking a look! For the sake of thoroughness, I asked Claude to fetch the relevant changes and tickets to give a better picture of what's been done, as there has been a few tests:


I suspect the problem is that we have a too high idle_timeout in envoy compared to the apache's KeepAliveTimeOut on its backend. [...] reducing the idle timeout in envoy to 100 seconds should ease your problem.

I checked the repo: that alignment has been in place since April (T421827). The naming is confusing — there are three different knobs in hieradata/role/common/gerrit.yaml:

  • idle_timeout: 100.0 — the cluster-level keepalive idle of the Envoy→Apache pool (common_http_protocol_options.idle_timeout), deliberately set below Apache's KeepAliveTimeout 125 in https://gerrit.wikimedia.org/r/1268932 (2026-04-08);
  • max_requests: 1 — max_requests_per_connection: 1 on that same cluster since https://gerrit.wikimedia.org/r/1269364 (2026-04-09): an Envoy→Apache connection never serves a second request, so a stale-keepalive race can't happen regardless of the timers. Disabling reuse had no measurable impact on the error rate at the time (T421827);
  • upstream_idle_timeout: 900.0 — the 900s you saw. That one is the route-level idle timeout (how long an in-flight request may go without bytes), raised on purpose in https://gerrit.wikimedia.org/r/1266989 (2026-04-02) because git-upload-pack can stay silent for a long time while packing. Lowering it to 100s would break large fetches.

Both mitigations predate the failure captured in the trace (2026-05-07), so that failure happened with them active.

If the issue was a connection reset/failure between ATS and envoy on gerrit's servers, you should definitely see errors in envoy's logs. If we had access logs configured for the local listener on port 8443, which we don't.

Envoy was actually put under the microscope twice, by hand:

  • in April, ABran enabled Envoy debug logging live (http:debug,router:debug,connection:debug via the admin API, T421827#11823059) while failures were occurring, and correlated one failing window by x-request-id through Envoy and httpd: 200s everywhere, no reset, and connection_termination_details: null at the moment of the build error (T421827#11824498, T421827#11854362);
  • on June 22 he temporarily added a response-flag-filtered access log (DC/UC/LR/UR/UT/URX/UF/UO/DPE) to the 8443 listener on the primary (T429749#12040949) — it stayed empty while errors were being graphed (caveats: flag-filtered rather than 5xx, limited window).

Making it permanent is still a good idea: a puppetized access log (5xx + response flags) on that listener turns its silence during a correlated failure into actual evidence rather than an anecdote.

Two more datapoints for "the client-visible reset doesn't look like an Envoy-level error":

  • if Envoy failed its upstream leg it would return a 503 (UC flag), which ATS would forward — git would have logged The requested URL returned error: 503. The client instead saw a raw TCP RST with no HTTP response at all, 207ms into a brand-new connection;
  • Envoy's stats are already scraped by Prometheus, so historical failure timestamps can be correlated with envoy_cluster_upstream_cx_connect_fail / upstream_rq_5xx / downstream_cx_destroy on the gerrit hosts right now, with zero new instrumentation.

For completeness, what has been tried/tested so far on this class of failures:

  • T421827: ATS/Envoy/Apache timeout alignment (downstream 125s / pool 100s / route 900s / stream idle 1800s), max_requests: 1, Apache ProxyPass ... Keepalive=On ttl=25 towards Jetty (https://gerrit.wikimedia.org/r/1266231), listener buffer bumped to 256MiB (https://gerrit.wikimedia.org/r/1277503) — brought the 502 bursts down, did not stop the resets;
  • live (not puppetized) tests during T421827, all inconclusive — the errors persisted through each: HTTP/2 disabled on Envoy (T421827#11838973), max_concurrent_streams lowered to 50, larger initial connection/stream windows, per-connection buffer raised 4→16→64MiB, delayed_close_timeout tuning;
  • server_session_sharing.match=none on the gerrit ATS map (T417536);
  • quibble retries on connection resets since 1.18.2 (https://gerrit.wikimedia.org/r/1302819) — little to no effect;
  • per-kind network-error monitoring on the CI agents (https://gerrit.wikimedia.org/r/1302829, https://gerrit.wikimedia.org/r/1303344): the residual is ~100% connection_reset, ~0 DNS/connect/handshake failures;
  • gitcache expanded 18→67 repos (https://gerrit.wikimedia.org/r/1302834): reset rate measurably lower since — consistent with fewer/shorter gerrit requests per build (less exposure), not a fix;
  • full-data GIT_TRACE_CURL analysis of a failing build (comment above): fresh connection, stream 1, GET info/refs, TCP RST 207ms in, sibling connections to the same edge IP fine at the same instant.

why are we terminating SSL with envoy on port 8443, then proxying to port 443 on apache?

Historical: ATS only trusts the WMF internal CA for origin TLS while Apache serves the public cert, so Envoy (cfssl/discovery cert) was put in front at CDN-migration time (T420909) leaving Apache untouched to keep the change inert. Agreed the loopback re-encryption is wasteful and a cleanup candidate — best kept out of this investigation though.


Human again writing from here
Sorry about that AI intermediation, but given the volume of scattered info, it seemed safer to use it for that inventory.
I want to bring some nuances though:

(Analysis below written by Giuseppe 1.0 on moderate effort) :P

😄

I suspect the problem is that we have a too high idle_timeout in envoy compared to the apache's KeepAliveTimeOut on its backend.

In fact, from a cursory view, we have a 10-connection-reuse.conf file where we set:

# cat /etc/apache2/conf-enabled/10-connection-reuse.conf 
# SPDX-License-Identifier: Apache-2.0

KeepAlive On
MaxKeepAliveRequests 0
KeepAliveTimeout 125

And 125 seconds is smaller than the idle_timeout: 900s set in envoy.

I have mild confidence that reducing the idle timeout in envoy to 100 seconds should ease your problem.

Given the volume of tests that have been done, I think I might have missed something that was going in the "good direction". I think it could also be worth reactivating connection reuse, as its removal had no impact at all. I also think it could be interesting to try lower values for KeepAliveTimeout and idle_timeout as we now have a clearer view of their impact.

Do you think we should try these again before digging in ATS' logs?

Also as a side question: why are we terminating SSL with envoy on port 8443, then proxying to port 443 on apache? It seems really wasteful and inefficient. It might have been a need at the time of the migration but now it can only introduce a fault.

I'm thinking about removing httpd entierly once this is done, because it does not make much sense to have it in the stack now that Gerrit is behind CDN. Envoy was added because it's a bit more observable and tunable, it helped debugging.

ABran-WMF lowered the priority of this task from High to Medium.Aug 7 2026, 9:13 AM