66 Commits

Author SHA1 Message Date
Kubernetes Prow Robot
d12fae55d0 Merge pull request #131001 from Chulong-Li/winstats-contextual-logging
Migrate pkg/kubelet/winstats to contextual logging
2025-07-24 17:58:26 -07:00
Kubernetes Prow Robot
9eb462ef4a Merge pull request #131306 from Chulong-Li/volumemanager-contextual-logging
Migrate pkg/kubelet/volumemanager to contextual logging
2025-07-24 10:50:27 -07:00
Chulong Li
bf98e45afb Migrate pkg/kubelet/volumemanager to contextual logging
Remove context.TODO and context.Background

Fix linter error in volume_manager_test

Fix QF1008: Could remove embedded field "ObjectMeta" from selector

Remove the extra code change

Remove the extra change

Update the NewTestContext
2025-07-24 21:20:12 +08:00
Chulong Li
f626e847e7 Migrate pkg/kubelet/winstats to contextual logging
Update the order of imports to follow the standard convention

Quick update on import order for cadvisor_windows.go

Update the hack files

Update contextual logging in Test_convertWinApiToCadvisorApi
2025-07-22 20:44:53 +08:00
zhangzhifei16
911df655d3 chore: migrate kubelet lifecycle to contextual logging. 2025-07-22 10:14:42 +08:00
Kubernetes Prow Robot
ba35c0613d Merge pull request #132427 from soma00333/kuberuntime-contextual-logging-1
feat(kubelet): migrate kuberuntime to contextual logging
2025-07-21 05:50:36 -07:00
Swati Sehgal
b8758ac31b node: mm-mgr: migrate to contextual logging
Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
2025-07-20 21:50:58 +01:00
soma00333
ab839c93ff feat(kubelet): migrate kuberuntime to contextual logging 2025-07-20 09:47:50 +09:00
soma00333
7ddb042626 feat(cmd/kubelet): support structured and contextual logging 2025-07-19 17:10:37 +09:00
Ed Bartosh
4bc2ad6eea migrate pkg/kubelet/preemption to contextual logging 2025-07-17 10:16:03 +03:00
Ed Bartosh
b96e3cac74 migrate pkg/kubelet/pod to contextual logging 2025-07-17 10:16:03 +03:00
Ed Bartosh
0cb31bc407 migrate pkg/kubelet/nodeshutdown to contextual logging 2025-07-17 10:16:03 +03:00
Ed Bartosh
75ccd69bab migrate pkg/kubelet/kubeletconfig to contextual logging 2025-07-17 10:16:03 +03:00
Ed Bartosh
7dad9e2af6 migrate pkg/kubelet/apis to contextual logging 2025-07-17 10:15:58 +03:00
Kubernetes Prow Robot
9a50e30636 Merge pull request #132668 from dims/fix-todos-from-sorted-features-original-pr
Fix todos from sorted features golangci-lint plugin PR
2025-07-09 13:15:26 -07:00
Patrick Ohly
b22ffdb48f golangci-lint: exclude naming convention check for swagger docs
This started to show up now as linter hints at the start of the 1.34 cycle in
all PRs which modify the API. We don't want to enforce that convention in that
generated code, so suppressing it.
2025-07-06 16:54:04 +02:00
Davanum Srinivas
1514568ddf rename sortedfeatures -> sorted
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2025-07-01 22:12:26 -04:00
Davanum Srinivas
f2d8b7ec2c Add linter to report on unsorted feature gates
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2025-06-27 11:05:13 -04:00
Kubernetes Prow Robot
3e39d1074f Merge pull request #132221 from dims/new-cmp-diff-impl
New implementation for `Diff` (drop in replacement for `cmp.Diff`)
2025-06-16 18:02:58 -07:00
Davanum Srinivas
03afe6471b Add a replacement for cmp.Diff using json+go-difflib
Co-authored-by: Jordan Liggitt <jordan@liggitt.net>
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2025-06-16 17:10:42 -04:00
Pierre Gimalac
40c718864b chore(apiserver): avoid using html template which disables dce 2025-06-13 15:28:55 +02:00
Stephen Kitt
d1bddfd779 Forbid github.com/pkg/errors in k/k
kubeadm has replaced pkg/errors with an internal implementation, which
means that pkg/errors can be marked as unwanted (once a final
straggler is replaced).

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2025-06-05 18:03:56 +03:00
Stephen Kitt
a6e2268994 Ensure github.com/pkg/errors is used only in kubeadm
Now that all other uses have been removed, this configures depguard to
ensure that new ones aren't added outside kubeadm.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2025-06-02 14:29:38 +02:00
Joel Speed
2f50d0a510 Add kube-api-linter plugin to golangci-lint 2025-05-16 16:04:15 +01:00
Patrick Ohly
2ea4b1aba6 golangci-lint: don't warn about conversion and defaulting functions
The linter suppression got removed in the migration to golangci-lint v2 because
it wasn't triggered for existing code, but as seen in a PR which adds a
conversion package the suppression is still needed.

Furthermore, we also want to suppress for unexported, manually written
conversion and defaulting functions because those follow the same Kubernetes
naming convention.
2025-05-05 13:00:08 +02:00
Patrick Ohly
5d9a2f30f2 golangci-lint: finish migration to v2
This finishes the work started in
https://github.com/kubernetes/kubernetes/pull/131113.

Changes:
- Remove TODOs for things that we don't have plans to fix.
- Add issue for older TODO.
- Reorganize and remove suppression rules so that the base check
  has no unused rules.
- Document warn-unused, but don't enable it.
- Remove disabling of statistics (they are useful) and ensure that
  they don't get the ERROR prefix.
- Avoid ../ prefix in paths via `run.relative-path-mode: gomod`.
2025-05-02 14:38:09 +02:00
Matthieu MOREL
4adb58565c chore: bump golangci-lint to v2
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-02 12:51:02 +02:00
Chulong Li
d868eeb088 Migrate pkg/kubelet/status to contextual logging
Update with logger from context

Fix nil pointer issue in TestUpdateReadiness
2025-03-20 21:58:14 +08:00
Oleksandr Redko
67f0e95b3a hack: fix text 2025-03-10 14:31:08 +02:00
Oleksandr Redko
a9d558de26 hack: verify golangci-lint config, update text 2025-03-10 12:40:04 +02:00
Oleksandr Redko
834a0d92cf hack: fix settings for forbidigo linter 2025-03-07 17:27:03 +02:00
Jordan Liggitt
43509b63d7 Bump hack/tools to github.com/golangci/golangci-lint 1.64.5 for go 1.24 2025-02-26 11:27:14 +01:00
Patrick Ohly
949385731f golangci-lint: remove "strict" checking
The corresponding "pull-kubernetes-verify-lint" job was already removed
earlier. Manual strict checking was still possible, but doesn't really make
sense for the same reasons why the job was removed (e.g. the decisions which
checks should be "strict" were too arbitrary).

The explanations for "hints" no longer end with "In general please prefer to
fix the error, ..." because that was misleading and only really applied to the
checks for existing code. For those checks we prefer to fix errors instead of
suppressing them, but not for hints.
2025-02-02 18:50:27 +01:00
Ed Bartosh
71b9114840 kubelet: Migrate pkg/kubelet/sysctl to contextual logging 2025-01-30 10:31:58 +02:00
Kubernetes Prow Robot
547654a8a1 Merge pull request #129813 from yongruilin/golangci-featuregate-add
feat: add a lint rule to prevent Add unversioned featuregate
2025-01-29 16:41:22 -08:00
Kubernetes Prow Robot
8294abc599 Merge pull request #128998 from bart0sh/PR165-migrate-oom-to-contextual-logging
kubelet: Migrate pkg/kubelet/oom to contextual logging
2025-01-28 13:33:22 -08:00
yongruilin
8a0937c034 feat: add a lint rule to prevent Add unversioned featuregate 2025-01-28 09:37:43 -08:00
Davanum Srinivas
4e05bc20db Linter to ensure go-cmp/cmp is used ONLY in tests
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2025-01-24 20:49:14 -05:00
Patrick Ohly
7821abf2ae client-go/rest: finish conversion to contextual logging
The remaining calls can be converted without API changes.
2025-01-22 07:58:18 +01:00
Patrick Ohly
4638ba9716 client-go/tools/cache: add APIs with context parameter
The context is used for cancellation and to support contextual logging.

In most cases, alternative *WithContext APIs get added, except for
NewIntegerResourceVersionMutationCache where code searches indicate that the
API is not used downstream.

An API break around SharedInformer couldn't be avoided because the
alternative (keeping the interface unchanged and adding a second one with
the new method) would have been worse. controller-runtime needs to be updated
because it implements that interface in a test package. Downstream consumers of
controller-runtime will work unless they use those test package.

Converting Kubernetes to use the other new alternatives will follow. In the
meantime, usage of the new alternatives cannot be enforced via logcheck
yet (see https://github.com/kubernetes/kubernetes/issues/126379 for the
process).

Passing context through and checking it for cancellation is tricky for event
handlers. A better approach is to map the context cancellation to the normal
removal of an event handler via a helper goroutine. Thanks to the new
HandleErrorWithLogr and HandleCrashWithLogr, remembering the logger is
sufficient for handling problems at runtime.
2024-12-18 18:45:02 +01:00
Ed Bartosh
f622be0333 kubelet: Migrate pkg/kubelet/oom to contextual logging 2024-11-28 17:47:02 +02:00
Ed Bartosh
e5cb071c2e kubelet: Migrate CAdvisor to contextual logging 2024-11-06 01:49:20 +02:00
Oksana Baranova
49b88f1d8a kubelet: migrate clustertrustbundle, token to contextual logging
Signed-off-by: Oksana Baranova <oksana.baranova@intel.com>
2024-10-30 17:31:11 +02:00
Kubernetes Prow Robot
3d7c95f241 Merge pull request #127769 from mmorel-35/golangci-lint/usestdlibvars
fix: apply usestdlibvars linter with golangci strict and hints
2024-10-23 02:21:42 +01:00
Antonin Bas
7dc4af6c8a Ignore false positives from unused linter
This is a workaround for a false positive in the staticcheck linter,
which has not been addressed yet.
See https://github.com/dominikh/go-tools/issues/1294.
Once this is fixed in staticcheck, we can just remove the exclude rule
from the golangci config.

Signed-off-by: Antonin Bas <antonin.bas@broadcom.com>
2024-10-03 14:44:08 -07:00
Matthieu MOREL
25222cb812 fix: apply usestdlibvars linter with golangci strict and hints
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-10-01 08:36:50 +02:00
Matthieu MOREL
0d2ad0ee43 fix: clean up testifylint configuration in golangci-lint
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-09-29 11:45:21 +02:00
Matthieu MOREL
64e9fd50ed chore: disable require-error rule from testifylint
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-09-24 07:17:52 +02:00
Oksana Baranova
2474369227 kubelet: migrate pleg to contextual logging
Signed-off-by: Oksana Baranova <oksana.baranova@intel.com>
2024-09-13 12:13:26 +03:00
Ed Bartosh
e1bc8defac kubelet: Migrate DRA Manager to contextual logging
Co-authored-by: Patrick Ohly <patrick.ohly@intel.com>
2024-08-22 11:12:41 +03:00