Skip to content

Added additional logs for downloading geoip databases #13599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion internal/nginx/maxmind.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ func DownloadGeoLite2DB(attempts int, period time.Duration) error {
attempts = minimumRetriesCount
}

klog.Infof("Starting GeoLite2 DB download (editions: %s, attempts: %d, interval: %s)",
MaxmindEditionIDs, attempts, period)

defaultRetry := wait.Backoff{
Steps: attempts,
Duration: period,
Expand All @@ -103,7 +106,14 @@ func DownloadGeoLite2DB(attempts int, period time.Duration) error {

lastErr = wait.ExponentialBackoff(defaultRetry, func() (bool, error) {
var dlError error

for _, dbName := range strings.Split(MaxmindEditionIDs, ",") {
dbName = strings.TrimSpace(dbName)
if dbName == "" {
continue
}

klog.V(2).Infof("Attempting to download GeoIP DB: %s", dbName)
dlError = downloadDatabase(dbName)
if dlError != nil {
break
Expand All @@ -112,6 +122,7 @@ func DownloadGeoLite2DB(attempts int, period time.Duration) error {

lastErr = dlError
if dlError == nil {
klog.Infof("GeoLite2 DBs downloaded successfully")
return true, nil
}

Expand All @@ -120,14 +131,21 @@ func DownloadGeoLite2DB(attempts int, period time.Duration) error {
if e, ok := e.Err.(*os.SyscallError); ok {
if e.Err == syscall.ECONNREFUSED {
retries++
klog.InfoS("download failed on attempt " + fmt.Sprint(retries))
klog.V(1).Infof("Download attempt %d failed: connection refused", retries)
return false, nil
}
}
}
}

klog.Errorf("GeoLite2 DB download failed: %v", dlError)
return true, nil
})

if lastErr != nil {
klog.Errorf("All attempts to download GeoLite2 DBs failed: %v", lastErr)
}

return lastErr
}

Expand Down