@@ -35,6 +35,7 @@ import (
35
35
type endpoint interface {
36
36
run ()
37
37
stop ()
38
+ getPreferredAllocation (available , mustInclude []string , size int ) (* pluginapi.PreferredAllocationResponse , error )
38
39
allocate (devs []string ) (* pluginapi.AllocateResponse , error )
39
40
preStartContainer (devs []string ) (* pluginapi.PreStartContainerResponse , error )
40
41
callback (resourceName string , devices []pluginapi.Device )
@@ -138,6 +139,22 @@ func (e *endpointImpl) setStopTime(t time.Time) {
138
139
e .stopTime = t
139
140
}
140
141
142
+ // getPreferredAllocation issues GetPreferredAllocation gRPC call to the device plugin.
143
+ func (e * endpointImpl ) getPreferredAllocation (available , mustInclude []string , size int ) (* pluginapi.PreferredAllocationResponse , error ) {
144
+ if e .isStopped () {
145
+ return nil , fmt .Errorf (errEndpointStopped , e )
146
+ }
147
+ return e .client .GetPreferredAllocation (context .Background (), & pluginapi.PreferredAllocationRequest {
148
+ ContainerRequests : []* pluginapi.ContainerPreferredAllocationRequest {
149
+ {
150
+ AvailableDeviceIDs : available ,
151
+ MustIncludeDeviceIDs : mustInclude ,
152
+ AllocationSize : int32 (size ),
153
+ },
154
+ },
155
+ })
156
+ }
157
+
141
158
// allocate issues Allocate gRPC call to the device plugin.
142
159
func (e * endpointImpl ) allocate (devs []string ) (* pluginapi.AllocateResponse , error ) {
143
160
if e .isStopped () {
0 commit comments