package app
import "k8s.io/kubernetes/test/e2e/dra/test-driver/app"
Package app does all of the work necessary to configure and run a Kubernetes app process.
Index ¶
- func NewCommand() *cobra.Command
- type ClaimID
- type Device
- type DeviceHealthUpdate
- type ExamplePlugin
- func StartPlugin(ctx context.Context, cdiDir, driverName string, kubeClient kubernetes.Interface, nodeName string, fileOps FileOperations, opts ...any) (*ExamplePlugin, error)
- func (ex *ExamplePlugin) BlockNodePrepareResources() func()
- func (ex *ExamplePlugin) BlockNodeUnprepareResources() func()
- func (ex *ExamplePlugin) CountCalls(methodSuffix string) int
- func (ex *ExamplePlugin) GetGRPCCalls() []GRPCCall
- func (ex *ExamplePlugin) GetPreparedResources() []ClaimID
- func (ex *ExamplePlugin) HandleError(ctx context.Context, err error, msg string)
- func (ex *ExamplePlugin) IsRegistered() bool
- func (ex *ExamplePlugin) NodeWatchResources(req *drahealthv1alpha1.NodeWatchResourcesRequest, srv drahealthv1alpha1.DRAResourceHealth_NodeWatchResourcesServer) error
- func (ex *ExamplePlugin) PrepareResourceClaims(ctx context.Context, claims []*resourceapi.ResourceClaim) (map[types.UID]kubeletplugin.PrepareResult, error)
- func (ex *ExamplePlugin) ResetGRPCCalls()
- func (ex *ExamplePlugin) SetGetInfoError(err error)
- func (ex *ExamplePlugin) SetNodePrepareResourcesFailureMode() func()
- func (ex *ExamplePlugin) SetNodeUnprepareResourcesFailureMode() func()
- func (ex *ExamplePlugin) Stop()
- func (ex *ExamplePlugin) UnprepareResourceClaims(ctx context.Context, claims []kubeletplugin.NamespacedObject) (map[types.UID]error, error)
- func (ex *ExamplePlugin) UpdateStatus(ctx context.Context, resourceClaim *resourceapi.ResourceClaim) (*resourceapi.ResourceClaim, error)
- type FileOperations
- type GRPCCall
- type Options
- type TestOption
Functions ¶
func NewCommand ¶
NewCommand creates a *cobra.Command object with default parameters.
Types ¶
type ClaimID ¶
ClaimID contains both claim name and UID to simplify debugging. The namespace is not included because it is random in E2E tests and the UID is sufficient to make the ClaimID unique.
type Device ¶
type DeviceHealthUpdate ¶
type ExamplePlugin ¶
type ExamplePlugin struct { drahealthv1alpha1.UnimplementedDRAResourceHealthServer HealthControlChan chan DeviceHealthUpdate // contains filtered or unexported fields }
func StartPlugin ¶
func StartPlugin(ctx context.Context, cdiDir, driverName string, kubeClient kubernetes.Interface, nodeName string, fileOps FileOperations, opts ...any) (*ExamplePlugin, error)
StartPlugin sets up the servers that are necessary for a DRA kubelet plugin.
func (*ExamplePlugin) BlockNodePrepareResources ¶
func (ex *ExamplePlugin) BlockNodePrepareResources() func()
BlockNodePrepareResources locks blockPrepareResourcesMutex and returns unlocking function for it
func (*ExamplePlugin) BlockNodeUnprepareResources ¶
func (ex *ExamplePlugin) BlockNodeUnprepareResources() func()
BlockNodeUnprepareResources locks blockUnprepareResourcesMutex and returns unlocking function for it
func (*ExamplePlugin) CountCalls ¶
func (ex *ExamplePlugin) CountCalls(methodSuffix string) int
CountCalls counts GRPC calls with the given method suffix.
func (*ExamplePlugin) GetGRPCCalls ¶
func (ex *ExamplePlugin) GetGRPCCalls() []GRPCCall
func (*ExamplePlugin) GetPreparedResources ¶
func (ex *ExamplePlugin) GetPreparedResources() []ClaimID
func (*ExamplePlugin) HandleError ¶
func (ex *ExamplePlugin) HandleError(ctx context.Context, err error, msg string)
func (*ExamplePlugin) IsRegistered ¶
func (ex *ExamplePlugin) IsRegistered() bool
func (*ExamplePlugin) NodeWatchResources ¶
func (ex *ExamplePlugin) NodeWatchResources(req *drahealthv1alpha1.NodeWatchResourcesRequest, srv drahealthv1alpha1.DRAResourceHealth_NodeWatchResourcesServer) error
func (*ExamplePlugin) PrepareResourceClaims ¶
func (ex *ExamplePlugin) PrepareResourceClaims(ctx context.Context, claims []*resourceapi.ResourceClaim) (map[types.UID]kubeletplugin.PrepareResult, error)
func (*ExamplePlugin) ResetGRPCCalls ¶
func (ex *ExamplePlugin) ResetGRPCCalls()
ResetGRPCCalls clears the internal tracking of GRPC calls made to the plugin. This is useful in tests to start with a clean slate when verifying plugin registration behavior, particularly when testing registration retry scenarios.
func (*ExamplePlugin) SetGetInfoError ¶
func (ex *ExamplePlugin) SetGetInfoError(err error)
SetGetInfoError sets an error to be returned by the plugin's GetInfo call. This can be used in tests to simulate a registration failure scenario, allowing verification that the kubelet plugin manager retries registration when GetInfo fails.
To restore normal GetInfo behavior, call SetGetInfoError(nil).
func (*ExamplePlugin) SetNodePrepareResourcesFailureMode ¶
func (ex *ExamplePlugin) SetNodePrepareResourcesFailureMode() func()
SetNodePrepareResourcesFailureMode sets the failure mode for NodePrepareResources call and returns a function to unset the failure mode
func (*ExamplePlugin) SetNodeUnprepareResourcesFailureMode ¶
func (ex *ExamplePlugin) SetNodeUnprepareResourcesFailureMode() func()
SetNodeUnprepareResourcesFailureMode sets the failure mode for NodeUnprepareResources call and returns a function to unset the failure mode
func (*ExamplePlugin) Stop ¶
func (ex *ExamplePlugin) Stop()
Stop ensures that all servers are stopped and resources freed.
func (*ExamplePlugin) UnprepareResourceClaims ¶
func (ex *ExamplePlugin) UnprepareResourceClaims(ctx context.Context, claims []kubeletplugin.NamespacedObject) (map[types.UID]error, error)
func (*ExamplePlugin) UpdateStatus ¶
func (ex *ExamplePlugin) UpdateStatus(ctx context.Context, resourceClaim *resourceapi.ResourceClaim) (*resourceapi.ResourceClaim, error)
type FileOperations ¶
type FileOperations struct { // Create must overwrite the file. Create func(name string, content []byte) error // Remove must remove the file. It must not return an error when the // file does not exist. Remove func(name string) error // HandleError is an optional callback for ResourceSlice publishing problems. HandleError func(ctx context.Context, err error, msg string) // DriverResources provides the information that the driver will use to // construct the ResourceSlices that it will publish. DriverResources *resourceslice.DriverResources }
FileOperations defines optional callbacks for handling CDI files and some other configuration.
type GRPCCall ¶
type GRPCCall struct { // FullMethod is the fully qualified, e.g. /package.service/method. FullMethod string // Request contains the parameters of the call. Request interface{} // Response contains the reply of the plugin. It is nil for calls that are in progress. Response interface{} // Err contains the error return value of the plugin. It is nil for calls that are in progress or succeeded. Err error }
type Options ¶
type Options struct { EnableHealthService bool }
type TestOption ¶
type TestOption func(o *options) error
TestOption implements the functional options pattern dedicated for usage in testing code.
func CancelMainContext ¶
func CancelMainContext(cancel context.CancelCauseFunc) TestOption
CancelMainContext sets a context cancellation function for the plugin. This function is called by HandleError when an error occurs in the background.
Source Files ¶
cdi.go kubeletplugin.go options.go server.go
- Version
- v1.35.0-alpha.0
- Published
- Aug 2, 2025
- Platform
- js/wasm
- Imports
- 41 packages
- Last checked
- 4 minutes ago –
Tools for package owners.