Commit Graph

321 Commits

Author SHA1 Message Date
Ville Vesilehto
3080ec0448 lint(errorlint): handle wrapped errors
Enable errorlint and preserve wrapped error chains so runtime checks
and tests classify failures correctly. This also makes Route53
surface insert failures instead of silently dropping them.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2026-04-25 11:57:32 +03:00
Peppi-Lotta
8c5ec14e31 Fix broken links (#8051)
Signed-off-by: peppi-lotta <peppi-lotta.saari@est.tech>
2026-04-16 20:31:32 +03:00
Ville Vesilehto
503c2d7ea3 fix(kubernetes): sanitize non-UTF-8 host in metrics (#7998) 2026-04-01 14:19:29 -07:00
Ville Vesilehto
2ba4340362 chore: bump golangci-lint to v2.11.4 (#7983) 2026-03-30 14:39:09 -07:00
Ville Vesilehto
6720959b8b lint(revive): fix unused-parameter violations (#7980) 2026-03-29 17:02:20 -07:00
Ville Vesilehto
867cd8fd6b lint(revive): fix indent-error-flow violations (#7977) 2026-03-29 17:01:22 -07:00
Syed Azeez
f582a01dc9 fix(kubernetes): record cluster_ip services in dns_programming_duration metric (#7951)
Signed-off-by: Azeez Syed <syedazeez337@gmail.com>
2026-03-24 05:29:28 -07:00
Ville Vesilehto
90a9739478 chore(lint): bump golangci-lint to v2.11.1 (#7905)
- Added nolint to plugin/auto/walk.go to avoid a symlink/TOCTOU
  warning, as it needs to follow symlink.
- Replaced a few flagged integer conversions with safe equivalents in
  cache hashing, reuseport socket setup, and TLS arg handling
- Preallocated response rule slices in plugin/rewrite/name.go
- Replaced WriteString(fmt.Sprintf/Sprintln(...)) with direct
  fmt.Fprint* calls
- Removed stale nolint directives from code and tests that are no
  longer needed

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2026-03-06 11:50:24 -08:00
Ville Vesilehto
191a783e46 chore(deps): k8s-io group to client-go v0.35.1 (#7868) 2026-02-17 10:13:22 -08:00
Ville Vesilehto
23774edfa4 fix(kubernetes): panic on empty ListenHosts (#7857) 2026-02-16 07:04:19 -08:00
Ville Vesilehto
b1080a2934 chore: bump Go version to 1.26.0 (#7856) 2026-02-16 04:26:18 -08:00
Henrik Gerdes
7f410524d0 docs: clarify kubernetes auth docs (#7831)
Signed-off-by: Henrik Gerdes <hegerdes@outlook.de>
2026-01-21 18:36:11 -08:00
Syed Azeez
7b38eb8625 plugin: fix gosec G115 integer overflow warnings (#7799)
Fix integer overflow conversion warnings (G115) by adding appropriate
suppressions where values are provably bounded.

Fixes: https://github.com/coredns/coredns/issues/7793

Changes:
- Updated 56 G115 annotations to use consistent // #nosec G115 format
- Added 2 //nolint:gosec suppressions for conditional expressions
- Removed G115 exclusion from golangci.yml (now explicitly handled per-line)

Suppressions justify why each conversion is safe (e.g., port numbers
are bounded 1-65535, DNS TTL limits, pool lengths, etc.)

Signed-off-by: Azeez Syed <syedazeez337@gmail.com>
2026-01-01 10:20:29 +02:00
pasteley
388cbc5187 plugin/kubernetes: rate limits to api server (#7771)
Signed-off-by: pasteley <ceasebeing@gmail.com>
2025-12-15 20:06:16 -08:00
Andrey Smirnov
604e1675cf fix: kubernetes plugin logging (#7727)
The plugin dropped the actual error message from the log, so the log
becomes completely useless.

Before:

```
[ERROR] plugin/kubernetes: error Failed to watch
```

After:

```
[ERROR] plugin/kubernetes: Failed to watch: failed to list *v1.Namespace: Get "https://10.96.0.1:443/api/v1/namespaces?limit=500&resourceVersion=0": tls: failed to parse certificate from server: x509: SAN dNSName is malformed
```

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
2025-11-27 19:46:04 +02:00
Ville Vesilehto
b72d267a29 chore(lint): bump to v2.5.0 and enable godoclint (#7632) 2025-10-23 10:01:57 -07:00
Ville Vesilehto
39abf5aeba chore(lint): modernize Go (#7536)
Use modern Go constructs through the modernize analyzer from the
golang.org/x/tools package.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-09-10 13:08:27 -07:00
Ville Vesilehto
d2e0e6a459 chore(docs): remove extra whitespace from readmes (#7532) 2025-09-09 14:30:27 -07:00
Ville Vesilehto
359632a2f4 lint: enable prealloc (#7493) 2025-09-01 18:05:15 -07:00
Guillaume Jacquet
1025a199e9 Properly create hostname from IPv6 (#7431)
Generate valid hostname from IPv6 when the address ends with `::`.

Signed-off-by: Guillaume Jacquet <guillaume.jacquet@gmail.com>
2025-08-04 16:53:40 -07:00
Dave Brown
ab74d3acf2 add args: startup_timeout for kubernetes plugin (#7068)
Signed-off-by: mangoyhuang <mangoyhuang@tencent.com>
Co-authored-by: mangoyhuang <mangoyhuang@tencent.com>
2025-06-11 11:22:07 -07:00
Matthieu MOREL
186e4a1dbb chore: enable early-return and superfluous-else from revive (#7129)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-05 10:10:58 +03:00
Ville Vesilehto
9f9aed31cf test: add t.Helper() calls to test helper functions (#7351) 2025-06-04 14:36:04 -07:00
Ville Vesilehto
b4abdcacf0 fix(kubernetes): multicluster DNS race condition (#7350) 2025-06-04 06:31:41 +03:00
Ville Vesilehto
8cac83dfb5 lint: enable wastedassign linter (#7340) 2025-06-01 16:30:41 -07:00
Ville Vesilehto
384fa3285e fix: missing intrange lint fix (#7333)
Missed in #7323

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-05-29 04:41:27 +03:00
Ville Vesilehto
60227bd8d2 perf(kubernetes): optimize AutoPath slice allocation (#7323)
Pre-allocate slice capacity in AutoPath to eliminate unnecessary
memory reallocations. This avoids slice growth when appending
search domains and sentinel value.

Benchmark shows significant performance improvement:
- Before: 538.6 ns/op, 560 B/op, 13 allocs/op
- After:  436.8 ns/op, 336 B/op, 11 allocs/op
- Result: 19% faster, 40% less memory, 15% fewer allocations

The optimization benefits Kubernetes clusters using autopath for
server-side search path completion.

Adds benchmark test to measure AutoPath performance.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-05-28 17:58:01 -07:00
Ville Vesilehto
19a6ae4983 lint: enable intrange linter (#7331)
Enable intrange linter to enforce modern Go range syntax over
traditional for loops, by converting:

for i := 0; i < n; i++

to:

for i := range n

Adding type conversions where needed for compatibility
with existing uint64 parameters.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-05-28 17:50:55 -07:00
Ville Vesilehto
7bd43af427 fix: loop variable capture and linter (#7328)
Enable copyloopvar linter and remove redundant variable
shadowing in Kubernetes plugin metadata handling. This pattern is
no longer needed in Go 1.22+ where loop variables are automatically
captured correctly in closures.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
2025-05-27 14:44:20 -07:00
Arthur Outhenin-Chalandre
5c71bd0b87 kubernetes: add multicluster support (#7266)
* kubernetes: add multicluster support

Add multicluster support via Multi-Cluster Services API (MCS-API) via a
new option `multiclusterZones` in the kubernetes plugin.

When some multicluster zones are passed to the kubernetes plugin, it
will start watching the ServiceImport objects and its associated
EndpointSlices.

Signed-off-by: Arthur Outhenin-Chalandre <arthur@cri.epita.fr>

* kubernetes: implement xfr support for multicluster zones

Signed-off-by: Arthur Outhenin-Chalandre <arthur@cri.epita.fr>

---------

Signed-off-by: Arthur Outhenin-Chalandre <arthur@cri.epita.fr>
2025-05-18 22:58:16 -07:00
Kevin Lyda
17eb2eed34 Prepare for the k8s api upgrade (#7293)
Don't explicitly set `RetryOnError` to `false`.  It won't exist in the
next version of the k8s api and it won't make a difference in this code
since the struct would default to that.

Signed-off-by: Kevin Lyda <kevin@lyda.ie>
2025-05-14 13:48:13 +02:00
Manuel Rüger
76ba39ffe9 chore: Upgrade to golangci-lint v2 (#7236)
Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2025-04-04 14:27:39 -04:00
Ben Kochie
a1cc54b719 Update for Go 1.24 (#7226)
* Update for Go 1.24

* Update Go build to 1.24.1.
* Update minimum Go version to 1.23.0.
* Bump golangci-lint version.

Signed-off-by: SuperQ <superq@gmail.com>

* Workaround confused golangci-lint error.

Signed-off-by: SuperQ <superq@gmail.com>

---------

Signed-off-by: SuperQ <superq@gmail.com>
2025-03-24 12:50:13 -04:00
momantech
1bb184aa09 chore: fix some comments (#7201)
Signed-off-by: momantech <cuimoman@qq.com>
2025-03-24 10:32:39 -04:00
Bartosz Borkowski
7c76d534d3 Fix handling of pods having DeletionTimestamp set (#7119) (#7131)
Signed-off-by: Bartosz Borkowski <bartebor@wp.pl>
Co-authored-by: Bartosz Borkowski <bartosz.borkowski@grupawp.pl>
2025-03-24 10:31:24 -04:00
Chris O'Haver
8eed5991f0 Update README.md (#7210) 2025-03-24 10:25:44 -04:00
Adrian Moisey
58d8999192 Revert "only create PTR records for endpoints with hostname defined (#6898)" (#7194)
This reverts commit f4f0d55dce.

Signed-off-by: Adrian Moisey <adrian@changeover.za.net>
2025-03-18 15:42:43 -04:00
Chris O'Haver
f4f0d55dce only create PTR records for endpoints with hostname defined (#6898)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2024-09-30 10:32:13 -04:00
Manuel Rüger
ebbbb453be kubernetes: Add useragent (#6484)
In kubernetes' audit logs you'll see:

"userAgent":"coredns/v0.0.0 (linux/amd64) kubernetes/$Format"

This change adds a userAgent to the requests made by CoreDNS against the kubernetes API:

"userAgent":"CoreDNS/v1.11.1 git_commit:ae2bbc29be1aaae0b3ded5d188968a6c97bb3144 (linux/amd64/go1.22)"

Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2024-08-26 16:45:39 -04:00
Ben Kochie
0d6e113f90 Enable Prometheus native histograms (#6524)
Add a NativeHistogramBucketFactor parameter to the use of
`NewHistogramVec` in order to enable use of Prometheus Native
Histograms.

This will store automatically computed sparse buckets in CoreDNS.
If a compatible Prometeus requests native histograms this data will
returned instead of the static buckets.

The default factor of 1.05 should provide high quality resolution data.

Signed-off-by: SuperQ <superq@gmail.com>
2024-03-11 16:09:09 -04:00
miles-to-go
92b7e658e3 add client labels to k8s plugin metadata (#6475)
Signed-off-by: Nolan Miles <nolanpmiles@gmail.com>
2024-03-07 14:34:09 -05:00
Zhizhen He
5de473da1c fix: remove unnecessary conversion (#6258)
Signed-off-by: Zhizhen He <hezhizhen.yi@gmail.com>
2023-08-14 15:14:09 +02:00
Zhizhen He
2fe5890d8b Fix typos (#6235)
* Fix typos and add todo to fix spelling of dnsutil.MaximumDefaulTTL

Signed-off-by: Zhizhen He <hezhizhen.yi@gmail.com>
2023-08-10 11:06:48 -04:00
rokkiter
6e1263d3d9 fix ports panic (#6179)
Signed-off-by: rokkiter <101091030+rokkiter@users.noreply.github.com>
2023-06-26 09:42:03 -04:00
Dan Wilson
5b5a6ac6ad plugin/kubernetes: filter ExternalName services from matching double subdomain wildcard (#6162)
remove double subdomain reference from review feedback



not subdoman

Signed-off-by: emaildanwilson <dan@controlplane.com>
Co-authored-by: emaildanwilson <dan@controlplane.com>
2023-06-19 08:42:17 -04:00
Chris O'Haver
06cd843918 plugin/kubernetes: Remove Endpoint and EndpointSlice v1beta Support (#6147)
* remove endpoint and endpointslicev1beta watch support

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* adjust readme

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* informer object changes

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

* remove unused funcs

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

---------

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2023-06-12 08:22:57 -07:00
Ondřej Benkovský
8c489bd400 replace reviewdog fully by golangci-lint (#6139)
Signed-off-by: Ondřej Benkovský <ondrej.benkovsky@jamf.com>
2023-06-09 18:08:23 +02:00
Chris O'Haver
6d3db023fe plugin/kubernetes: fix headless/endpoint query panics when endpoints are disabled (#6137)
* always create listers, so we dont panic

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>

---------

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2023-06-07 16:22:28 -04:00
Yashpal
1b95a6042d plugin/kubernetes: rename client-go metrics label "url" to "host" (#6040) 2023-04-25 20:26:57 +02:00
cui fliter
ee3999303d fix some comments (#6052)
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-04-25 11:25:07 -04:00