Commit Graph

3370 Commits

Author SHA1 Message Date
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
246fa57363 Merge pull request #135604 from dims/better-support-for-cri-stats
kubelet: improve CRI stats for resource metrics and testing
2025-12-17 23:28:10 -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
Kubernetes Prow Robot
97e95711c5 Merge pull request #133654 from kwohlfahrt/kubelet-cert
Fix kubelet certificate reload when connecting by IP address
2025-12-17 16:25:32 -08:00
Davanum Srinivas
914ddf4468 kubelet: improve CRI stats for resource metrics and testing
properly support the resource metrics endpoint when `PodAndContainerStatsFromCRI` is enabled and fix the related e2e tests.

Stats Provider:
- add container-level CPU and memory stats to `ListPodCPUAndMemoryStats` so the resource metrics endpoint has complete data
- add `aggregatePodSwapStats` to compute pod-level swap from container stats (CRI doesn't provide pod-level swap directly)
- add missing memory stats fields: `AvailableBytes`, `PageFaults`, and `MajorPageFaults`
- add platform-specific implementations for Linux and Windows

Tests:
- skip cAdvisor metrics test when `PodAndContainerStatsFromCRI` is enabled (cAdvisor metrics aren't available in that mode)
- fix expected metrics in `ResourceMetricsAPI` test
- `node_swap_usage_bytes` is only available with cAdvisor (need to verify!)
- Add `dumpResourceMetricsForPods` helper to log actual metric values when tests fail, making debugging easier

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2025-12-17 10:52:32 -05:00
k-diger
b255410b4f Remove duplicate connection management in DRA plugin Fixes 2025-12-05 01:34:44 +09:00
Kai Wohlfahrt
2ba1b66b57 Fix kubelet certificate reload when connecting by IP
Currently, we set TLSConfig.Config.GetCertificate, but then also pass
certificate and key paths to http.Server.ListenAndServeTLS.

ListenAndServeTLS uses these paths to populate the TLS config Certificate
property. Then, when accepting connections, a non-nil Certificate is preferred
over GetCertificate if the ServerName is not set in ClientHelloInfo. Finally,
the Go TLS client doesn't set ServerName when connecting by IP. As a result,
when connecting to the kubelet by IP (e.g. to fetch pod logs), stale
certificates are served.

This patch passes empty certFile and keyFile arguments, to force the TLS
server to use the GetCertificate function.

This is done by clearing key/cert file config when setting GetCertificate as
suggested in PR review. This way, all downstream users of kubeDeps.TLSConfig
will do the right thing automatically.
2025-11-25 20:44:19 +01:00
Itamar Holder
792f1643d4 Add e2e tests
Signed-off-by: Itamar Holder <iholder@redhat.com>
2025-11-18 14:14:42 +02:00
Sascha Grunert
a66c025dc9 test/e2e_node: Update procMount test to use Restricted PSA level
Update the procMount test expectations to match the intentional PSA
policy relaxation introduced in commit e8bd3f629d.

As of Kubernetes 1.35+, Pod Security Admission Baseline policy
allows UnmaskedProcMount for pods with user namespaces (hostUsers:
false). This was an intentional change to support nested container
use cases while maintaining security through user namespace isolation.

The test "will fail to unmask proc mounts if not privileged" was
written before this relaxation and expected Baseline level to reject
UnmaskedProcMount. Since Baseline now allows it (for user namespace
pods), the test needs to use Restricted level instead, which
unconditionally blocks UnmaskedProcMount regardless of user namespace
settings.

Changes:
- Change PSA level from Baseline to Restricted
- Update test name to clarify it's testing Restricted level behavior
- Update framework name from "proc-mount-baseline-test" to
  "proc-mount-restricted-test"

Fixes the ci-crio-userns-e2e-serial test failure that started occurring
when runtimes began reporting user namespace support.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2025-11-14 10:17:54 +01:00
Stanislav Láznička
805eb885e3 node e2e: add tests for Ensure Secret Image Pulls default policy
Signed-off-by: Stanislav Láznička <slznika@microsoft.com>

Co-authored-by: Anish Ramasekar <anish.ramasekar@gmail.com>
2025-11-11 11:15:53 -05:00
Kubernetes Prow Robot
462ee14a36 Merge pull request #134345 from yuanwang04/restart-pod
Implement RestartAllContainers
2025-11-11 07:18:56 -08:00
Yuan Wang
0b47a37861 Keep pod in running state and prune past container status from runtime 2025-11-11 06:37:49 +00:00
Heba
aceb89debc KEP-5471: Extend tolerations operators (#134665)
* Add numeric operations to tolerations

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>

* code review feedback

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>

* add default feature gate

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>

* Add integration tests

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>

* Add toleration value validation

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>

* Add validate options for new operators

Signed-off-by: helayoty <heelayot@microsoft.com>

* Remove log

Signed-off-by: helayoty <heelayot@microsoft.com>

* Update feature gate check

Signed-off-by: helayoty <heelayot@microsoft.com>

* emove IsValidNumericString func

Signed-off-by: helayoty <heelayot@microsoft.com>

* Implement IsDecimalInteger

Signed-off-by: helayoty <heelayot@microsoft.com>

* code review feedback

Signed-off-by: helayoty <heelayot@microsoft.com>

* Add logs to v1/toleration

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>
Signed-off-by: helayoty <heelayot@microsoft.com>

* Update integration tests and address code review feedback

Signed-off-by: helayoty <heelayot@microsoft.com>

* Add feature gate to the scheduler framework

Signed-off-by: helayoty <heelayot@microsoft.com>

* Remove extra test

Signed-off-by: helayoty <heelayot@microsoft.com>

* Fix integration test

Signed-off-by: helayoty <heelayot@microsoft.com>

* pass feature gate via TolerationsTolerateTaint

Signed-off-by: helayoty <heelayot@microsoft.com>

---------

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>
Signed-off-by: helayoty <heelayot@microsoft.com>
2025-11-10 12:42:54 -08:00
Yuan Wang
2eb1eeeabf add disruptive tests 2025-11-10 09:41:02 +00:00
Yuan Wang
83c5cd5526 Implement restartPod action 2025-11-10 09:41:02 +00:00
Kubernetes Prow Robot
d777de7741 Merge pull request #135195 from haircommander/image-volume
KEP 4639: Move ImageVolume to on by default beta
2025-11-09 18:34:53 -08:00
Kubernetes Prow Robot
ef274e869c Merge pull request #135142 from stlaz/fix-node-conformance-failures-2
Fix node-conformance failures
2025-11-08 14:14:54 -08:00
Kubernetes Prow Robot
87eb6c5f7f Merge pull request #135225 from HirazawaUi/fix-envfiles-tests
Fix e2e test cases for EnvFiles
2025-11-08 12:14:52 -08:00
HirazawaUi
d979816a40 Fix e2e test cases for EnvFiles 2025-11-08 10:14:00 +08:00
Anish Ramasekar
d82fa1eb98 test: use localhost and HostNetwork for registry, mark test as disruptive
Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
2025-11-07 11:13:28 -08:00
Stanislav Láznička
ad0a3de152 node-conformance-e2e: restart the kubelet after loading credential config
Signed-off-by: Stanislav Láznička <slznika@microsoft.com>
2025-11-07 11:08:28 -08:00
Sascha Grunert
c7b277a32e KEP 4639: Move ImageVolume to on by default beta
Coauthored-by: Sascha Grunert <sgrunert@redhat.com>
Signed-off-by: Peter Hunt <pehunt@redhat.com>
2025-11-06 16:26:27 -05:00
Kubernetes Prow Robot
ee0485adb9 Merge pull request #134736 from haircommander/4210-ga
features: bump image gc max age feature to stable
2025-11-06 12:43: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
Kubernetes Prow Robot
8c2771a3de Merge pull request #135165 from HirazawaUi/fix-standalone-tests
Fix the failing e2e test case in Standalone mode.
2025-11-06 03:37:03 -08:00
Kubernetes Prow Robot
b07d0f852d Merge pull request #135168 from pohly/e2e-node-registry-flake
E2E node: temporarily disable flaky "pull from private registry"
2025-11-05 23:42:51 -08:00
Patrick Ohly
1499524e8e E2E node: temporarily disable flaky "pull from private registry"
This considerably impacts the ability to merge PRs right now because it fails
in the merge-blocking pull-kubernetes-node-e2e-containerd. Attempts to fix
it seem to be incomplete and need further
discussion (https://github.com/kubernetes/kubernetes/pull/135142),
so let's instead disable the test in the job.
2025-11-06 07:48:42 +01:00
HirazawaUi
71c02338df Fix the failing e2e test case in Standalone mode. 2025-11-06 13:10:46 +08:00
HirazawaUi
192d93f7cb add e2e tests for static pod and standalone mode 2025-11-06 09:18:23 +08: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
Kubernetes Prow Robot
0452b0aec7 Merge pull request #134746 from HirazawaUi/fix-restart-kubelet-1
KEP-4781: Restarting kubelet does not change pod status
2025-11-05 01:48:52 -08:00
Kubernetes Prow Robot
dec78c833d Merge pull request #135094 from stlaz/fix-node-conformance-failures
Fix failures in node-e2e image pull tests
2025-11-04 14:32:11 -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
Stanislav Láznička
a275785bd4 node conformance e2e: log fake registry creds on test failure 2025-11-04 17:26:40 +01:00
Stanislav Láznička
fba24a8e71 node-conformance-e2e: finite wait for pod status
Signed-off-by: Stanislav Láznička <slznika@microsoft.com>
2025-11-04 17:26:35 +01: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
HirazawaUi
acdf891478 add e2e tests 2025-11-01 12:55:01 +08:00
Swati Sehgal
f2d075ea65 Address review comments
Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
2025-10-31 17:41:34 +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
Kubernetes Prow Robot
34988e758d Merge pull request #134453 from stlaz/node-conformance-e2e
Fix node conformance tests with fake registry
2025-10-30 07:48:06 -07:00
Stanislav Láznička
428be46ba2 node conformance e2e: move registry cleanup to ginkgo.DeferCleanup
Signed-off-by: Stanislav Láznička <slznika@microsoft.com>
2025-10-30 15:00:57 +01:00
Stanislav Láznička
842cd0ea77 node conformance e2e: don't recreate test container on an error
Signed-off-by: Stanislav Láznička <slznika@microsoft.com>
2025-10-29 13:18:07 +01:00
Stanislav Láznička
135b46974a e2e registry: have SetupRegistry() return registry address 2025-10-29 13:18:06 +01:00
Stanislav Láznička
fc81e22735 fix Node Conformance Container Runtime test with fake registry
Signed-off-by: Stanislav Láznička <slznika@microsoft.com>
2025-10-29 13:17:03 +01:00
Kubernetes Prow Robot
036e624317 Merge pull request #134918 from mariafromano-25/cleanup-sidecar-feature
SidecarContainer feature to Node Conformance
2025-10-28 15:22:08 -07:00
Kubernetes Prow Robot
7be689fcd6 Merge pull request #134816 from swatisehgal/device-plugin-e2e-flakiness-2
node: e2e: update podresources check post fix of kubernetes#119423
2025-10-28 07:49:42 -07:00
Stanislav Láznička
a3f242676c Revert "remove failing test that depends on expired credential, remove credential, add TODOs"
This reverts commit 8ace0fb89f.
2025-10-28 14:23:54 +01:00
Maria Romano Silva
86bfcd5eec oopsie missed two, should fix failing tests 2025-10-28 01:26:32 +00:00
Maria Romano Silva
a277269159 updating sidecar feature to node conformance 2025-10-27 23:43:43 +00:00