Skip to content

Extend the Allocate to return scores #19

@kerthcet

Description

@kerthcet

Now in Interface Policy, we only return devices when calling Allocate, this is definitely enough for k8s-device-plugin, however, as a kubernetes scheduler developer, I would like to leverage this helper library to build GPU topology aware scheduler plugin, specifically the score extension point which requires a score in prioritizing

type Policy interface {
// Allocate is meant to do the heavy-lifting of implementing the actual
// allocation strategy of the policy. It takes a slice of devices to
// allocate GPUs from, and an amount 'size' to allocate from that slice. It
// then returns a subset of devices of length 'size'. If the policy is
// unable to allocate 'size' GPUs from the slice of input devices, it
// returns an empty slice.
Allocate(available []*Device, required []*Device, size int) []*Device
}

so I wonder whether we can extend the Allocate method return two values, like

	Allocate(available []*Device, required []*Device, size int) ([]*Device, int)

Which then can be reused by other components.

The disadvantage is some policy like SimplyPolicy doesn't need the score at all.

Another option is we'll add another interface like PriorityPolicy which helps in prioritizing then the bestEffort policy can implement it. This requires to change the allocator.Allocator() anyway.

cc @elezar @klueska

I can help to implement either way if accepted, hope to see your feedbacks.

/kind feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions