Project-HAMi / HAMi

Heterogeneous AI Computing Virtualization Middleware
http://project-hami.io/
Apache License 2.0
957 stars 197 forks source link

fix(scheduler): prevent array out-of-bounds when GPU containers are placed between non-GPU containers #572

Closed Nimbus318 closed 3 weeks ago

Nimbus318 commented 4 weeks ago

What type of PR is this? /kind bug

What this PR does / why we need it: This PR fixes a bug in the scheduler where an array out-of-bounds error occurs when a GPU container is placed between non-GPU containers in a multi-container Pod. The bug manifests when the GPU container must be positioned at the beginning or end of the container list, otherwise, it leads to a panic with an array index error. Ensuring that the length of score.Devices[idx] is sufficient before appending resolves this issue. The scheduler now handles this scenario by extending the score.Devices array correctly.

Which issue(s) this PR fixes: Fixes #571

Special notes for your reviewer: None

Does this PR introduce a user-facing change?: None

archlitchi commented 4 weeks ago

A very god PR, please sign your commit:)

Nimbus318 commented 4 weeks ago

@archlitchi Thanks for the reminder! I've signed the commit now. Please check and let me know if everything looks good. :)

archlitchi commented 3 weeks ago

/approve

codecov[bot] commented 3 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Flag Coverage Δ
unittests 27.09% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/scheduler/score.go 67.05% <100.00%> (ø)