Commit Graph

1727 Commits

Author SHA1 Message Date
Kubernetes Prow Robot
ae76dd831d Merge pull request #136168 from bart0sh/PR214-DRA-kubelet-OWNERS-update
Add pohly and bart0sh as approvers for kubelet/cm/dra
2026-01-17 01:33:24 +05:30
Kubernetes Prow Robot
210881f0f0 Merge pull request #135485 from saschagrunert/fix-device-plugin-termination-grace-period
Fix device plugin admission failure after container restart
2026-01-12 22:24:22 +05:30
Sascha Grunert
172a65c71d Fix device plugin admission failure after container restart
When a container restarts before kubelet restarts, containerMap has
multiple entries (old exited + new running). GetContainerID() may
return the exited container, causing the running check to fail. Fixed
by checking if ANY container for the pod/name is running.

Also filter terminal pods from podresources since they no longer
consume resources, and fix test error handling to avoid exiting
Eventually immediately on transient errors.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2026-01-12 11:55:25 +01:00
Ed Bartosh
b0375e76f0 Add pohly and bart0sh as approvers for kubelet/cm/dra 2026-01-12 12:43:07 +02:00
Kubernetes Prow Robot
c68de67df3 Merge pull request #136132 from pohly/ktesting-default-verbosity
ktesting: avoid increasing default verbosity
2026-01-09 22:17:50 +05:30
Patrick Ohly
36a95a05eb ktesting: avoid increasing default verbosity
Bumping to 5 is useful in unit tests. Those tend to not produce less output and
ideally use per-test output, so we end up keeping only the output of failed
tests where increased verbosity also in CI runs is useful.

But ktesting now also gets imported into e2e test binaries through the
framework. There the increased verbosity is apparently causing OOM killing in
some jobs which previously worked fine.

Long term we need a better solution than simply disabling the verbosity
change. We could modify each unit test to call SetDefaultVerbosity, but that's
tedious. Perhaps an env variable? It cannot be a command line flag because not
all unit tests accept `-v`.
2026-01-09 14:54:09 +01:00
Davanum Srinivas
1b33c52ef1 Fix data race in devicemanager PluginDisconnected logging
Don't log the endpoint struct in PluginDisconnected() - it contains
a gRPC client and logging it via reflection races with Close().

The logger walks the struct with reflection, reading gRPC internals,
while Close() is modifying mutex state in the background. Removing
the endpoint from the log avoids the race. The resourceName is already
logged which is enough to identify which endpoint disconnected.

This race becomes visible with gRPC v1.76.0+ due to timing changes
in buffer handling and goroutine lifecycle during Close(). The
ci-kubernetes-unit-dependencies job was hitting this ~10% of the time
when testing with updated dependencies.

CI failures:
- https://storage.googleapis.com/kubernetes-ci-logs/logs/ci-kubernetes-unit-dependencies/2009065501396832256/build-log.txt
- https://storage.googleapis.com/kubernetes-ci-logs/logs/ci-kubernetes-unit-dependencies/2008641956699181056/build-log.txt
- https://storage.googleapis.com/kubernetes-ci-logs/logs/ci-kubernetes-unit-dependencies/2007491912692404224/build-log.txt
- https://storage.googleapis.com/kubernetes-ci-logs/logs/ci-kubernetes-unit-dependencies/2007431281842851840/build-log.txt

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2026-01-09 08:19:33 -05:00
Kubernetes Prow Robot
0f89b13c79 Merge pull request #135227 from hime/master
Inverting DRAOperationsDuration metric by inverting 'is_error' label.
2026-01-06 05:24:38 +05:30
Patrick Ohly
ad79e479c2 build: remove deprecated '// +build' tag
This has been replaced by `//build:...` for a long time now.

Removal of the old build tag was automated with:

    for i in $(git grep -l '^// +build' | grep -v -e '^vendor/'); do if ! grep -q '^// Code generated' "$i"; then sed -i -e '/^\/\/ +build/d' "$i"; fi; done
2025-12-18 12:16:21 +01:00
Kubernetes Prow Robot
321e0f69d8 Merge pull request #135504 from dims/bump=github.com/opencontainers/cgroups-to-v0.0.6
Bump github.com/opencontainers/cgroups to v0.0.6
2025-12-17 22:36:36 -08:00
Kubernetes Prow Robot
c0c81a4258 Merge pull request #135249 from bart0sh/PR207-migrate-container-manager-to-contextual-logging
kubelet: migrate container manager to contextual logging
2025-12-17 20:00:01 -08:00
Kubernetes Prow Robot
1078cf59b9 Merge pull request #133964 from K-Diger/fix/dra-plugin-unreachable-code
kubelet: refactor DRA plugin health client initialization
2025-12-17 16:26:03 -08:00
Jaime Bohorquez
19d50f6340 Fix recording of "DRAOperationsDuration" metric by inverting "is_error" boolean. 2025-12-08 23:40:05 +00:00
k-diger
b255410b4f Remove duplicate connection management in DRA plugin Fixes 2025-12-05 01:34:44 +09:00
Davanum Srinivas
1569ebc5a6 Bump github.com/opencontainers/cgroups to v0.0.6
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2025-11-28 16:22:46 -05:00
ndixita
11ff4efcde Kubelet changes to support IPPR + PodLevelResources
Signed-off-by: ndixita <ndixita@google.com>
2025-11-11 18:17:28 +00:00
Ed Bartosh
9521398859 kubelet: migrate container manager to contextual logging 2025-11-11 13:51:01 +02:00
Kubernetes Prow Robot
135db3b1c1 Merge pull request #135153 from SergeyKanzhelev/deviceManagerHealthFix
mark device manager as haelthy before it started for the first time
2025-11-06 17:00:51 -08:00
Kubernetes Prow Robot
ec5211cedc Merge pull request #135147 from harche/HealhCheckTimeout
DRA: Add configurable health check timeout per device
2025-11-06 15:19:07 -08:00
Kubernetes Prow Robot
41fd1b51f6 Merge pull request #134520 from sunya-ch/add-share-id-to-plugin-device
[DRA] Add ShareID to kubelet plugin API
2025-11-06 12:43:00 -08:00
Sergey Kanzhelev
2d3e063923 mark device manager as haelthy before it started for the first time 2025-11-06 20:25:01 +00:00
yliao
6676982316 fixed non-sidecar init container device requests and mappings 2025-11-05 22:48:50 +00:00
Sunyanan Choochotkaew
eea7c1403f [DRA] Add ShareID to kubelet plugin API
Signed-off-by: Sunyanan Choochotkaew <sunyanan.choochotkaew1@ibm.com>
2025-11-06 03:28:35 +09:00
Harshal Patil
374baacf92 Check HealthCheckTimeout in updateHealthInfo comparison
Signed-off-by: Harshal Patil <12152047+harche@users.noreply.github.com>
2025-11-05 11:32:18 -05:00
Kubernetes Prow Robot
1ed34af815 Merge pull request #133724 from bart0sh/PR195-device-plugins-fix-out-of-sync
devicemanager: fix cleanup of unhealthy devices
2025-11-04 13:42:04 -08:00
Kubernetes Prow Robot
934c34435a Merge pull request #134875 from Jpsassine/jpsassine-dra-health-fix
Fix bug in reporting health for templated and renamed DRA claims
2025-11-04 12:52:11 -08:00
John-Paul Sassine
1e8fc543cc Fix report health for templated and renamed DRA claims
The Kubelet's DRA manager was failing to report device health status in a pod's status for certain types of resource claims. The logic incorrectly assumed that the claim name used within the container's spec (`container.resources.claims[*].name`) was the same as the metadata name of the actual ResourceClaim object.

This assumption is false in two key scenarios:
1.  When a claim is generated from a `ResourceClaimTemplate`, Kubernetes creates a `ResourceClaim` object with a randomized suffix in its name.
2.  When a user defines a pre-existing claim in `pod.spec.resourceClaims`, they can provide a local name that differs from the actual `ResourceClaim` object's name.

In both cases, the code would fail to find the claim's information in its internal cache, resulting in the health status not being populated, as reported in issue #134482.

This fix corrects the logic by using `pod.Status.ResourceClaimStatuses` as the authoritative map to look up the actual, generated name of the `ResourceClaim` object. This ensures that both templated and renamed claims are resolved correctly before their health status is retrieved from the cache.

Additionally, this change introduces a new node e2e test that specifically covers templated and renamed claims to prevent future regressions.
2025-11-03 22:56:32 +00:00
Kubernetes Prow Robot
4e8499740e Merge pull request #134985 from swatisehgal/node-cm-ctx-logging-migration
node: cm: migrate container manager to contextual logging
2025-11-03 09:34:12 -08:00
Kubernetes Prow Robot
b9bbdfa32f Merge pull request #132658 from tkashem/dra-plugin-timeout
kubelet: add a unit test that verifies that the dra plugin enforces timeout
2025-11-03 04:44:05 -08:00
Ed Bartosh
36510ccf56 devicemanager: fix cleanup of healthy and unhealthy devices
Correctly removed the resource from both healthy and unhealthy device
maps when resource endpoint expires.

This makes resource endpoint and devices maps consistent.
2025-11-03 10:57:58 +02:00
Swati Sehgal
f2d075ea65 Address review comments
Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
2025-10-31 17:41:34 +00:00
Abu Kashem
11e3147fdd kubelet: add a test to verify that dra plugin enforces timeout 2025-10-31 11:16:54 -04:00
Abu Kashem
344df7835c refactor dra fake grpc server 2025-10-31 10:11:49 -04:00
Swati Sehgal
f2257059d7 node: cm: fix linter failures
Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
2025-10-31 08:14:49 +00:00
Swati Sehgal
67280d4df9 node: cm: update mocks for contextual logging migration
Autogenerated by running:
```
./hack/update-mocks.sh
```
Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
2025-10-31 06:50:28 +00:00
Swati Sehgal
05f67d834a node: cm: migrate container manager to contextual logging
This commit migrates the container manager package to use
contextual logging.

This follows the contextual logging migration pattern where:
- Logger is passed from the boundary down to implementations
- klog.TODO() is used at call sites where context is not yet available
- Functions with context.Context extract logger via klog.FromContext(ctx)
- klog.InfoS/ErrorS/V().InfoS calls are replaced with logger.Info/Error/V().Info
- Sub-managers receive proper logger context from their callers

Some call sites still use klog.TODO() as placeholders, with TODO
comments indicating these will be replaced with proper contextual loggers
as the migration continues upward through the call stack.

Test/fake implementations use klog.Background() which is the appropriate
choice for test code where no real context is available.

Mock file updates (pkg/kubelet/cm/testing/mocks.go) were done manually
due to mockery tool incompatibility with Go 1.25 and will be committed
separately with an explanation.

Key changes:

1. PodContainerManager and ContainerManager interface updates:
   - PodContainerManager.EnsureExists: add logger parameter
   - PodContainerManager.Destroy: add logger parameter
   - PodContainerManager.ReduceCPULimits: add logger parameter
   - PodContainerManager.SetPodCgroupConfig: add logger parameter
   - ContainerManager.UpdateQOSCgroups: add logger parameter
   - Update all implementations (Linux, Windows, stub, noop, fake)

2. Helper function updates:
   - GetKubeletContainer: add logger parameter (Linux and unsupported platforms)
   - Update cmd/kubelet/app/server.go to pass logger to GetKubeletContainer
   - Comment out type assertion in helpers.go due to signature change

3. Cgroup manager contextual logging:
   - CgroupManager interface methods updated to accept logger:
     * Destroy: add logger parameter
     * ReduceCPULimits: add logger parameter
     * SetCgroupConfig: add logger parameter
   - Update cgroupCommon and unsupportedCgroupManager implementations
   - Migrate klog.InfoS/V().InfoS calls to logger.Info/V().Info

4. Container manager implementation updates:
   - Extract logger from context in NewContainerManager() and Start()
   - Pass logger to sub-managers (deviceManager, topologyManager)
   - Update DRA manager initialization to use logger from context
   - Migrate klog.InfoS/ErrorS to logger.Info/Error throughout

5. Call sites updated with TODO comments:
   - pkg/kubelet/kubelet.go: UpdateQOSCgroups, EnsureExists
   - pkg/kubelet/kubelet_pods.go: UpdateQOSCgroups, ReduceCPULimits, Destroy
   - pkg/kubelet/kuberuntime/kuberuntime_manager.go: SetPodCgroupConfig
   - pkg/kubelet/kuberuntime/kuberuntime_manager_test.go: test expectations

Most call sites currently use klog.TODO() as placeholders, with TODO
comments indicating these will be replaced with proper contextual loggers
as the migration continues upward through the call stack.

Test/fake implementations use klog.Background() which is the appropriate
choice for test code where no real context is available.

Mock file updates (pkg/kubelet/cm/testing/mocks.go) were done manually
due to mockery tool incompatibility with Go 1.25 and will be committed
separately with an explanation.

Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
2025-10-30 18:34:03 +00:00
Swati Sehgal
e06abce75f node: mm-mgr: Refactor to use logger parameter instead of context
This change completes the contextual logging migration for the memory
manager by updating the Manager interface and all implementations to
accept logr.Logger parameters instead of context.Context.

Key changes:
- Update Manager interface methods to accept logr.Logger:
  * AddContainer, RemoveContainer, GetMemoryNUMANodes
  * GetAllocatableMemory, GetMemory (removed context entirely)
- Update Policy interface methods to accept logr.Logger instead of context.Context
- Pass logger to NewManager() and policy constructors (NewPolicyStatic, NewPolicyNone, NewPolicyBestEffort)
- Update internal_container_lifecycle to use klog.TODO() when calling memory manager methods
- Update fake manager to accept and use logger parameter
- Update all test code to pass logger instead of context

This aligns with the contextual logging migration pattern where:
- Functions that need a logger accept logr.Logger parameter directly
- Logger is passed from the boundary (e.g., Start()) down to implementation
- klog.TODO() is used temporarily in call sites where logger is not yet available
- Context is only used where truly needed (e.g., Start() method)

This follows the same pattern as recent migrations in:
- pkg/kubelet/cm/topologymanager (#134174)
- pkg/kubelet/cm/devicemanager (#134293)
- pkg/kubelet/cm/cpumanager (#125912)

Related to the initial memory manager contextual logging work in #130727.

Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
2025-10-29 16:09:42 +00:00
Kubernetes Prow Robot
f0ed028e75 Merge pull request #133784 from bart0sh/PR197-DRA-process-devices-when-allocatable-is-0
Treat extended resources as inactive when allocatable is 0
2025-10-28 03:29:36 -07:00
Ed Bartosh
7b2acb74c0 DRA: fix admit logic for extended resources
Updated allocateContainerResources to skip resources referring
extended resource claims as they are managed by DRA drivers.
These resources shouldn't be processed by device plugins.
2025-10-27 16:24:35 +02:00
Francesco Romani
fd5b2efa76 node: cpumanager: migrate to contextual logging
migrate the cpumanager code to contextual logging

design musings:
- golang contexts "[...] carries deadlines, cancellation signals, and
  other request-scoped values across API boundaries and between
  processes." (see: https://pkg.go.dev/context#pkg-overview).
  Thus, it generally makes sense to add contexts to most of the APIs
  and functions  as the resource management is done in the admission flow, when
  ultimately we process a request and we have time bounds;
- however, receiving a context from the outside and depending on it
  kind also conflicts with the goal of having uniform logging and "
  - attach key/value pairs that get included in all log messages
  - add names that describe which component or operation triggered a log messages"
  (see:
https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/3077-contextual-logging#summary)
  Some of this conflict is due to the transitional nature of the PRs
  which we do when updating the codelet codebase. We can envision a
  final state on which the top level caller adds identifying information
  like pod UID and pod namespace/name pair; but up until all the calling
  chain is updated and wired, the results are gonna be inconsistent.
- continuing from the point above, the most realistic transition plan
  for the kubelet is outlined in
  https://github.com/kubernetes/kubernetes/issues/130069 .
  Since we do want to move in parallel and migrate on a
  subsystem-by-subsystem basis, each subsystem will be in charge to add
  the data they want to their contexts. I think this is the only
  reasonnable way forward, and the cost will be overhead and redundancy.
  We should do sweeping changes to uniform the flows once we completed
  the full transition to ensure uniformity.
- there are some well known packages which want to operate by design
  only in in-memory data structure, which arguably can't block.
  Shoehorning a context feels not great. Instead, we intentionally pass
  only the logger, which still is the core idea of contextual logging
  (see:
https://github.com/kubernetes/kubernetes/pull/125912#discussion_r1935919144)
  examples are the topology subpackage and the cpu_assignment logic
  (takeByTopology and friends)

Signed-off-by: Francesco Romani <fromani@redhat.com>
2025-10-27 08:38:58 +01:00
Kubernetes Prow Robot
4539b9c8f3 Merge pull request #133660 from scaventz/109717-PreStartContainer
Test: Add unit test for PreStartContainer
2025-10-24 13:07:33 -07:00
Xin Wang
5d4d6cc980 Test: Add unit test for PreStartContainer
#109717
2025-10-24 12:58:01 +08:00
novahe
9d48e7d2d4 fix missing involvedObject.apiVersion in event 2025-10-22 20:13:36 +08:00
Kubernetes Prow Robot
cba95d3e42 Merge pull request #132601 from toVersus/test/more-pod-level-resources
[PodLevelResources] Add more comprehensive test cases to kubelet
2025-10-20 14:26:36 -07:00
Kubernetes Prow Robot
69b762aacd Merge pull request #134587 from bart0sh/PR204-fix-TestConnectionHandling-flake
DRA: fix TestConnectionHandling flake
2025-10-20 13:36:36 -07:00
Kubernetes Prow Robot
02e576064f Merge pull request #134614 from ffromani/topomgr-max-allowable-nodes-ga
KEP-4622: promote topology manager `max-allowable-numa-nodes` to GA
2025-10-15 18:43:41 -07:00
Kubernetes Prow Robot
95fcceb90c Merge pull request #134388 from nokia/kep-4540-ga
KEP-4540: StrictCPUReservationOption moved to GA
2025-10-15 05:59:35 -07:00
Francesco Romani
97861325ae KEP-4622: node: topomgr: max-allowable-numa-nodes to GA
promote the policy option to GA.

Signed-off-by: Francesco Romani <fromani@redhat.com>
2025-10-15 12:21:04 +02:00
Francesco Romani
cccb66bfbc test: topologymanager: handle panic in test
unexpected success should cause a test failure, not a panic

Signed-off-by: Francesco Romani <fromani@redhat.com>
2025-10-15 12:20:57 +02:00
Francesco Romani
00a8ddce91 node: topologymanager: don't leak options in tests
unit tests for the policy options add test options to the
global state without proper cleanup; this is done only in tests
so it has limited room for doing damage, but still weakens
the test signal. Let's avoid that adding proper cleanup.

Signed-off-by: Francesco Romani <fromani@redhat.com>
2025-10-15 12:15:08 +02:00