mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +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 {
|
type endpoint interface {
|
||||||
run()
|
run()
|
||||||
stop()
|
stop()
|
||||||
|
getPreferredAllocation(available, mustInclude []string, size int) (*pluginapi.PreferredAllocationResponse, error)
|
||||||
allocate(devs []string) (*pluginapi.AllocateResponse, error)
|
allocate(devs []string) (*pluginapi.AllocateResponse, error)
|
||||||
preStartContainer(devs []string) (*pluginapi.PreStartContainerResponse, error)
|
preStartContainer(devs []string) (*pluginapi.PreStartContainerResponse, error)
|
||||||
callback(resourceName string, devices []pluginapi.Device)
|
callback(resourceName string, devices []pluginapi.Device)
|
||||||
@ -138,6 +139,22 @@ func (e *endpointImpl) setStopTime(t time.Time) {
|
|||||||
e.stopTime = t
|
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.
|
// allocate issues Allocate gRPC call to the device plugin.
|
||||||
func (e *endpointImpl) allocate(devs []string) (*pluginapi.AllocateResponse, error) {
|
func (e *endpointImpl) allocate(devs []string) (*pluginapi.AllocateResponse, error) {
|
||||||
if e.isStopped() {
|
if e.isStopped() {
|
||||||
|
Loading…
Reference in New Issue
Block a user