createClientWithRetries should be revised
Pamir opened this issue · 2 comments
Pamir commented
Is your feature request related to a problem? Please describe.
Nginx + nginx prometheus exporter is not working in kubernets when you configure exporter as a sidecar.
Describe the solution you'd like
There should be an infinite number of retries to connect nginx.
Describe alternatives you've considered
when NGINX_RETRIES is 0, we can loop nginx connection retry mechanism nfinitely.
func createClientWithRetries(getClient func() (interface{}, error), retries uint, retryInterval time.Duration) (interface{}, error) {
var err error
var nginxClient interface{}
var i = 0
for ;; {
nginxClient, err = getClient()
if err == nil {
return nginxClient, nil
}
if i <= int(retries) {
log.Printf("Could not create Nginx Client. Retrying in %v...", retryInterval)
time.Sleep(retryInterval)
}else {
break
}
if retries != 0 {
i++
}
}
return nil, err
}
Additional context
If you are ok i can create a PR for this.
Aha! Link: https://nginx.aha.io/features/IC-292
brianehlert commented
If you are willing to create the PR, please do so.