Skip to content
Snippets Groups Projects
  1. Apr 11, 2018
  2. Apr 10, 2018
  3. Apr 06, 2018
  4. Apr 05, 2018
  5. Apr 04, 2018
  6. Apr 03, 2018
  7. Apr 02, 2018
  8. Mar 31, 2018
  9. Mar 29, 2018
  10. Mar 28, 2018
  11. Mar 27, 2018
  12. Mar 26, 2018
  13. Mar 24, 2018
    • Alex Ellis (VMware)'s avatar
      Add feature for graceful shutdown of HTTP server · de2c74fc
      Alex Ellis (VMware) authored
      If the watchdog is sent SIGTERM from an external process then it
      should stop accepting new connections and attempt to finish the
      work in progress. This change makes use of the new ability in Go
      1.9 and onwards to cancel a HTTP server gracefully.
      
      The write_timeout duration is used as a grace period to allow all
      in-flight requests to complete. The pattern is taken directly from
      the offical example in the Golang documentation. [1]
      
      Further tuning and testing may be needed for Windows containers which
      have a different set of signals for closing work. This change aims
      to cover the majority use-case for Linux containers.
      
      The HTTP health-check is also invalidated by creating an and
      expression with the existing lock file.
      
      Tested with Kubernetes by deploying a custom watchdog and the
      fprocess of `env`. Log message was observed when scaling down and
      connections stopped being accepted on terminating replica.
      
      Also corrects some typos from previous PR.
      
      [1] https://golang.org/pkg/net/http/#Server.Shutdown
      
      
      
      Signed-off-by: default avatarAlex Ellis (VMware) <alexellis2@gmail.com>
      de2c74fc
Loading