Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package geoipupdate for openSUSE:Factory checked in at 2021-04-23 17:50:49 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/geoipupdate (Old) and /work/SRC/openSUSE:Factory/.geoipupdate.new.12324 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "geoipupdate" Fri Apr 23 17:50:49 2021 rev:16 rq:888064 version:4.7.1 Changes: -------- --- /work/SRC/openSUSE:Factory/geoipupdate/geoipupdate.changes 2020-12-17 17:08:41.969934795 +0100 +++ /work/SRC/openSUSE:Factory/.geoipupdate.new.12324/geoipupdate.changes 2021-04-23 17:51:05.670842543 +0200 @@ -1,0 +2,13 @@ +Fri Apr 23 14:36:31 UTC 2021 - Paolo Stivanin <[email protected]> + +- Update to 4.7.1: + * In verbose mode, we now print a message before each HTTP request. + Previously we would not print anything for retried requests. + * Expected response errors no longer cause request retries. For example, we + no longer retry the download request if the database subscription has + lapsed. + * When running with GEOIPUPDATE_FREQUENCY set, the Docker image will now + stop when sent a SIGTERM instead of waiting for a SIGKILL. Pull request + by Maxence POULAIN. GitHub #135. + +------------------------------------------------------------------- Old: ---- geoipupdate-4.6.0.tar.gz New: ---- geoipupdate-4.7.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ geoipupdate.spec ++++++ --- /var/tmp/diff_new_pack.kfn4ck/_old 2021-04-23 17:51:06.326843671 +0200 +++ /var/tmp/diff_new_pack.kfn4ck/_new 2021-04-23 17:51:06.330843678 +0200 @@ -1,7 +1,7 @@ # # spec file for package geoipupdate # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,7 +18,7 @@ # Common info Name: geoipupdate -Version: 4.6.0 +Version: 4.7.1 Release: 0 Summary: GeoIP update client code License: Apache-2.0 OR MIT @@ -34,7 +34,7 @@ Patch0: disable-pandoc.patch %if 0%{?suse_version} >= 1500 # Build-time parameters -BuildRequires: go >= 1.11 +BuildRequires: go >= 1.13 # Manpage BuildRequires: perl%{?suse_version:-base} %endif @@ -53,6 +53,7 @@ %description legacy Script for updating data in GeoIP Legacy format. + # Preparation step (unpackung and patching if necessary) %prep %setup -q -a1 ++++++ _service ++++++ --- /var/tmp/diff_new_pack.kfn4ck/_old 2021-04-23 17:51:06.374843753 +0200 +++ /var/tmp/diff_new_pack.kfn4ck/_new 2021-04-23 17:51:06.378843760 +0200 @@ -2,7 +2,7 @@ <service name="tar_scm" mode="disabled"> <param name="scm">git</param> <param name="url">git://github.com/maxmind/geoipupdate</param> - <param name="revision">v4.6.0</param> + <param name="revision">v4.7.1</param> <param name="exclude">.git</param> <param name="versionformat">@PARENT_TAG@</param> <param name="changesgenerate">enable</param> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.kfn4ck/_old 2021-04-23 17:51:06.394843788 +0200 +++ /var/tmp/diff_new_pack.kfn4ck/_new 2021-04-23 17:51:06.398843795 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">git://github.com/maxmind/geoipupdate</param> - <param name="changesrevision">7b5009fa4cd889997783005cea56180b4b85974e</param> + <param name="changesrevision">8bb6d26f0b015d27a3470bfe1171c6c68ff4b106</param> </service> -</servicedata> +</servicedata> \ No newline at end of file ++++++ geoipupdate-4.6.0.tar.gz -> geoipupdate-4.7.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/geoipupdate-4.6.0/.github/dependabot.yml new/geoipupdate-4.7.1/.github/dependabot.yml --- old/geoipupdate-4.6.0/.github/dependabot.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/geoipupdate-4.7.1/.github/dependabot.yml 2021-04-19 20:20:49.000000000 +0200 @@ -0,0 +1,7 @@ +version: 2 +updates: +- package-ecosystem: gomod + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/geoipupdate-4.6.0/.github/workflows/codeql-analysis.yml new/geoipupdate-4.7.1/.github/workflows/codeql-analysis.yml --- old/geoipupdate-4.6.0/.github/workflows/codeql-analysis.yml 2020-12-14 17:54:50.000000000 +0100 +++ new/geoipupdate-4.7.1/.github/workflows/codeql-analysis.yml 2021-04-19 20:20:49.000000000 +0200 @@ -2,6 +2,8 @@ on: push: + branches-ignore: + - 'dependabot/**' pull_request: schedule: - cron: '0 11 * * 2' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/geoipupdate-4.6.0/.github/workflows/go.yml new/geoipupdate-4.7.1/.github/workflows/go.yml --- old/geoipupdate-4.6.0/.github/workflows/go.yml 2020-12-14 17:54:50.000000000 +0100 +++ new/geoipupdate-4.7.1/.github/workflows/go.yml 2021-04-19 20:20:49.000000000 +0200 @@ -11,9 +11,7 @@ build: strategy: matrix: - # We test back to 1.11 as we need to support old, EOL'd Go versions - # to build PPA packages for older versions of Ubuntu. - go-version: [1.11.x, 1.12.x, 1.13.x, 1.14.x, 1.15.x] + go-version: [1.13.x, 1.14.x, 1.15.x, 1.16.x] platform: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.platform }} name: "Build ${{ matrix.go-version }} test on ${{ matrix.platform }}" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/geoipupdate-4.6.0/.golangci.toml new/geoipupdate-4.7.1/.golangci.toml --- old/geoipupdate-4.6.0/.golangci.toml 2020-12-14 17:54:50.000000000 +0100 +++ new/geoipupdate-4.7.1/.golangci.toml 2021-04-19 20:20:49.000000000 +0200 @@ -9,6 +9,7 @@ "deadcode", "depguard", "errcheck", + "errorlint", "exhaustive", "exportloopref", "goconst", @@ -21,17 +22,19 @@ "govet", "ineffassign", "lll", - "maligned", + "makezero", "misspell", "nakedret", + "nilerr", "noctx", "nolintlint", - # https://github.com/golangci/golangci-lint/issues/287 - # "safesql", + "predeclared", + "revive", "sqlclosecheck", "staticcheck", "structcheck", "stylecheck", + "tparallel", "typecheck", "unconvert", "unparam", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/geoipupdate-4.6.0/.goreleaser.yml new/geoipupdate-4.7.1/.goreleaser.yml --- old/geoipupdate-4.6.0/.goreleaser.yml 2020-12-14 17:54:50.000000000 +0100 +++ new/geoipupdate-4.7.1/.goreleaser.yml 2021-04-19 20:20:49.000000000 +0200 @@ -27,12 +27,53 @@ - CGO_ENABLED=0 dockers: - image_templates: - - "maxmindinc/geoipupdate:{{ .Tag }}" - - "maxmindinc/geoipupdate:v{{ .Major }}" - - "maxmindinc/geoipupdate:v{{ .Major }}.{{ .Minor }}" - - "maxmindinc/geoipupdate:latest" + - "maxmindinc/geoipupdate:{{ .Tag }}-amd64" dockerfile: docker/Dockerfile + use_buildx: true + goarch: amd64 extra_files: - docker/entry.sh + build_flag_templates: + - "--platform=linux/amd64" + - image_templates: + - "maxmindinc/geoipupdate:{{ .Tag }}-arm64" + dockerfile: docker/Dockerfile + use_buildx: true + goarch: arm64 + extra_files: + - docker/entry.sh + build_flag_templates: + - "--platform=linux/arm64" + - image_templates: + - "maxmindinc/geoipupdate:{{ .Tag }}-arm-v6" + dockerfile: docker/Dockerfile + use_buildx: true + goarch: arm + goarm: 6 + extra_files: + - docker/entry.sh + build_flag_templates: + - "--platform=linux/arm/v6" +docker_manifests: + - name_template: "maxmindinc/geoipupdate:{{ .Tag }}" + image_templates: + - "maxmindinc/geoipupdate:{{ .Tag }}-amd64" + - "maxmindinc/geoipupdate:{{ .Tag }}-arm64" + - "maxmindinc/geoipupdate:{{ .Tag }}-arm-v6" + - name_template: "maxmindinc/geoipupdate:v{{ .Major }}" + image_templates: + - "maxmindinc/geoipupdate:{{ .Tag }}-amd64" + - "maxmindinc/geoipupdate:{{ .Tag }}-arm64" + - "maxmindinc/geoipupdate:{{ .Tag }}-arm-v6" + - name_template: "maxmindinc/geoipupdate:v{{ .Major }}.{{ .Minor }}" + image_templates: + - "maxmindinc/geoipupdate:{{ .Tag }}-amd64" + - "maxmindinc/geoipupdate:{{ .Tag }}-arm64" + - "maxmindinc/geoipupdate:{{ .Tag }}-arm-v6" + - name_template: "maxmindinc/geoipupdate:latest" + image_templates: + - "maxmindinc/geoipupdate:{{ .Tag }}-amd64" + - "maxmindinc/geoipupdate:{{ .Tag }}-arm64" + - "maxmindinc/geoipupdate:{{ .Tag }}-arm-v6" checksum: name_template: 'checksums-darwin-linux.txt' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/geoipupdate-4.6.0/CHANGELOG.md new/geoipupdate-4.7.1/CHANGELOG.md --- old/geoipupdate-4.6.0/CHANGELOG.md 2020-12-14 17:54:50.000000000 +0100 +++ new/geoipupdate-4.7.1/CHANGELOG.md 2021-04-19 20:20:49.000000000 +0200 @@ -1,5 +1,27 @@ # CHANGELOG +## 4.7.1 (2021-04-19) + +* The Alpine version used for the Docker image now tracks the `alpine:3` + tag rather than a specific point release. +* The `arm64` Docker images were not correctly generated in 4.7.0. This + release corrects the issue. +* This release provides an `arm/v6` Docker image. + +## 4.7.0 (2021-04-16) + +* Go 1.13 or greater is now required. +* In verbose mode, we now print a message before each HTTP request. + Previously we would not print anything for retried requests. +* Expected response errors no longer cause request retries. For example, we + no longer retry the download request if the database subscription has + lapsed. +* When running with `GEOIPUPDATE_FREQUENCY` set, the Docker image will now + stop when sent a SIGTERM instead of waiting for a SIGKILL. Pull request + by Maxence POULAIN. GitHub #135. +* Docker images are now provided for ARM64. Requested by allthesebugsv2. + GitHub #136. + ## 4.6.0 (2020-12-14) * Show version number in verbose output. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/geoipupdate-4.6.0/README.dev.md new/geoipupdate-4.7.1/README.dev.md --- old/geoipupdate-4.6.0/README.dev.md 2020-12-14 17:54:50.000000000 +0100 +++ new/geoipupdate-4.7.1/README.dev.md 2021-04-19 20:20:49.000000000 +0200 @@ -1,9 +1,13 @@ # Releasing * Make sure you have [`hub`](https://github.com/github/hub), - [`goreleaser`](https://goreleaser.com/), and rpmbuild installed. + [`goreleaser`](https://goreleaser.com/), rpmbuild, and pandoc installed. (rpmbuild is in the Ubuntu package `rpm`). * Set release date in `CHANGELOG.md` and commit it. +* Ensure you can run `docker` commands as your user (e.g., `docker + images`). +* Log in to your Docker Hub account (be sure to be in our organization): + `docker login`. * Run `GITHUB_TOKEN=<your token> ./dev-bin/release.sh`. For `goreleaser` you will need a token with the `repo` scope. You may create a token [here](https://github.com/settings/tokens/new). @@ -14,14 +18,33 @@ `git merge v4.1.0`. * Set up to release to launchpad. You can see some information about prerequisites for this - [here](https://github.com/maxmind/libmaxminddb/blob/master/README.dev.md). -* Ensure you have the `dh-golang` and `golang-any` packages installed. + [here](https://github.com/maxmind/libmaxminddb/blob/main/README.dev.md). +* Ensure you have the `dh-golang`, `golang-any`, `devscripts`, + `libfile-slurp-tiny-perl`, and `libdatetime-perl` packages installed. * Delete `dist` directory. * Check whether you need to update the `$DISTS` variable in `dev-bin/ppa-release.sh`. We should include all currently supported Ubuntu releases. * Run `dev-bin/ppa-release.sh` +Gotcha with PPA: + +* If you get an error from `dput` like `No host ppa:maxmind/ppa found in + config`, you can create a `~/.dput.cf` with content like so: + +``` +[maxmind] +fqdn = ppa.launchpad.net +method = ftp +incoming = ~maxmind/ubuntu/ppa/ +login = anonymous +allow_unsigned_uploads = 0 +``` + +Then you can run the same `dput` command but with `dput maxmind [...]` +instead of `dput ppa:maxmind/ppa [...]` (I'm not sure how to make the +matching work with the original command). + Finally release to Homebrew: * Go to https://github.com/Homebrew/homebrew-core/blob/master/Formula/geoipupdate.rb diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/geoipupdate-4.6.0/docker/Dockerfile new/geoipupdate-4.7.1/docker/Dockerfile --- old/geoipupdate-4.6.0/docker/Dockerfile 2020-12-14 17:54:50.000000000 +0100 +++ new/geoipupdate-4.7.1/docker/Dockerfile 2021-04-19 20:20:49.000000000 +0200 @@ -1,4 +1,4 @@ -FROM alpine:3.11.5 +FROM alpine:3 COPY geoipupdate /usr/bin/geoipupdate COPY docker/entry.sh /usr/bin/entry.sh diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/geoipupdate-4.6.0/docker/entry.sh new/geoipupdate-4.7.1/docker/entry.sh --- old/geoipupdate-4.6.0/docker/entry.sh 2020-12-14 17:54:50.000000000 +0100 +++ new/geoipupdate-4.7.1/docker/entry.sh 2021-04-19 20:20:49.000000000 +0200 @@ -2,6 +2,18 @@ set -e +# SIGTERM-handler +term_handler() { + if [ $pid -ne 0 ]; then + kill -SIGTERM "$pid" + wait "$pid" + fi + exit 143; # 128 + 15 -- SIGTERM +} + +trap 'kill ${!}; term_handler' SIGTERM + +pid=0 conf_file=/etc/GeoIP.conf database_dir=/usr/share/GeoIP flags= @@ -47,5 +59,7 @@ fi echo "# STATE: Sleeping for $GEOIPUPDATE_FREQUENCY hours" - sleep "$frequency" + sleep "$frequency" & + pid=$! + wait $! done diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/geoipupdate-4.6.0/go.mod new/geoipupdate-4.7.1/go.mod --- old/geoipupdate-4.6.0/go.mod 2020-12-14 17:54:50.000000000 +0100 +++ new/geoipupdate-4.7.1/go.mod 2021-04-19 20:20:49.000000000 +0200 @@ -1,6 +1,6 @@ module github.com/maxmind/geoipupdate/v4 -go 1.11 +go 1.13 require ( github.com/davecgh/go-spew v1.1.1 // indirect @@ -9,7 +9,7 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect github.com/pkg/errors v0.9.1 github.com/spf13/pflag v1.0.5 - github.com/stretchr/testify v1.6.1 + github.com/stretchr/testify v1.7.0 golang.org/x/sys v0.0.0-20201026173827-119d4633e4d1 // indirect gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b // indirect gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/geoipupdate-4.6.0/go.sum new/geoipupdate-4.7.1/go.sum --- old/geoipupdate-4.6.0/go.sum 2020-12-14 17:54:50.000000000 +0100 +++ new/geoipupdate-4.7.1/go.sum 2021-04-19 20:20:49.000000000 +0200 @@ -5,7 +5,6 @@ github.com/gofrs/flock v0.8.0 h1:MSdYClljsF3PbENUUEx85nkWfJSGfzYI9yEBZOJz6CY= github.com/gofrs/flock v0.8.0/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= @@ -17,16 +16,14 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= golang.org/x/sys v0.0.0-20201026173827-119d4633e4d1 h1:/DtoiOYKoQCcIFXQjz07RnWNPRCbqmSXSpgEzhC9ZHM= golang.org/x/sys v0.0.0-20201026173827-119d4633e4d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U= gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/geoipupdate-4.6.0/pkg/geoipupdate/database/http_reader.go new/geoipupdate-4.7.1/pkg/geoipupdate/database/http_reader.go --- old/geoipupdate-4.6.0/pkg/geoipupdate/database/http_reader.go 2020-12-14 17:54:50.000000000 +0100 +++ new/geoipupdate-4.7.1/pkg/geoipupdate/database/http_reader.go 2021-04-19 20:20:49.000000000 +0200 @@ -60,10 +60,6 @@ url.QueryEscape(destination.GetHash()), ) - if reader.verbose { - log.Printf("Performing update request to %s", updateURL) - } - var modified bool // It'd be nice to not use a temporary file here. However the Writer API does // not currently support multiple attempts to download the file (it assumes @@ -86,6 +82,10 @@ var modificationTime time.Time err = internal.RetryWithBackoff( func() error { + if reader.verbose { + log.Printf("Performing update request to %s", updateURL) + } + newMD5, modificationTime, modified, err = reader.download( updateURL, editionID, @@ -171,9 +171,16 @@ if response.StatusCode != http.StatusOK { buf, err := ioutil.ReadAll(io.LimitReader(response.Body, 256)) if err == nil { - return "", time.Time{}, false, errors.Errorf("unexpected HTTP status code: %s: %s", response.Status, buf) + err := internal.HTTPError{ + Body: string(buf), + StatusCode: response.StatusCode, + } + return "", time.Time{}, false, errors.Wrap(err, "unexpected HTTP status code") + } + err = internal.HTTPError{ + StatusCode: response.StatusCode, } - return "", time.Time{}, false, errors.Errorf("unexpected HTTP status code: %s", response.Status) + return "", time.Time{}, false, errors.Wrap(err, "unexpected HTTP status code") } gzReader, err := gzip.NewReader(response.Body) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/geoipupdate-4.6.0/pkg/geoipupdate/database/http_reader_test.go new/geoipupdate-4.7.1/pkg/geoipupdate/database/http_reader_test.go --- old/geoipupdate-4.6.0/pkg/geoipupdate/database/http_reader_test.go 2020-12-14 17:54:50.000000000 +0100 +++ new/geoipupdate-4.7.1/pkg/geoipupdate/database/http_reader_test.go 2021-04-19 20:20:49.000000000 +0200 @@ -73,7 +73,7 @@ DatabaseBefore: "database goes here", DatabaseAfter: "database goes here", DownloadStatus: http.StatusBadRequest, - Err: "unexpected HTTP status code: 400 Bad Request", + Err: "unexpected HTTP status code: received HTTP status code: 400", }, { Description: "Download request is missing X-Database-MD5", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/geoipupdate-4.6.0/pkg/geoipupdate/database/local_file_writer.go new/geoipupdate-4.7.1/pkg/geoipupdate/database/local_file_writer.go --- old/geoipupdate-4.6.0/pkg/geoipupdate/database/local_file_writer.go 2020-12-14 17:54:50.000000000 +0100 +++ new/geoipupdate-4.7.1/pkg/geoipupdate/database/local_file_writer.go 2021-04-19 20:20:49.000000000 +0200 @@ -97,7 +97,8 @@ func (writer *LocalFileDatabaseWriter) Close() error { err := writer.temporaryFile.Close() if err != nil { - if perr, ok := err.(*os.PathError); !ok || perr.Err != os.ErrClosed { + var perr *os.PathError + if !errors.As(err, &perr) || !errors.Is(perr.Err, os.ErrClosed) { return errors.Wrap(err, "error closing temporary file") } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/geoipupdate-4.6.0/pkg/geoipupdate/geoip_updater.go new/geoipupdate-4.7.1/pkg/geoipupdate/geoip_updater.go --- old/geoipupdate-4.6.0/pkg/geoipupdate/geoip_updater.go 2020-12-14 17:54:50.000000000 +0100 +++ new/geoipupdate-4.7.1/pkg/geoipupdate/geoip_updater.go 2021-04-19 20:20:49.000000000 +0200 @@ -39,13 +39,13 @@ url.QueryEscape(editionID), ) - if config.Verbose { - log.Printf("Performing get filename request to %s", maxMindURL) - } - var buf []byte err := internal.RetryWithBackoff( func() error { + if config.Verbose { + log.Printf("Performing get filename request to %s", maxMindURL) + } + req, err := http.NewRequest(http.MethodGet, maxMindURL, nil) // nolint: noctx if err != nil { return errors.Wrap(err, "error creating HTTP request") @@ -67,7 +67,11 @@ } if res.StatusCode != http.StatusOK { - return errors.Errorf("unexpected HTTP status code: %s: %s", res.Status, buf) + err := internal.HTTPError{ + Body: string(buf), + StatusCode: res.StatusCode, + } + return errors.Wrap(err, "unexpected HTTP status code") } if len(buf) == 0 { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/geoipupdate-4.6.0/pkg/geoipupdate/geoip_updater_test.go new/geoipupdate-4.7.1/pkg/geoipupdate/geoip_updater_test.go --- old/geoipupdate-4.6.0/pkg/geoipupdate/geoip_updater_test.go 2020-12-14 17:54:50.000000000 +0100 +++ new/geoipupdate-4.7.1/pkg/geoipupdate/geoip_updater_test.go 2021-04-19 20:20:49.000000000 +0200 @@ -29,7 +29,7 @@ { Description: "Get filename fails", FilenameStatus: http.StatusBadRequest, - ExpectedError: "unexpected HTTP status code: 400 Bad Request: ", + ExpectedError: "unexpected HTTP status code: received HTTP status code: 400: ", }, { Description: "Get filename is missing body", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/geoipupdate-4.6.0/pkg/geoipupdate/internal/errors.go new/geoipupdate-4.7.1/pkg/geoipupdate/internal/errors.go --- old/geoipupdate-4.6.0/pkg/geoipupdate/internal/errors.go 1970-01-01 01:00:00.000000000 +0100 +++ new/geoipupdate-4.7.1/pkg/geoipupdate/internal/errors.go 2021-04-19 20:20:49.000000000 +0200 @@ -0,0 +1,15 @@ +package internal + +import ( + "fmt" +) + +// HTTPError is an error from performing an HTTP request. +type HTTPError struct { + Body string + StatusCode int +} + +func (h HTTPError) Error() string { + return fmt.Sprintf("received HTTP status code: %d: %s", h.StatusCode, h.Body) +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/geoipupdate-4.6.0/pkg/geoipupdate/internal/retry.go new/geoipupdate-4.7.1/pkg/geoipupdate/internal/retry.go --- old/geoipupdate-4.6.0/pkg/geoipupdate/internal/retry.go 2020-12-14 17:54:50.000000000 +0100 +++ new/geoipupdate-4.7.1/pkg/geoipupdate/internal/retry.go 2021-04-19 20:20:49.000000000 +0200 @@ -3,6 +3,8 @@ import ( "time" + + "github.com/pkg/errors" ) // RetryWithBackoff calls the provided function repeatedly until it succeeds or @@ -19,6 +21,14 @@ return nil } + underlyingErr := errors.Cause(err) + var httpErr HTTPError + if errors.As(underlyingErr, &httpErr) && + httpErr.StatusCode >= 400 && + httpErr.StatusCode < 500 { + return err + } + currentDuration := time.Since(start) waitDuration := 200 * time.Millisecond * (1 << i) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/geoipupdate-4.6.0/pkg/geoipupdate/internal/retry_test.go new/geoipupdate-4.7.1/pkg/geoipupdate/internal/retry_test.go --- old/geoipupdate-4.6.0/pkg/geoipupdate/internal/retry_test.go 2020-12-14 17:54:50.000000000 +0100 +++ new/geoipupdate-4.7.1/pkg/geoipupdate/internal/retry_test.go 2021-04-19 20:20:49.000000000 +0200 @@ -1,11 +1,11 @@ package internal import ( + "net/http" "testing" "time" "github.com/pkg/errors" - "github.com/stretchr/testify/assert" ) @@ -39,3 +39,35 @@ assert.NoError(t, err) }) } + +func TestRetryDoesNotRetryHTTP4xx(t *testing.T) { + var n int + err := RetryWithBackoff( + func() error { + n++ + err := HTTPError{ + StatusCode: http.StatusBadRequest, + } + return errors.Wrap(err, "unexpected HTTP status") + }, + 6*time.Second, + ) + assert.Equal(t, 1, n) + assert.Error(t, err) +} + +func TestRetryDoesRetryHTTP5xx(t *testing.T) { + var n int + err := RetryWithBackoff( + func() error { + n++ + err := HTTPError{ + StatusCode: http.StatusInternalServerError, + } + return errors.Wrap(err, "unexpected HTTP status") + }, + 6*time.Second, + ) + assert.Equal(t, 5, n) + assert.Error(t, err) +} ++++++ vendor.tar.gz ++++++ /work/SRC/openSUSE:Factory/geoipupdate/vendor.tar.gz /work/SRC/openSUSE:Factory/.geoipupdate.new.12324/vendor.tar.gz differ: char 13, line 1
