Skip to content

proxy: report backend outcomes for completed upgrades - #4438

Merged
MustafaSaber merged 2 commits into
zalando:cwfreezefrom
perfloop-oss:perfloop-pr-open-q16sz1cdvr
Nov 20, 2026
Merged

MustafaSaber merged 2 commits into
zalando:cwfreezefrom
perfloop-oss:perfloop-pr-open-q16sz1cdvr

Conversation

@perfloop-agent

Copy link
Copy Markdown
Contributor

A completed experimental protocol upgrade currently counts as a failed backend request. This can open the circuit breaker for a healthy backend and reject later requests with 503.

Return the backend outcome from the upgrade handler separately from the marker that says the response was already handled. Completed tunnels and fully forwarded non-5xx backend responses report success; dial failures, incomplete HTTP responses, and backend 5xx responses retain their failure accounting. Response writing and connection cleanup are unchanged. The route backend-error counter no longer counts completed upgrades or fully forwarded responses below 500 as errors; a 401 upgrade response also counts as success.

proxy/upgrade_breaker_test.go exchanges a WebSocket message, waits for handler completion, and then checks a healthy request using the same breaker key. The other cases cover a rejected upgrade, refused connections, server errors, an incomplete response, and resetting previous consecutive failures.

The focused Go proxy tests passed with the race detector, covering upgrade responses and audit logging, circuit-breaker states, retries, and error-response filters. Scoped vet, staticcheck, and formatting checks also passed.

This applies when ExperimentalUpgrade is enabled and a circuit breaker applies to the outgoing host. Active tunnels are accounted for when the upgrade handler returns.

Fixes #4437.

Case and evidence


Made by Perfloop. Human sponsor: Tomás Senart.

Signed-off-by: Perfloop Agent <[email protected]>
Signed-off-by: Tomás Senart <[email protected]>
A handled response is not necessarily a backend failure. Carry the outcome of the upgrade handler to circuit breaker and backend-error accounting while preserving handled-response and connection cleanup behavior.

Signed-off-by: Perfloop Agent <[email protected]>
Signed-off-by: Tomás Senart <[email protected]>
@szuecs

szuecs commented Nov 16, 2026

Copy link
Copy Markdown
Member

@perfloop-agent can you create the PR to cwfreeze instead of master branch?
We are for 2-3 weeks only able to merge it to cwfreeze.

@perfloop-agent
perfloop-agent changed the base branch from master to cwfreeze November 16, 2026 08:54
@perfloop-agent

Copy link
Copy Markdown
Contributor Author

@szuecs Done: the PR now targets cwfreeze. It matched master, so the commit is unchanged.

The pr-labels check needs one of its required labels, which I cannot set. bugfix fits this change, if you agree.

@szuecs szuecs added the bugfix Bug fixes and patches label Nov 16, 2026
@MustafaSaber
MustafaSaber merged commit e51bf67 into zalando:cwfreeze Nov 20, 2026
18 checks passed
szuecs pushed a commit that referenced this pull request Nov 24, 2026
A completed experimental protocol upgrade currently counts as a failed
backend request. This can open the circuit breaker for a healthy backend
and reject later requests with 503.

Return the backend outcome from the upgrade handler separately from the
marker that says the response was already handled. Completed tunnels and
fully forwarded non-5xx backend responses report success; dial failures,
incomplete HTTP responses, and backend 5xx responses retain their
failure accounting. Response writing and connection cleanup are
unchanged. The route backend-error counter no longer counts completed
upgrades or fully forwarded responses below 500 as errors; a 401 upgrade
response also counts as success.

`proxy/upgrade_breaker_test.go` exchanges a WebSocket message, waits for
handler completion, and then checks a healthy request using the same
breaker key. The other cases cover a rejected upgrade, refused
connections, server errors, an incomplete response, and resetting
previous consecutive failures.

The focused Go proxy tests passed with the race detector, covering
upgrade responses and audit logging, circuit-breaker states, retries,
and error-response filters. Scoped vet, staticcheck, and formatting
checks also passed.

This applies when `ExperimentalUpgrade` is enabled and a circuit breaker
applies to the outgoing host. Active tunnels are accounted for when the
upgrade handler returns.

Fixes #4437.

[Case and evidence](<https://app.perfloop.ai/t/oss/case_vq976y36j2>)

---

Made by [Perfloop](https://app.perfloop.ai). Human sponsor: [Tomás
Senart](https://github.com/tsenart).

---------

Signed-off-by: Perfloop Agent <[email protected]>
Signed-off-by: Tomás Senart <[email protected]>
szuecs pushed a commit that referenced this pull request Dec 1, 2026
A completed experimental protocol upgrade currently counts as a failed
backend request. This can open the circuit breaker for a healthy backend
and reject later requests with 503.

Return the backend outcome from the upgrade handler separately from the
marker that says the response was already handled. Completed tunnels and
fully forwarded non-5xx backend responses report success; dial failures,
incomplete HTTP responses, and backend 5xx responses retain their
failure accounting. Response writing and connection cleanup are
unchanged. The route backend-error counter no longer counts completed
upgrades or fully forwarded responses below 500 as errors; a 401 upgrade
response also counts as success.

`proxy/upgrade_breaker_test.go` exchanges a WebSocket message, waits for
handler completion, and then checks a healthy request using the same
breaker key. The other cases cover a rejected upgrade, refused
connections, server errors, an incomplete response, and resetting
previous consecutive failures.

The focused Go proxy tests passed with the race detector, covering
upgrade responses and audit logging, circuit-breaker states, retries,
and error-response filters. Scoped vet, staticcheck, and formatting
checks also passed.

This applies when `ExperimentalUpgrade` is enabled and a circuit breaker
applies to the outgoing host. Active tunnels are accounted for when the
upgrade handler returns.

Fixes #4437.

[Case and evidence](<https://app.perfloop.ai/t/oss/case_vq976y36j2>)

---

Made by [Perfloop](https://app.perfloop.ai). Human sponsor: [Tomás
Senart](https://github.com/tsenart).

---------

Signed-off-by: Perfloop Agent <[email protected]>
Signed-off-by: Tomás Senart <[email protected]>
Signed-off-by: Sandor Szücs <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Bug fixes and patches

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Completed experimental upgrades can open the backend circuit breaker

3 participants