Commit Graph

10754 Commits

Author SHA1 Message Date
Kubernetes Prow Robot
800a58b7c5 Merge pull request #137456 from liggitt/go126
Update go.mod to go 1.26, fix 1.26 vet errors
2026-03-06 10:58:23 +05:30
Jordan Liggitt
0d0b727988 Demote lint newexpr, stditerators to hints 2026-03-05 18:17:07 -05:00
Davanum Srinivas
595f1330b1 Re-enable deadcode-elimination check
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2026-03-05 16:57:02 -05:00
Jordan Liggitt
f291ae40b0 Bump to go 1.26 2026-03-05 16:48:18 -05:00
Kubernetes Prow Robot
3369e51e09 Merge pull request #137080 from cpanato/update-go-1.26
Bump dependencies, images and versions used to Go 1.26.0 and distroless iptables
2026-03-05 21:56:21 +05:30
Kubernetes Prow Robot
c38abeb4ff Merge pull request #131572 from rexagod/metrics-api
component-base: introduce metrics api
2026-03-05 11:26:17 +05:30
Kubernetes Prow Robot
8bd1505fc0 Merge pull request #137108 from pohly/logtools-update
golangci-lint: bump to logtools v0.10.1
2026-03-05 10:14:16 +05:30
Davanum Srinivas
4513498be1 Disable hard fail on deadcode-elimination script for 1.26
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2026-03-04 10:54:32 -05:00
Patrick Ohly
b895ce734f golangci-lint: bump to logtools v0.10.1
This fixes a bug that caused log calls involving `klog.Logger` to not be
checked.

As a result we have to fix some code that is now considered faulty:

    ERROR: pkg/controller/serviceaccount/tokens_controller.go:382:1: A function should accept either a context or a logger, but not both. Having both makes calling the function harder because it must be defined whether the context must contain the logger and callers have to follow that. (logcheck)
    ERROR: func (e *TokensController) generateTokenIfNeeded(ctx context.Context, logger klog.Logger, serviceAccount *v1.ServiceAccount, cachedSecret *v1.Secret) ( /* retry */ bool, error) {
    ERROR: ^
    ERROR: pkg/controller/storageversionmigrator/storageversionmigrator.go:299:1: A function should accept either a context or a logger, but not both. Having both makes calling the function harder because it must be defined whether the context must contain the logger and callers have to follow that. (logcheck)
    ERROR: func (svmc *SVMController) runMigration(ctx context.Context, logger klog.Logger, gvr schema.GroupVersionResource, resourceMonitor *garbagecollector.Monitor, toBeProcessedSVM *svmv1beta1.StorageVersionMigration, listResourceVersion string) (err error, failed bool) {
    ERROR: ^
    ERROR: pkg/proxy/node.go:121:3: logging function "Error" should not use format specifier "%q" (logcheck)
    ERROR: 		klog.FromContext(ctx).Error(nil, "Timed out waiting for node %q to exist", nodeName)
    ERROR: 		^
    ERROR: pkg/proxy/node.go:123:3: logging function "Error" should not use format specifier "%q" (logcheck)
    ERROR: 		klog.FromContext(ctx).Error(nil, "Timed out waiting for node %q to be assigned IPs", nodeName)
    ERROR: 		^
    ERROR: pkg/scheduler/backend/queue/scheduling_queue.go:610:1: A function should accept either a context or a logger, but not both. Having both makes calling the function harder because it must be defined whether the context must contain the logger and callers have to follow that. (logcheck)
    ERROR: func (p *PriorityQueue) runPreEnqueuePlugin(ctx context.Context, logger klog.Logger, pl fwk.PreEnqueuePlugin, pInfo *framework.QueuedPodInfo, shouldRecordMetric bool) *fwk.Status {
    ERROR: ^
    ERROR: pkg/scheduler/framework/plugins/dynamicresources/extendeddynamicresources.go:286:1: A function should accept either a context or a logger, but not both. Having both makes calling the function harder because it must be defined whether the context must contain the logger and callers have to follow that. (logcheck)
    ERROR: func (pl *DynamicResources) deleteClaim(ctx context.Context, claim *resourceapi.ResourceClaim, logger klog.Logger) error {
    ERROR: ^
    ERROR: pkg/scheduler/framework/plugins/dynamicresources/extendeddynamicresources.go:499:1: A function should accept either a context or a logger, but not both. Having both makes calling the function harder because it must be defined whether the context must contain the logger and callers have to follow that. (logcheck)
    ERROR: func (pl *DynamicResources) waitForExtendedClaimInAssumeCache(
    ERROR: ^
    ERROR: pkg/scheduler/framework/plugins/dynamicresources/extendeddynamicresources.go:528:1: A function should accept either a context or a logger, but not both. Having both makes calling the function harder because it must be defined whether the context must contain the logger and callers have to follow that. (logcheck)
    ERROR: func (pl *DynamicResources) createExtendedResourceClaimInAPI(
    ERROR: ^
    ERROR: pkg/scheduler/framework/plugins/dynamicresources/extendeddynamicresources.go:592:1: A function should accept either a context or a logger, but not both. Having both makes calling the function harder because it must be defined whether the context must contain the logger and callers have to follow that. (logcheck)
    ERROR: func (pl *DynamicResources) unreserveExtendedResourceClaim(ctx context.Context, logger klog.Logger, pod *v1.Pod, state *stateData) {
    ERROR: ^
    ERROR: pkg/scheduler/framework/runtime/batch.go:171:1: A function should accept either a context or a logger, but not both. Having both makes calling the function harder because it must be defined whether the context must contain the logger and callers have to follow that. (logcheck)
    ERROR: func (b *OpportunisticBatch) batchStateCompatible(ctx context.Context, logger klog.Logger, pod *v1.Pod, signature fwk.PodSignature, cycleCount int64, state fwk.CycleState, nodeInfos fwk.NodeInfoLister) bool {
    ERROR: ^
    ERROR: staging/src/k8s.io/component-base/featuregate/feature_gate.go:890:4: Additional arguments to Info should always be Key Value pairs. Please check if there is any key or value missing. (logcheck)
    ERROR: 			logger.Info("Warning: SetEmulationVersionAndMinCompatibilityVersion will change already queried feature", "featureGate", feature, "oldValue", oldVal, newVal)
    ERROR: 			^
    ERROR: test/images/sample-device-plugin/sampledeviceplugin.go:108:2: logging function "Info" should not use format specifier "%s" (logcheck)
    ERROR: 	logger.Info("pluginSocksDir: %s", pluginSocksDir)
    ERROR: 	^
    ERROR: test/images/sample-device-plugin/sampledeviceplugin.go:123:2: logging function "Info" should not use format specifier "%s" (logcheck)
    ERROR: 	logger.Info("CDI_ENABLED: %s", cdiEnabled)
    ERROR: 	^

While waiting for this to merge, another call was added which also doesn't
follow conventions:

    ERROR: pkg/kubelet/kubelet.go:2454:1: A function should accept either a context or a logger, but not both. Having both makes calling the function harder because it must be defined whether the context must contain the logger and callers have to follow that. (logcheck)
    ERROR: func (kl *Kubelet) deletePod(ctx context.Context, logger klog.Logger, pod *v1.Pod) error {
    ERROR: ^

Contextual logging has been beta and enabled by default for several releases
now. It's mostly just a matter of wrapping up and declaring it GA. Therefore
the calls which directly call WithName or WithValues (always have an effect)
are left as-is instead of converting them to use the klog wrappers (support
disabling the effect). To allow that, the linter gets reconfigured to not
complain about this anymore, anywhere.

The calls which would have to be fixed otherwise are:

    ERROR: pkg/kubelet/cm/dra/claiminfo.go:170:11: function "WithName" should be called through klogr.LoggerWithName (logcheck)
    ERROR: 	logger = logger.WithName("dra-claiminfo")
    ERROR: 	         ^
    ERROR: pkg/kubelet/cm/dra/healthinfo.go:45:11: function "WithName" should be called through klogr.LoggerWithName (logcheck)
    ERROR: 	logger = logger.WithName("dra-healthinfo")
    ERROR: 	         ^
    ERROR: pkg/kubelet/cm/dra/healthinfo.go:89:11: function "WithName" should be called through klogr.LoggerWithName (logcheck)
    ERROR: 	logger = logger.WithName("dra-healthinfo")
    ERROR: 	         ^
    ERROR: pkg/kubelet/cm/dra/healthinfo.go:157:11: function "WithName" should be called through klogr.LoggerWithName (logcheck)
    ERROR: 	logger = logger.WithName("dra-healthinfo")
    ERROR: 	         ^
    ERROR: pkg/kubelet/cm/dra/manager.go:175:12: function "WithName" should be called through klogr.LoggerWithName (logcheck)
    ERROR: 	logger := klog.FromContext(ctx).WithName("dra-manager")
    ERROR: 	          ^
    ERROR: pkg/kubelet/cm/dra/manager.go:239:12: function "WithName" should be called through klogr.LoggerWithName (logcheck)
    ERROR: 	logger := klog.FromContext(ctx).WithName("dra-manager")
    ERROR: 	          ^
    ERROR: pkg/kubelet/cm/dra/manager.go:593:12: function "WithName" should be called through klogr.LoggerWithName (logcheck)
    ERROR: 	logger := klog.FromContext(ctx).WithName("dra-manager")
    ERROR: 	          ^
    ERROR: pkg/kubelet/cm/dra/manager.go:781:12: function "WithName" should be called through klogr.LoggerWithName (logcheck)
    ERROR: 	logger := klog.FromContext(context.Background()).WithName("dra-manager")
    ERROR: 	          ^
    ERROR: pkg/kubelet/cm/dra/manager.go:898:12: function "WithName" should be called through klogr.LoggerWithName (logcheck)
    ERROR: 	logger := klog.FromContext(ctx).WithName("dra-manager")
    ERROR: 	          ^
    ERROR: pkg/kubelet/cm/dra/manager_test.go:1638:15: function "WithName" should be called through klogr.LoggerWithName (logcheck)
    ERROR: 				logger := klog.FromContext(streamCtx).WithName(st.Name())
    ERROR: 				          ^
    ERROR: pkg/kubelet/cm/dra/plugin/dra_plugin.go:77:12: function "WithName" should be called through klogr.LoggerWithName (logcheck)
    ERROR: 	logger := klog.FromContext(ctx).WithName("dra-plugin")
    ERROR: 	          ^
    ERROR: pkg/kubelet/cm/dra/plugin/dra_plugin.go:108:12: function "WithName" should be called through klogr.LoggerWithName (logcheck)
    ERROR: 	logger := klog.FromContext(ctx).WithName("dra-plugin")
    ERROR: 	          ^
    ERROR: pkg/kubelet/cm/dra/plugin/dra_plugin.go:161:12: function "WithName" should be called through klogr.LoggerWithName (logcheck)
    ERROR: 	logger := klog.FromContext(ctx).WithName("dra-plugin")
    ERROR: 	          ^
    ERROR: staging/src/k8s.io/dynamic-resource-allocation/resourceslice/tracker/tracker.go:695:14: function "WithValues" should be called through klogr.LoggerWithValues (logcheck)
    ERROR: 			logger := logger.WithValues("device", deviceID)
    ERROR: 			          ^
    ERROR: test/integration/apiserver/watchcache_test.go:42:54: function "WithName" should be called through klogr.LoggerWithName (logcheck)
    ERROR: 	etcd0URL, stopEtcd0, err := framework.RunCustomEtcd(klog.FromContext(ctx).WithName("etcd0"), "etcd_watchcache0", etcdArgs)
    ERROR: 	                                                    ^
    ERROR: test/integration/apiserver/watchcache_test.go:47:54: function "WithName" should be called through klogr.LoggerWithName (logcheck)
    ERROR: 	etcd1URL, stopEtcd1, err := framework.RunCustomEtcd(klog.FromContext(ctx).WithName("etcd1"), "etcd_watchcache1", etcdArgs)
    ERROR: 	                                                    ^
    ERROR: test/integration/scheduler_perf/scheduler_perf.go:1149:12: function "WithName" should be called through klogr.LoggerWithName (logcheck)
    ERROR: 		logger = logger.WithName(tCtx.Name())
    ERROR: 		         ^
2026-03-04 12:08:18 +01:00
Kubernetes Prow Robot
a0594a28a4 Merge pull request #136954 from BenTheElder/kube-runner
switch server images to kube-log-runner
2026-03-04 06:30:17 +05:30
Benjamin Elder
9f8eca1566 add kube-log-runner to images on the fly, replicating the same /go-runner path as the current base image
d98562ea2e/images/build/go-runner/Dockerfile (L68-L70)
2026-03-03 16:00:02 -08:00
Kubernetes Prow Robot
ba4ac6d65b Merge pull request #137003 from hoteye/pr1-kubelet-podworkers-core
kubelet: tighten podworkers context flow and consolidate kubelet logcheck scope
2026-03-04 04:30:27 +05:30
Pranshu Srivastava
e74b4063d8 chore: reorganize component-base/metrics
This commit reorganizes component-base's metrics package to bring about
the following changes:
* migrate all related functions and methods to options.go (from
  registry.go)
* inline v1.MetricsConfiguration in Options and expose it in api/v1,
  also re-generate deepcopy assets for the same
* add missing validation functions for MetricsConfiguration fields
* add missing setter functions for MetricsConfiguration fields
* addressed a logical bug in SetDisabledMetric to not increment the
  disabled metrics counter when a duplicate metric is disabled again
* refactored some tests to also take into consideration meta metrics,
  wherever applicable
* changed validateAllowListMappingManifest's godoc to mention that
  components are expected to pass in the *absolute* path to the manifest
  file

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
2026-03-03 23:45:14 +05:30
Kubernetes Prow Robot
92491f09ee Merge pull request #137299 from Jefftree/kexp
Use ephemeral port for etcd peer listener
2026-03-03 23:03:23 +05:30
Jefftree
292e4ca469 Use localhost for etcd peer listener instead of ETCD_HOST 2026-03-03 10:22:39 -05:00
Kubernetes Prow Robot
9b25f86cf8 Merge pull request #137348 from Jefftree/deepcopy-fix
deepcopy-gen: remove dead --bounding-dirs flag
2026-03-03 11:00:53 +05:30
Kubernetes Prow Robot
4ee05a3a2f Merge pull request #137242 from tico88612/cleanup/e2e-node-prometheus
Cleanup: `test/e2e_node` remove prometheus dependency
2026-03-03 02:49:02 +05:30
Jefftree
d6b91820b7 deepcopy-gen: remove dead --bounding-dirs flag
The --bounding-dirs flag and BoundingDirs field in deepcopy-gen are dead
code. The field is stored on the genDeepCopy struct but never read by
any method.

The flag was introduced in gengo commit 14ae879 (2016) to control which
types deepcopy would generate for and which nested types it could assume
had generated deepcopy functions. Over time, as deepcopy-gen was
rewritten (gengo v2, moved to code-generator), the copyableAndInBounds /
isRootedUnder usage was dropped. The field and flag survived but
g.boundingDirs is never referenced in the current code.

hack/update-codegen.sh still passed --bounding-dirs but it had no
effect.
2026-03-02 14:53:52 -05:00
Jefftree
553dc9c2aa Use ephemeral port for etcd peer listener
Port 0 lets the OS assign a random free port, avoiding conflicts
when running multiple etcd instances for parallel tests. Peering
is unused in single-node test setups.
2026-02-27 17:24:32 -05:00
ChengHao Yang
ba277219e3 Remove dependency prometheus from test/e2e_node resource metric test
Signed-off-by: ChengHao Yang <17496418+tico88612@users.noreply.github.com>
2026-02-28 00:01:00 +08:00
pranshul gupta
10f7c34c16 added exceptions for StorageVersion.Spec , StorageVersion.Status , StorageVersionCondition.LastTransitionTime to be a pointer and StorageVersion.Spec and StorageVersion.Status to have omitempty tag 2026-02-27 09:00:07 +05:30
pranshul gupta
1c6365cda0 lint: add granular exception for apiserverinternal
Demonstrates the 1:1 migration strategy by enabling the 'apiserverinternal'
API group and adding a specific exception for StorageVersionCondition.
2026-02-27 08:29:35 +05:30
pranshul gupta
c0c06c9ac6 lint: Enable optionalfields rule in KAL with mass exclusion 2026-02-27 08:29:35 +05:30
pranshul gupta
b278254eba Enable optionalfields rule for Kube API linter 2026-02-27 08:29:35 +05:30
Carlos Panato
d9956b7fde Bump dependencies, images and versions used to Go 1.26.0 and distroless iptables
Signed-off-by: Carlos Panato <ctadeu@gmail.com>
2026-02-26 09:09:39 +01:00
ChengHao Yang
4baef5a295 Remove dependency prometheus from test/e2e_node mirror pod grace period test
Signed-off-by: ChengHao Yang <17496418+tico88612@users.noreply.github.com>
2026-02-25 21:06:16 +08:00
ermias19
0678b48e88 narrowing the lint through adding admissionregistration. 2026-02-25 10:29:28 +01:00
ermias19
40173a2774 admission: mark review fields optional 2026-02-25 02:52:48 +01:00
Kubernetes Prow Robot
0ef4f38784 Merge pull request #136900 from itzPranshul/rbac-optionalorrequired
KAL:enforce `optionalorrequired` on rbac API group
2026-02-24 23:43:34 +05:30
Ludo van Orden
9e29a74c6f commentstart lint fixes for apiserverinternal API group 2026-02-20 23:54:57 +01:00
Sotiris Salloumis
df5c17e199 Add memorymanager option in local-up-cluster 2026-02-20 09:44:54 +01:00
Kubernetes Prow Robot
0536cfdf8d Merge pull request #137107 from joshjms/update-etcd-3.6.8
etcd: update etcd image to v3.6.8
2026-02-19 21:05:40 +05:30
koba1t
58d00acb62 remove unwanted dependency 'github.com/pkg/errors' 2026-02-19 22:16:47 +09:00
hoteye
6bccc051eb hack: add temporary kubelet contextual logcheck carve-outs
Keep broad kubelet contextual logcheck coverage while excluding a small set of legacy files that still use non-contextual logging patterns.

These carve-outs are temporary and will be removed in follow-up kubelet contextual logging PRs.
2026-02-19 14:06:21 +08:00
hoteye
e94e67337d kubelet: tighten podworkers context flow and consolidate kubelet logcheck scope
Propagate upper-level context through pod worker update and sync paths in the kubelet call flow touched by this PR.

Also consolidate kubelet logcheck scope so non-contextual logging additions are blocked in pkg/kubelet while keeping behavior unchanged.
2026-02-19 14:05:39 +08:00
joshjms
7c54689847 etcd: update etcd image to v3.6.8
Signed-off-by: joshjms <joshjms1607@gmail.com>
2026-02-18 21:29:56 +08:00
pranshul gupta
ed551f6826 KAL:enforce optionalorrequired on rbac API group
# Conflicts:
#	hack/golangci-hints.yaml
#	hack/golangci.yaml
#	hack/kube-api-linter/exceptions.yaml
2026-02-18 13:41:39 +05:30
Kubernetes Prow Robot
4540abb5d8 Merge pull request #136704 from Ignoramuss/optionalorrequired-authentication
api: enable optionalorrequired linter for authentication API
2026-02-17 23:31:47 +05:30
Stephen Kitt
3d1e90f95a Bump to golangci-lint 2.9.0
bloop was disabled because of its impact on small benchmarks (see
267fc6b81a
for details), this removes it from the disabled entries.

stringscut was introduced in x/tools 0.40.0 and is disabled for
existing code.

ginkgolinter's Success matcher check doesn't know about TContext, so
it's disabled for k/k.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2026-02-16 15:45:22 +01:00
Ignoramuss
3b25b16ce1 api: enable optionalorrequired linter for authentication API
Add missing +optional and +required markers to authentication API types
across v1, v1beta1, and v1alpha1 versions, and remove authentication
from the linter exception lists.

Part of kubernetes/kubernetes#134671
2026-02-13 17:40:47 -08:00
Kubernetes Prow Robot
9571e19da9 Merge pull request #134675 from JoelSpeed/enable-kal-optionalorrequired-apiserver-internal
Enforce either optional or required tag on apiserverinternal API group
2026-02-13 06:10:00 +05:30
Joel Speed
551c08e2a2 Update exceptions to drop "it must be optional" 2026-02-12 17:42:44 +00:00
Joel Speed
0b10375aec Add exception for union type in scheduling API
We need to add a marker to allow podgroup to be marked up correctly as a union type, and then teach the nonpointerstructs linter how to understand this
2026-02-12 14:12:36 +00:00
Joel Speed
a9034c040e Enable nonpointerstructs alongside optionalorrequired 2026-02-12 14:12:33 +00:00
Davanum Srinivas
550cc8645b Move dump package from apimachinery to k8s.io/utils
Replace all imports of k8s.io/apimachinery/pkg/util/dump with
k8s.io/utils/dump across the repo. The apimachinery dump package
now contains deprecated wrapper functions that delegate to
k8s.io/utils/dump for backwards compatibility.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2026-02-12 07:34:19 -05:00
Joel Speed
c4b2640b32 Remove exceptions for groups with no issues 2026-02-12 11:16:54 +00:00
Joel Speed
8651d99a26 Enforce either optional or required tag on apiserverinternal API group 2026-02-12 11:14:37 +00:00
Kubernetes Prow Robot
7b0310aadd Merge pull request #136820 from dims/update-otel-deps
Update OpenTelemetry dependencies to latest versions
2026-02-10 05:44:05 +05:30
Kubernetes Prow Robot
f693c45c4e Merge pull request #136775 from atombrella/feature/activate_modernize_slicessort
Enable modernize/slicessort rule
2026-02-10 05:43:57 +05:30
Davanum Srinivas
275adf8b04 Update OpenTelemetry dependencies to latest versions
Bump OpenTelemetry dependencies:
- go.opentelemetry.io/otel v1.39.0 → v1.40.0
- go.opentelemetry.io/otel/metric v1.39.0 → v1.40.0
- go.opentelemetry.io/otel/sdk v1.39.0 → v1.40.0
- go.opentelemetry.io/otel/trace v1.39.0 → v1.40.0
- go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.39.0 → v1.40.0
- go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.39.0 → v1.40.0
- go.opentelemetry.io/contrib/.../otelrestful v0.64.0 → v0.65.0
- go.opentelemetry.io/contrib/.../otelhttp v0.64.0 → v0.65.0
- go.opentelemetry.io/contrib/.../otelgrpc v0.63.0 → v0.65.0

Unpin otelgrpc: the nil TracerProvider panic (kubernetes#135865) that
required pinning at v0.63.0 is fixed in v0.65.0. Removed the
pinnedModules entry from unwanted-dependencies.json.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2026-02-07 09:21:51 -05:00