Commit Graph

216 Commits

Author SHA1 Message Date
Kubernetes Prow Robot
051dd70772 Merge pull request #133149 from ritazh/draadminaccess-test
draadminaccess test make it serial
2025-07-23 19:56:55 -07:00
Kubernetes Prow Robot
ca569e152d Merge pull request #132700 from pohly/dra-kubelet-grpc-v1
DRA kubelet: add v1 gRPC
2025-07-23 17:36:26 -07:00
Rita Zhang
61cc6cf807 draadminaccess test make it serial
Signed-off-by: Rita Zhang <rita.z.zhang@gmail.com>
2025-07-23 09:13:13 -07:00
Kubernetes Prow Robot
49af85d86a Merge pull request #133110 from ritazh/DRAAdminAccess_upgradedowngradetest
DRAAdminAccess: add upgrade downgrade test
2025-07-23 07:08:28 -07:00
Patrick Ohly
f6061605fb DRA E2E: run multi-node control plane tests also with two nodes
The tests should work also with only two nodes, which is the minimum required
for conformance testing.
2025-07-23 09:12:46 +02:00
Patrick Ohly
f0e2920898 DRA E2E: simplify "control plane" test names
There's no need to clarify how many nodes are used in the test because the
overall test names are still unique without that (verified with go test -v
./test/e2e -args -list-tests | grep -w DRA | wc -l).
2025-07-23 09:10:45 +02:00
Patrick Ohly
603751ee80 DRA E2E: remove redundant test
"must be possible for the driver to update the ResourceClaim.Status.Devices
once allocated" was also run as kubelet test although it only checks the
control plane.

Before:
    [sig-node] [DRA] [FeatureGate:DynamicResourceAllocation] [Beta] [Feature:OffByDefault] control plane with single node [ConformanceCandidate] must be possible for the driver to update the ResourceClaim.Status.Devices once allocated [FeatureGate:DRAResourceClaimDeviceStatus] [Beta]
    [sig-node] [DRA] [FeatureGate:DynamicResourceAllocation] [Beta] [Feature:OffByDefault] kubelet [Feature:DynamicResourceAllocation] on single node must be possible for the driver to update the ResourceClaim.Status.Devices once allocated [FeatureGate:DRAResourceClaimDeviceStatus] [Beta]

After:
    [sig-node] [DRA] [FeatureGate:DynamicResourceAllocation] [Beta] [Feature:OffByDefault] control plane with single node [ConformanceCandidate] must be possible for the driver to update the ResourceClaim.Status.Devices once allocated [FeatureGate:DRAResourceClaimDeviceStatus] [Beta]
2025-07-23 09:10:45 +02:00
Rita Zhang
216f7485bd DRAAdminAccess: add upgrade downgrade test
Signed-off-by: Rita Zhang <rita.z.zhang@gmail.com>
2025-07-22 11:54:34 -07:00
Patrick Ohly
78bf3410c8 DRA E2E: revisit conformance classification of tests
All of these tests already ran successfully in
https://testgrid.k8s.io/sig-release-master-informing#kind-master-beta&include-filter-by-regex=DRA
and thus can get promoted to a conformance tests once DRA is GA.

The "control plane truncates the name of a generated resource claim" was marked
as depending on a recent kubelet incorrectly.

Removal of the feature label fixes b84271a779.

Removal of KubeletMinVersion for control plane tests depends on running only
kubelet tests in the kubelet version skew jobs.
2025-07-22 09:21:58 +02:00
Kubernetes Prow Robot
8e12e795d0 Merge pull request #133076 from pohly/dra-client-conversion-fix
DRA: fix conversion of watch
2025-07-20 12:52:29 -07:00
Rita Zhang
b84271a779 DRAAdminAccess: add e2e
Signed-off-by: Rita Zhang <rita.z.zhang@gmail.com>
2025-07-19 21:54:47 -07:00
Patrick Ohly
f77ce8951e DRA: debug output for list/watch client
Upgrade/downgrade testing after the DRA GA graduation gets stuck because the
ResourceSlice controller's informer doesn't pick up that the ResourceSlice got
deleted.

This additional log output shows a List+Watch after a watch got closed due to a
disconnect from the apiserver, so right now everything is working as expected.
2025-07-19 11:38:12 +02:00
Patrick Ohly
f141907ddd DRA kubelet: add v1 gRPC
The API is a direct copy of v1beta1, with v1beta1 replaced by v1.
The interoperability support is the same that was used for v1alpha4.
Adding it "reverts" the removal of the v1alpha4 support in
a57f15e081, except that now v1beta1 is the legacy
API which needs conversion. If kubelet and the plugin both support v1, no
conversion is needed.
2025-07-17 07:56:03 +02:00
Ed Bartosh
fc21d3f37d e2e: DRA: enable test plugin to cancel main context on error
Add a cancelMainContext field to ExamplePlugin and options. This
function allows the plugin to cancel an upper-level context when a
background error occurs. The HandleError method now calls this
function if it is set.

This enables DRA drivers to perform a graceful shutdown when a fatal
background error triggers context cancellation.
2025-07-16 15:49:41 +03:00
Ed Bartosh
1981c985b1 e2e: DRA: support test and public options
Refactor StartPlugin and related test helpers to accept a variadic
list of options of any type, allowing both public and test-specific
options to be passed.
2025-07-16 15:49:41 +03:00
Patrick Ohly
d44b737447 DRA: handle grpc.Server.Serve failures
Added an errHandler callback to startGRPCServer for handling errors.
Replaced direct logging of server failures with calls to the
provided error handler. This change ensures that errors are surfaced
and handled consistently.

Co-authored-by: Ed Bartosh <eduard.bartosh@intel.com>
2025-07-16 15:49:32 +03:00
Patrick Ohly
c8ca9249ac DRA integration: add upgrade/downgrade testing with local-up-cluster.sh
The test brings up the cluster and uses that power to run through
an upgrade/downgrade scenario. Version skew testing (running tests while the cluster
is partially up- or downgraded) could be added.

The new helper code for managing the cluster is written so that it could be
used both in an integration test and an E2E
test. https://github.com/kubernetes/kubernetes/pull/122481 could make that a
bit easier in an E2E test, but is not absolutely required.

In contrast to running on a normal cluster, pods need no privileges.
Instead, the caller has to make sure that the test itself can write
into system directories used by the cluster.
2025-07-15 12:54:40 +02:00
Patrick Ohly
60e9316c0c DRA E2E: refactor helper code
The helper code is useful for a separate Ginkgo suite for upgrade/downgrade
testing. We don't want to import test/e2e/dra there because that would also
define additional tests.
2025-07-15 12:54:40 +02:00
Patrick Ohly
2e3228e2ca DRA E2E: support deploying driver on localhost
If we know that the test binary shares the filesystem with the cluster (for
example, when using local-up-cluster.sh), then we can avoid the whole
complicated portproxy solution and work directly with the paths on the
host.

Only works with suitable permissions! /var/lib/kubelet/plugins,
/var/lib/kubelet/plugin_registry, and /var/run/cdi must be writable.

portproxy remains the default because it automatically gains sufficient
permissions also when combined with local-up-cluster.sh.
2025-07-15 12:52:27 +02:00
Patrick Ohly
f381d73724 DRA E2E: retry exec of hostpathplugin
We can recover from exec failing, the portproxy code already retries port
forwarding.
2025-07-15 12:52:27 +02:00
Patrick Ohly
c2080e7e45 DRA E2E: support using ktesting
This is a DRA-specific stop-gap solution for using the E2E framework together
with ktesting. Long-term this should better land in the E2E framework itself.
2025-07-15 12:52:27 +02:00
Patrick Ohly
5721c927e6 DRA E2E: increase verbosity of resource claim controller
Can be done via -vmodule, albeit not precisely because other controllers
also have a controller.go file.
2025-07-15 12:52:26 +02:00
Patrick Ohly
af249fb2e9 DRA E2E: test mixture of extended resources + ResourceClaim
This shows that a device plugin and DRA driver can be used together on the same
node.
2025-07-14 18:13:27 +02:00
Patrick Ohly
2dd07e9242 DRA E2E: ResourceSlice Controller test flake
There was one flake:

  expected pod to be pod is scheduled, got instead:
     ...
     status:
          conditions:
          - lastProbeTime: null
            lastTransitionTime: "2025-07-06T12:08:54Z"
            message: 'running "DynamicResources" filter plugin: pool network-attached is invalid:
              duplicate device name dev-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0000'

The root cause was that the test produced device names which were unique within
their slice, but not within the pool. This didn't matter for the test itself,
but for tests running concurrently of after it, because those slices were also
not cleaned up properly.

Timing in pull-kubernetes-e2e-gce also was different.
2025-07-09 15:56:06 +02:00
Patrick Ohly
ad0b2bf4f5 DRA E2E: serialize costly test
After enabling more tests in 00dd610c93,
periodic ci-kind-dra-all became unstable, with random flakes at the time when
the "supports sharing a claim sequentially". Probably the cluster became
overwhelmed by the number of pods which wanted to run in parallel. Running this
tests in the serial phase of a Ginkgo run should fix this.
2025-07-02 18:11:46 +02:00
Patrick Ohly
00dd610c93 DRA E2E: run some tests without feature label
Tests which only exercise the control plane don't need DRA drivers on the nodes
and thus can run in any cluster where the API and feature gate is
enabled. Eventually they can become conformance tests.

The actual test cases follow the same pattern and in some cases are run twice,
once for "control plane" testing and once for "kubelet" testing. The difference
is that in "control plane" mode, the driver's don't get deployed and pods are
only expected to get scheduled instead of starting to run.
2025-06-27 21:15:50 +02:00
Jon Huhn
8454093f09 DRA: add e2e test with initContainer using external claim 2025-06-19 15:19:00 -05:00
Kubernetes Prow Robot
bd44685ead Merge pull request #132317 from pohly/dra-kubelet-version-skew-labels
DRA E2E: label tests which need a certain minimum kubelet, II
2025-06-16 00:39:02 -07:00
Jon Huhn
fae2fdd052 DRA: wrap e2e finalizer update in retry 2025-06-15 23:49:43 -05:00
Patrick Ohly
233a0aeedb DRA E2E: label tests which need a certain minimum kubelet, II
Commit 71b2f32d70 missed one test which needs the
"kubelet >= 1.33" label because that test didn't run in the canary
presubmit. It's now failing in the ci-kind-dra-n-2 job.
2025-06-15 13:04:25 +02:00
Patrick Ohly
71b2f32d70 DRA E2E: label tests which need a certain minimum kubelet
This is used by n-1 and n-2 version skew jobs to exclude
current tests which cannot run with a certain older kubelet
release because the tested functionality wasn't present yet.
2025-06-12 18:16:04 +02:00
Kubernetes Prow Robot
0731167a99 Merge pull request #131996 from ritazh/dra-adminaccess-updatelabelkey
DRAAdminAccess: update label key
2025-06-04 12:16:45 -07:00
Kubernetes Prow Robot
4832b57e48 Merge pull request #131968 from pohly/dra-kubelet-prepare-validation
DRA kubelet: validation pass before changing claim info cache
2025-05-30 12:40:19 -07:00
Patrick Ohly
a5aabf9f7e DRA kubelet: validation pass before changing claim info cache
If preparing for a pod failed because the driver was not registered, it failed
after already having added the pod and claim to the claim info cache. The
effect was that deletion of the pod was blocked until the driver got
installed. Other errors had a similar effect. Now as many errors as possible
are checked in a read-only loop before proceeding to changing the claim info
cache.

The error message that was surfaced for the problem was not very readable:
   Failed to prepare dynamic resources: failed to get gRPC client for driver dra-1411.k8s.io: plugin name dra-1411.k8s.io not found in the list of registered DRA plugins

To address this, error messages and wrapping get updated according to these
guidelines:

    // Most errors returned by the manager show up in the context of a pod.
    // They try to adher to the following convention:
    // - Don't include the pod.
    // - Use terms that are familiar to users.
    // - Don't include the namespace, it can be inferred from the context.
    // - Avoid repeated "failed to ...: failed to ..." when wrapping errors.
    // - Avoid wrapping when it does not provide relevant additional information to keep the user-visible error short.
2025-05-30 09:52:22 +02:00
Rita Zhang
5058e385b0 DRAAdminAccess: update label key
Signed-off-by: Rita Zhang <rita.z.zhang@gmail.com>
2025-05-27 21:19:25 -07:00
Patrick Ohly
346fe182be DRA E2E: fail test when ResourceSlice publishing fails
This can happen when a test is run in a cluster where a required feature gate
is turned off. Letting the test continue then fails less clearly. For example,
a test for partitionable devices runs with ResourceSlices which don't have
the additional fields for partitionable devices.
2025-05-26 15:30:39 +02:00
Kubernetes Prow Robot
122219790f Merge pull request #131803 from pohly/dra-resource-slice-flake
DRA E2E: reduce risk of flake in ResourceSlice stress test
2025-05-23 02:08:36 -07:00
Kubernetes Prow Robot
ce450746a4 Merge pull request #131760 from bart0sh/PR178-dra-test-re-registration
DRA: test plugin re-registration after failed GetInfo call
2025-05-17 22:15:13 -07:00
Ed Bartosh
aef61622ae e2e: dra: implement ResetGRPCCalls 2025-05-16 21:53:35 +03:00
Ed Bartosh
e8be3e575b e2e: dra: simulate GetInfo failure 2025-05-16 21:53:30 +03:00
Kubernetes Prow Robot
17161cb45d Merge pull request #131617 from bart0sh/PR180-claimInfo-check-claimUID
DRA: kubelet: check for duplicate claim names
2025-05-16 04:53:14 -07:00
Patrick Ohly
ba77d27560 DRA E2E: reduce risk of flake in ResourceSlice stress test
In at least one case, the controller only got as far as creating 93 out of 100
slices in the allotted one minute:

    [FAILED] Timed out after 60.001s.
    Value for field 'Items' failed to satisfy matcher.
    Expected
        <[]v1beta2.ResourceSlice | len:93, cap:146>:
           ...
    to have length 100
    In [It] at: k8s.io/kubernetes/test/e2e/dra/dra.go:1520 @ 05/09/25 17:49:42.592
2025-05-16 07:52:55 +02:00
Ed Bartosh
ec7e732cbc e2e: dra: move gomega matchers to dedicated package
Moved gomega matcher definitions from test-driver/app
to a new test-driver/gomega package.
2025-05-15 20:55:17 +03:00
Patrick Ohly
bba9c49e10 e2e: DRA: test 2 claims with the same name
Co-Authored-By: Ed Bartosh <eduard.bartosh@intel.com>
2025-05-15 19:31:16 +03:00
Morten Torkildsen
26c198dc20 Some fixes 2025-05-12 16:08:15 +00:00
Morten Torkildsen
0b915a538f Cleanup after rebase 2025-05-12 16:02:11 +00:00
Morten Torkildsen
a6586aa610 Addressed comments 2025-05-12 16:01:01 +00:00
Morten Torkildsen
e262cccf23 Cleanup after rebase 2025-05-12 16:00:07 +00:00
Morten Torkildsen
8610404358 Add e2e tests for Partitionable Devices 2025-05-12 16:00:04 +00:00
Morten Torkildsen
ece35e5882 Update DRA e2e test framework to allow publishing advanced ResourceSlices 2025-05-12 15:56:24 +00:00