Merge pull request #3285 from Shopify/probe-timeout

Add health-check-timeout as command line argument
This commit is contained in:
k8s-ci-robot 2018-10-25 06:31:32 -07:00 committed by GitHub
commit bc6f2e7016
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 4 deletions

View file

@ -38,7 +38,8 @@ func (n NGINXController) Name() string {
func (n *NGINXController) Check(_ *http.Request) error {
url := fmt.Sprintf("http://127.0.0.1:%v%v", n.cfg.ListenPorts.Status, ngxHealthPath)
statusCode, err := simpleGet(url)
timeout := n.cfg.HealthCheckTimeout
statusCode, err := simpleGet(url, timeout)
if err != nil {
return err
}
@ -48,7 +49,7 @@ func (n *NGINXController) Check(_ *http.Request) error {
}
url = fmt.Sprintf("http://127.0.0.1:%v/is-dynamic-lb-initialized", n.cfg.ListenPorts.Status)
statusCode, err = simpleGet(url)
statusCode, err = simpleGet(url, timeout)
if err != nil {
return err
}
@ -75,9 +76,9 @@ func (n *NGINXController) Check(_ *http.Request) error {
return err
}
func simpleGet(url string) (int, error) {
func simpleGet(url string, timeout time.Duration) (int, error) {
client := &http.Client{
Timeout: 10 * time.Second,
Timeout: timeout * time.Second,
Transport: &http.Transport{DisableKeepAlives: true},
}

View file

@ -61,6 +61,7 @@ type Configuration struct {
ForceNamespaceIsolation bool
DefaultHealthzURL string
HealthCheckTimeout time.Duration
DefaultSSLCertificate string
// +optional