Skip to content

Commit

Permalink
Change argument of resort_guidances
Browse files Browse the repository at this point in the history
Signed-off-by: Rob Hoes <[email protected]>
  • Loading branch information
robhoes committed Aug 18, 2023
1 parent 4b27b24 commit a1a1562
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion ocaml/tests/test_repository_helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2755,7 +2755,8 @@ module GuidanceSetResortGuidancesTest = Generic.MakeStateless (struct
let transform (kind, guidances) =
guidances
|> GuidanceSet.of_list
|> GuidanceSet.resort_guidances ~kind
|> GuidanceSet.resort_guidances
~remove_evacuations:(kind = Guidance.Absolute)
|> GuidanceSet.elements

let tests =
Expand Down
11 changes: 7 additions & 4 deletions ocaml/xapi/repository_helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ module GuidanceSet = struct
; (EvacuateHost, of_list [RestartDeviceModel])
]

let resort_guidances ~kind gs =
let resort_guidances ~remove_evacuations gs =
let gs' =
List.fold_left
(fun acc (higher, lowers) ->
Expand All @@ -143,7 +143,10 @@ module GuidanceSet = struct
)
gs precedences
in
match kind with Recommended -> gs' | Absolute -> remove EvacuateHost gs'
if remove_evacuations then
remove EvacuateHost gs'
else
gs'
end

let create_repository_record ~__context ~name_label ~name_description
Expand Down Expand Up @@ -647,7 +650,7 @@ let eval_guidances ~updates_info ~updates ~kind ~livepatches ~failed_livepatches
)
GuidanceSet.empty updates
|> append_livepatch_guidances ~updates_info ~upd_ids_of_livepatches
|> GuidanceSet.resort_guidances ~kind
|> GuidanceSet.resort_guidances ~remove_evacuations:(kind = Guidance.Absolute)
|> GuidanceSet.elements

let merge_with_unapplied_guidances ~__context ~host ~guidances =
Expand All @@ -657,7 +660,7 @@ let merge_with_unapplied_guidances ~__context ~host ~guidances =
|> List.filter (fun g -> g <> Guidance.RebootHostOnLivePatchFailure)
|> of_list
|> union (of_list guidances)
|> resort_guidances ~kind:Guidance.Recommended
|> resort_guidances ~remove_evacuations:false
|> elements

let repoquery_sep = ":|"
Expand Down

0 comments on commit a1a1562

Please sign in to comment.