@@ -921,6 +921,30 @@ func (m *ManagerImpl) callPreStartContainerIfNeeded(podUID, contName, resource s
921
921
return nil
922
922
}
923
923
924
+ // callGetPreferredAllocationIfAvailable issues GetPreferredAllocation grpc
925
+ // call for device plugin resource with GetPreferredAllocationAvailable option set.
926
+ func (m * ManagerImpl ) callGetPreferredAllocationIfAvailable (podUID , contName , resource string , available , mustInclude sets.String , size int ) (sets.String , error ) {
927
+ eI , ok := m .endpoints [resource ]
928
+ if ! ok {
929
+ return nil , fmt .Errorf ("endpoint not found in cache for a registered resource: %s" , resource )
930
+ }
931
+
932
+ if eI .opts == nil || ! eI .opts .GetPreferredAllocationAvailable {
933
+ klog .V (4 ).Infof ("Plugin options indicate to skip GetPreferredAllocation for resource: %s" , resource )
934
+ return nil , nil
935
+ }
936
+
937
+ m .mutex .Unlock ()
938
+ klog .V (4 ).Infof ("Issuing a GetPreferredAllocation call for container, %s, of pod %s" , contName , podUID )
939
+ resp , err := eI .e .getPreferredAllocation (available .UnsortedList (), mustInclude .UnsortedList (), size )
940
+ m .mutex .Lock ()
941
+ if err != nil {
942
+ return nil , fmt .Errorf ("device plugin GetPreferredAllocation rpc failed with err: %v" , err )
943
+ }
944
+ // TODO: Add metrics support for init RPC
945
+ return sets .NewString (resp .ContainerResponses [0 ].DeviceIDs ... ), nil
946
+ }
947
+
924
948
// sanitizeNodeAllocatable scans through allocatedDevices in the device manager
925
949
// and if necessary, updates allocatableResource in nodeInfo to at least equal to
926
950
// the allocated capacity. This allows pods that have already been scheduled on
0 commit comments