Commit Graph

1693 Commits

Author SHA1 Message Date
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
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
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
Kubernetes Prow Robot
48453a6eec Merge pull request #134174 from phuhung273/topologymanager-contextual-logging
kubelet: Migrate pkg/kubelet/cm/topologymanager to contextual logging
2025-10-15 01:53:34 -07:00
Tsubasa Nagasawa
476824c2a1 [PodLevelResources] Add more comprehensive test cases to kubelet
Signed-off-by: Tsubasa Nagasawa <toversus2357@gmail.com>
2025-10-15 10:50:21 +09:00
Kubernetes Prow Robot
d92afdefcb Merge pull request #134298 from kannon92/kep-5573-cgroupv1-unsupported
[KEP-5573] Set failCgroupV1 to true
2025-10-14 11:37:34 -07:00
Ed Bartosh
4c8b434779 DRA: Fix socket binding error in unit tests
Fixes TestConnectionHandling/no-wipe-on-reconnect which was failing with
"Only one usage of each socket address is normally permitted" because the
teardown function wasn't waiting for the gRPC server to fully shut down
before returning, causing socket cleanup issues in subsequent test runs.

The fix ensures proper synchronization during server shutdown so that the
Unix socket is fully released before the teardown completes. This prevents
socket binding conflicts when tests run in sequence.
2025-10-14 16:26:07 +03:00
phuhung273
7ed61cfde1 chore(kubelet): migrate topologymanager to contextual logging 2025-10-14 18:32:20 +07:00
Kubernetes Prow Robot
db63a581ca Merge pull request #134366 from tallclair/feature-gates-test
Set multiple feature gates simultaneously in test
2025-10-13 13:11:33 -07:00
Kubernetes Prow Robot
260ea59ff5 Merge pull request #134293 from bart0sh/PR203-migrate-devicemanager-to-contextual-logging
Migrate device manager to contextual logging
2025-10-13 07:23:44 -07:00
Kevin Hannon
f27346db6c update warning to reflect kep changes 2025-10-10 10:00:08 -04:00
Sergey Kanzhelev
5b7e96219f remove cpuSharesToCPUWeight that is not used any longer 2025-10-03 22:50:07 +00:00
Mark Sasnal
e4a34ce343 KEP-4540: StrictCPUReservationOption moved to GA, modified unit tests to reflect this 2025-10-02 16:08:13 -04:00
Tim Allclair
4986abe0b8 Automated refactoring to use SetFeatureGatesDuringTest 2025-10-01 21:10:53 -07:00
Ed Bartosh
a20b34aa82 devicemanager: fix golangci-lint errors 2025-09-28 21:13:46 +03:00
Kevin Hannon
06c47136fe implement KEP-5573 by not starting kubelet on cgroup v1 by default 2025-09-26 15:15:37 -04:00
Ed Bartosh
d45a4557c1 Migrate device manager to contextual logging 2025-09-26 16:50:34 +03:00
Kubernetes Prow Robot
a3bfeca891 Merge pull request #133728 from Frank-svg-dev/master
Fix the spelling error of grpc in the log
2025-09-16 20:00:09 -07:00
Kubernetes Prow Robot
8826364a57 Merge pull request #131483 from tallclair/kubeletconfig
Clean up pkg/kubelet/config
2025-09-15 15:54:07 -07:00
yliao
79f8d1b1c5 fixed bug such that implicit extended resource name can always be used,
no matter the explicit extendedResourceName field in device class is set or not.
2025-09-10 14:10:40 +00:00
Patrick Ohly
06c5eb992e DRA kubelet: avoid deadlock when gRPC connection to driver goes idle
When gRPC notifies the kubelet that a connection ended, the kubelet tries to
reconnect because it needs to know when a DRA driver comes back. The same code
gets called when a connection goes idle, by default after 30 minutes. In that
and only that case the conn.Connect call deadlocks while calling into the gRPC
idle manager.

This can be reproduced with a new unit test which artificially shortens the
idle timeout. This fix is to move the Connect call into a goroutine because
then both HandleConn and Connect can proceed. It's sufficient that Connect
finishes at some point, it doesn't need to be immediately.
2025-09-08 08:59:55 +02:00
胡玮文
21ff3c196c kubelet/metrics: fix multiple Register call
DRA also calls Register at pkg/kubelet/cm/container_manager_linux.go NewContainerManager(), causing volume stats collector being ignored.
Fix this by moving it out of `sync.Once()`, allowing multiple calls to `Register()` func.
2025-09-04 20:12:58 +08:00
Kubernetes Prow Robot
7a1e1b6fb1 Merge pull request #130376 from phuhung273/pluginmanager-context-logging
kubelet: Migrate pkg/kubelet/pluginmanager to contextual logging
2025-09-03 12:55:13 -07:00
Kubernetes Prow Robot
cb67d10970 Merge pull request #133026 from saschagrunert/dra-proto
Convert `k8s.io/kubelet/pkg/apis/dra` from gogo to protoc
2025-08-29 08:17:09 -07:00
Stephen Kitt
81cec6df1d Bump to mockery v3
mockery has introduced breaking changes and switched to a v3 branch,
this migrates to that, mostly using the built-in migration tool. Mocks
are now generated in single files per package, except in packages
containing mocks for multiple interface packages (in
pkg/kubelet/container/testing).

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2025-08-29 13:43:54 +02:00
Sascha Grunert
fd2d2fd66f Convert k8s.io/kubelet/pkg/apis/dra from gogo to protoc
Use standard protoc for the dra instead of gogo.

Part of kubernetes#96564

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2025-08-29 09:40:51 +02:00
pamforever
731e6def04 Fix the spelling error of grpc in the log 2025-08-27 19:14:22 +08:00
Tim Allclair
ff6f4e1f63 Move kubelet config code to kubeletconfig 2025-08-06 12:08:19 -07:00
Tim Allclair
30b34fbcca Don't read AllocatedResources from PodStatus during admission 2025-08-06 11:31:15 -07:00
Kubernetes Prow Robot
91731d05e2 Merge pull request #133279 from ffromani/pod-level-resource-managers
[PodLevelResources] handle pod-level resource manager alignment
2025-07-29 17:28:33 -07:00
yliao
34a64db2c7 extended resource backed by DRA: implementation 2025-07-29 18:55:21 +00:00
Francesco Romani
4ca47255a8 node: disable resource managers when pod-level resources are enabled
When pod-level resources are detected, the cpu and memory manages
cannot engage because the feature is not yet compatible,
one of the main reasons being the managers only work at container level.

So, the managers has to detect if pod level resources are in use,
and turn themselves to no-operation skipping resource allocation
should that be the case.

We add an intentional loud log to inform the user, because
pods with pod-level resources landing on a node which cannot
actuate the desired spec is likely to be undesirable.

Signed-off-by: Francesco Romani <fromani@redhat.com>
2025-07-29 20:19:40 +02:00
Francesco Romani
15b1a7fd31 Revert "CPU and Memory manager event when using pod level resources"
This reverts commit 7804b51f42.
2025-07-29 16:41:37 +02:00
Kevin Torres
5672750e6a Unit tests for no hints nor aligment of CPU and Memory 2025-07-28 18:53:03 +00:00
Kevin Torres
7804b51f42 CPU and Memory manager event when using pod level resources 2025-07-28 18:53:03 +00:00
John-Paul Sassine
b7de71f9ce feat(kubelet): Add ResourceHealthStatus for DRA pods
This change introduces the ability for the Kubelet to monitor and report
the health of devices allocated via Dynamic Resource Allocation (DRA).
This addresses a key part of KEP-4680 by providing visibility into
device failures, which helps users and controllers diagnose pod failures.

The implementation includes:
- A new `v1alpha1.NodeHealth` gRPC service with a `WatchResources`
  stream that DRA plugins can optionally implement.
- A health information cache within the Kubelet's DRA manager to track
  the last known health of each device and handle plugin disconnections.
- An asynchronous update mechanism that triggers a pod sync when a
  device's health changes.
- A new `allocatedResourcesStatus` field in `v1.ContainerStatus` to
  expose the device health information to users via the Pod API.

Update vendor

KEP-4680: Fix lint, boilerplate, and codegen issues

Add another e2e test, add TODO for KEP4680 & update test infra helpers

Add Feature Gate e2e test

Fixing presubmits

Fix var names, feature gating, and nits

Fix DRA Health gRPC API according to review feedback
2025-07-24 23:23:18 +00:00