-
Notifications
You must be signed in to change notification settings - Fork 312
Optimize Fit-in-device logic to make it device-specific #1097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: limengxuan <[email protected]>
Signed-off-by: limengxuan <[email protected]>
Signed-off-by: limengxuan <[email protected]>
Signed-off-by: limengxuan <[email protected]>
Signed-off-by: limengxuan <[email protected]>
Signed-off-by: limengxuan <[email protected]>
Signed-off-by: limengxuan <[email protected]>
Signed-off-by: limengxuan <[email protected]>
Signed-off-by: limengxuan <[email protected]>
Signed-off-by: limengxuan <[email protected]>
Signed-off-by: limengxuan <[email protected]>
Signed-off-by: limengxuan <[email protected]>
Signed-off-by: limengxuan <[email protected]>
/assign @lengrongfu @Shouren |
@archlitchi After a quick review of this pr, i find there are lots of duplicated code in the current implementation, especially in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For devices in pkg/device
, the CheckType
and CheckUUID
functions should start with a lower case which keeps up with modification to customFilterRule
function.
found, numa := nv.CheckType(annos, *dev, k) | ||
if !found { | ||
reason[common.CardTypeMismatch]++ | ||
klog.V(5).InfoS(common.CardTypeMismatch, "pod", klog.KObj(pod), "device", dev.ID, dev.Type, k.Type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this logger level we can unified debug is 4. Other log levels are similar.
@@ -290,3 +287,99 @@ func (dev *Devices) AddResourceUsage(n *util.DeviceUsage, ctr *util.ContainerDev | |||
n.Usedmem += ctr.Usedmem | |||
return nil | |||
} | |||
|
|||
func (npu *Devices) Fit(devices []*util.DeviceUsage, request util.ContainerDeviceRequest, annos map[string]string, pod *corev1.Pod, allocated *util.PodDevices) (bool, map[string]util.ContainerDevices, string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function l found every device type there is a similar logic, is there a better implementation of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel the same way, Fine-grained interfaces are more friendly to subsequent scheduler expansion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's our next move, we need to remove redundant logic in fit for each devices
yes, we need refine some logics here, for now, i just copy original fitInCertain method to every devices |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: archlitchi The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: limengxuan <[email protected]>
/lgtm |
/lgtm |
/kind feature
Right now, a unified fitInCertainDevice is responsible for all devices, which is a very bad design, it causes many unnecessary logic among different types of device.
We need to optimize that by make fit logic device-specific, implemented by device interface.So We did several adjustment to device API, such as
Add interface Fit
Remove interface CheckType, CheckUUID, CustomFilterRule. Because these logics can be implemented in Fit directly