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.
This commit is contained in:
Patrick Ohly
2025-05-25 18:17:23 +02:00
parent dae746b59d
commit 346fe182be

View File

@@ -432,6 +432,21 @@ func (d *Driver) SetUp(nodes *Nodes, driverResources map[string]resourceslice.Dr
klog.Background().Info("deleting CDI file", "node", nodename, "filename", name)
return d.removeFile(&pod, name)
},
ErrorHandler: func(ctx context.Context, err error, msg string) {
// Record a failure, but don't kill the background goroutine.
defer ginkgo.GinkgoRecover()
// During tests when canceling the context it is possible to get all kinds of
// follow-up errors for that, like:
// processing ResourceSlice objects: retrieve node "127.0.0.1": client rate limiter Wait returned an error: context canceled
//
// The "context canceled" error was not wrapped, so `errors.Is` doesn't work.
// Instead of trying to detect errors which can be ignored, let's only
// treat errors as failures which definitely shouldn't occur:
var droppedFields *resourceslice.DroppedFieldsError
if errors.As(err, &droppedFields) {
framework.Failf("driver %s: %v", d.Name, err)
}
},
}
if dr, ok := driverResources[nodename]; ok {