oauth2-proxy icon indicating copy to clipboard operation
oauth2-proxy copied to clipboard

feat: graceful shutdown to prevent 502 errors when oauth2-proxy is load balanced

Open adelsz opened this issue 7 months ago • 1 comments

This PR introduces a new shutdownDuration configuration variable which allows the proxy to shutdown gracefully.

After receiving a termination signal, proxy will keep serving traffic for shutdownDuration but will start returning a 503 error for its readiness /ready endpoint signaling to the load balancer to not send new traffic to it.

After shutdownDuration, proxy shuts down as usual.

Motivation and Context

Fixes https://github.com/oauth2-proxy/oauth2-proxy/issues/3066

How Has This Been Tested?

  1. Launch proxy
  2. Send SIGTERM
  3. Observe that proxy keeps serving traffic for shutdownDuration seconds
  4. While timeout hasn't elapsed /ready endpoint returns an error
  5. After timeout the proxy exits normally

Checklist:

  • [x] My change requires a change to the documentation or CHANGELOG.
  • [x] I have updated the documentation/CHANGELOG accordingly.
  • [x] I have created a feature (non-master) branch for my PR.
  • [ ] I have written tests for my code changes.

adelsz avatar May 13 '25 17:05 adelsz

Thanks for the review @tuunit and @dolmen. I have addressed your comments in the last commit.

adelsz avatar May 27 '25 18:05 adelsz