Skip to content

Commit 4e1c6da

Browse files
committed
CA-420987: xapi_message: Add message-destroy-all API
We've seen issues where a client will try to dismiss all their alerts and fail due to the message-destroy call hitting the maximum XAPI request size at ~5000 messages. A new message-destroy-all API avoids this issue while saving the bandwidth required to send a ref for each message. Signed-off-by: Christian Pardillo Laursen <[email protected]>
1 parent 68bf47d commit 4e1c6da

File tree

5 files changed

+23
-0
lines changed

5 files changed

+23
-0
lines changed

ocaml/idl/datamodel.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8915,6 +8915,10 @@ module Message = struct
89158915
~params:[(Set (Ref _message), "messages", "Messages to destroy")]
89168916
~allowed_roles:_R_POOL_OP ()
89178917

8918+
let destroy_all =
8919+
call ~name:"destroy_all" ~lifecycle:[] ~params:[] ~allowed_roles:_R_POOL_OP
8920+
()
8921+
89188922
let get_all =
89198923
call ~name:"get_all"
89208924
~lifecycle:[(Published, rel_orlando, "")]
@@ -9002,6 +9006,7 @@ module Message = struct
90029006
create
90039007
; destroy
90049008
; destroy_many
9009+
; destroy_all
90059010
; get
90069011
; get_all
90079012
; get_since

ocaml/idl/datamodel_lifecycle.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ let prototyped_of_message = function
215215
Some "24.14.0"
216216
| "PCI", "disable_dom0_access" ->
217217
Some "24.14.0"
218+
| "message", "destroy_all" ->
219+
Some "25.39.0-next"
218220
| "message", "destroy_many" ->
219221
Some "22.19.0"
220222
| "VTPM", "set_contents" ->

ocaml/xapi-cli-server/cli_frontend.ml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,15 @@ let rec cmdtable_data : (string * cmd_spec) list =
128128
; flags= []
129129
}
130130
)
131+
; ( "message-destroy-all"
132+
, {
133+
reqd= []
134+
; optn= []
135+
; help= "Destroy all existing messages"
136+
; implementation= No_fd Cli_operations.message_destroy_all
137+
; flags= []
138+
}
139+
)
131140
; ( "pool-enable-binary-storage"
132141
, {
133142
reqd= []

ocaml/xapi-cli-server/cli_operations.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,6 +1426,9 @@ let message_destroy (_ : printer) rpc session_id params =
14261426
in
14271427
Client.Message.destroy_many ~rpc ~session_id ~messages
14281428

1429+
let message_destroy_all (_ : printer) rpc session_id _ =
1430+
Client.Message.destroy_all ~rpc ~session_id
1431+
14291432
(* Pool operations *)
14301433

14311434
let get_pool_with_default rpc session_id params key =

ocaml/xapi/xapi_message.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,10 @@ let get_record ~__context ~self =
728728
(Api_errors.handle_invalid, ["message"; Ref.string_of self])
729729
)
730730

731+
let destroy_all ~__context =
732+
let messages = get_all ~__context in
733+
destroy_many ~__context ~messages
734+
731735
let get_all_records ~__context = get_real message_dir (fun _ -> true) 0.0
732736

733737
let get_all_records_where ~__context ~expr =

0 commit comments

Comments
 (0)