• Angel Santiago's avatar
    proxy: Cleanly shutdown health checks on restart (#1524) · 59bf71c2
    Angel Santiago authored
    * Add a shutdown function and context to staticUpstream so that running goroutines can be cancelled. Add a GetShutdownFunc to Upstream interface to expose the shutdown function to the caddy Controller for performing it on restarts.
    
    * Make fakeUpstream implement new Upstream methods.
    
    Implement new Upstream method for fakeWSUpstream as well.
    
    * Rename GetShutdownFunc to Stop(). Add a waitgroup to the staticUpstream for controlling individual object's goroutines. Add the Stop function to OnRestart and OnShutdown. Add tests for checking to see if healthchecks continue hitting a backend server after stop has been called.
    
    * Go back to using a stop channel since the context adds no additional benefit.
    Only register stop function for onShutdown since it's called as part of restart.
    
    * Remove assignment to atomic value
    
    * Incrementing WaitGroup outside of goroutine to avoid race condition. Loading atomic values in test.
    
    * Linting: change counter to just use the default zero value instead of setting it
    
    * Clarify Stop method comments, add comments to stop channel and waitgroup and remove out of date comment about handling stopping the proxy. Stop the ticker when the stop signal is sent
    59bf71c2
upstream.go 9.99 KB