-
Notifications
You must be signed in to change notification settings - Fork 2.4k
plugin/geoip: Upgrade the geoip2-golang dependency to v2 #7732
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
Conversation
|
@case Thank you for your contribution, I will have a full look during the week and come back with feedback. |
51687c6 to
d56e8a0
Compare
This PR add a deprecation noticed for geoip plugin's upcoming behavior change of 0. Please see PR coredns#7732 for details. Signed-off-by: Yong Tang <[email protected]>
This PR add a deprecation noticed for geoip plugin's upcoming behavior change of 0. Please see PR coredns#7732 for details. Signed-off-by: Yong Tang <[email protected]>
plugin/geoip/README.md
Outdated
|
|
||
| ## Notable changes | ||
|
|
||
| - In CoreDNS **vFIXME**, released **2025-12-FIXME-release-date**, the `geoip` plugin was upgraded to use [`oschwald/geoip2-golang/v2`](https://github.com/oschwald/geoip2-golang/blob/main/MIGRATION.md), the Go library that reads and parses [`.mmdb`](https://maxmind.github.io/MaxMind-DB/) databases. It has a small, but possibly-breaking change, where the `Location.Latitude` and `Location.Longitude` structs changed from value types to pointers (`float64` → `*float64`). In `oschwald/geoip2-golang` v1, missing coordinates returned "0" (which is a [valid location](https://en.wikipedia.org/wiki/Null_Island)), and in v2 they now return an empty string "". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@case based on https://github.com/coredns/coredns/pull/7740/files look like this change will finally be in version 1.13.2, can you update this README text?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing, this is done.
| github.com/prometheus/client_model v0.6.2 | ||
| github.com/prometheus/common v0.67.4 | ||
| github.com/quic-go/quic-go v0.57.0 | ||
| github.com/stretchr/testify v1.11.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this direct dependency being added here? At first glance I do not see testify being directly used anywhere in this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that too, according to go mod graph | grep testify it's a transitive dependency of github.com/oschwald/geoip2-golang/v2 and github.com/oschwald/maxminddb-golang/v2
A bunch of other deps use it as well, but v1.11.1 appears to now be the MVS result - https://go.dev/ref/mod#minimal-version-selection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you resolve conflicts on go.mod?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go.mod conflict is resolved.
Signed-off-by: Eric Case <[email protected]>
d56e8a0 to
e8aad77
Compare
snebel29
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Signed-off-by: Eric Case <[email protected]>
6691767 to
66c49c4
Compare
|
Thanks again for your help with this PR, @snebel29! 🙏 |
|
Thanks for your contributions @case ! |
This PR add a deprecation noticed for geoip plugin's upcoming behavior change of 0. Please see PR #7732 for details. Signed-off-by: Yong Tang <[email protected]>
1. Why is this pull request needed and what does it do?
While working on #7730, I noticed that the GeoIP plugin is using v1 of the oschwald/geoip2-golang library, which recently bumped to v2. (The v2 beta series started on 2025-06-22, and shipped to v2.0.0 on 2025-10-19)
Notable changes in v2, from the
geoip2-golangreadme:I followed the v1 -> v2 migration guide; here are a few notes from the updates:
plugin/geoip/city.go:map[string]stringto the typed struct with language fieldsIsoCoderenamed toISOCodefloat64to*float64to distinguish "value is 0.0" from "value not present in database"plugin/geoip/geoip.go:netip.ParseAddrmakes errors explicitplugin/geoip/setup_test.go:netip.Addris a value type, needsIsValid()instead of anilchecknetip.Addr{}(zero value) doesn't cause an error from the geoip2 library - it simply returns empty data.2. Which issues (if any) are related?
No, I went ahead and just created this PR instead of filing an issue. Happy to file one if needed.
3. Which documentation changes (if any) need to be made?
None needed.
4. Does this introduce a backward incompatible change or deprecation?
No