mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Add GetPreferredAllocation() as a supported device plugin endpoint
This commit is contained in:
parent
32c047a52e
commit
abf87c99c6
@ -35,6 +35,7 @@ import (
|
||||
type endpoint interface {
|
||||
run()
|
||||
stop()
|
||||
getPreferredAllocation(available, mustInclude []string, size int) (*pluginapi.PreferredAllocationResponse, error)
|
||||
allocate(devs []string) (*pluginapi.AllocateResponse, error)
|
||||
preStartContainer(devs []string) (*pluginapi.PreStartContainerResponse, error)
|
||||
callback(resourceName string, devices []pluginapi.Device)
|
||||
@ -138,6 +139,22 @@ func (e *endpointImpl) setStopTime(t time.Time) {
|
||||
e.stopTime = t
|
||||
}
|
||||
|
||||
// getPreferredAllocation issues GetPreferredAllocation gRPC call to the device plugin.
|
||||
func (e *endpointImpl) getPreferredAllocation(available, mustInclude []string, size int) (*pluginapi.PreferredAllocationResponse, error) {
|
||||
if e.isStopped() {
|
||||
return nil, fmt.Errorf(errEndpointStopped, e)
|
||||
}
|
||||
return e.client.GetPreferredAllocation(context.Background(), &pluginapi.PreferredAllocationRequest{
|
||||
ContainerRequests: []*pluginapi.ContainerPreferredAllocationRequest{
|
||||
{
|
||||
AvailableDeviceIDs: available,
|
||||
MustIncludeDeviceIDs: mustInclude,
|
||||
AllocationSize: int32(size),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// allocate issues Allocate gRPC call to the device plugin.
|
||||
func (e *endpointImpl) allocate(devs []string) (*pluginapi.AllocateResponse, error) {
|
||||
if e.isStopped() {
|
||||
|
Loading…
Reference in New Issue
Block a user