Skip to content

Commit

Permalink
Fix host choice for vGPU allocation
Browse files Browse the repository at this point in the history
The ordering for the group_by function when grouping hosts based on "best" PGPU
was not specified. Now the hosts should be ordered and grouped correctly
according to GPU_group.allocation_algorithm.

Signed-off-by: Si Beaumont <simon.beaumont@citrix.com>
  • Loading branch information
simonjbeaumont committed Aug 27, 2013
1 parent 4b490fa commit af6fdfc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
8 changes: 4 additions & 4 deletions ocaml/xapi/helpers.ml
Expand Up @@ -505,10 +505,10 @@ let group_by f list =

(** Groups list elements by equality of result of function application sorted
* in order of that result *)
let group_by ?(descending=false) f list =
match descending with
| true -> group_by f list
| false -> List.rev (group_by f list)
let group_by ~ordering f list =
match ordering with
| `descending -> group_by f list
| `ascending -> List.rev (group_by f list)

(** Schwarzian transform sort *)
let sort_by_schwarzian ?(descending=false) f list =
Expand Down
11 changes: 6 additions & 5 deletions ocaml/xapi/xapi_vm_helpers.ml
Expand Up @@ -574,12 +574,13 @@ let group_hosts_by_best_pgpu_in_group ~__context gpu_group vgpu_type =
(List.map (fun pgpu -> Db.PGPU.get_host ~__context ~self:pgpu)
viable_pgpus)
in
Helpers.group_by
let ordering =
match Db.GPU_group.get_allocation_algorithm ~__context ~self:gpu_group with
| `depth_first -> `ascending | `breadth_first -> `descending
in
Helpers.group_by ~ordering
(fun host ->
let group_by_capacity pgpus =
(match Db.GPU_group.get_allocation_algorithm ~__context ~self:gpu_group with
| `depth_first -> Helpers.group_by ~descending:false
| `breadth_first -> Helpers.group_by ~descending:true)
let group_by_capacity pgpus = Helpers.group_by ~ordering
(fun pgpu -> Xapi_pgpu_helpers.get_remaining_capacity ~__context ~self:pgpu ~vgpu_type)
pgpus
in
Expand Down

0 comments on commit af6fdfc

Please sign in to comment.