Skip to content

CP-54034: Expose expected_votes in Cluster object #6374

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ocaml/idl/datamodel_cluster.ml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ let t =
; field ~qualifier:DynamicRO ~lifecycle:[] ~ty:Int "live_hosts"
~default_value:(Some (VInt 0L))
"Current number of live hosts, according to the cluster stack"
; field ~qualifier:DynamicRO ~lifecycle:[] ~ty:Int "expected_hosts"
~default_value:(Some (VInt 0L))
"Total number of hosts expected by the cluster stack"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand the exact meaning of "expected by the cluster stack". Is that the amount of nodes that the cluster stack has been configured with?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I understand that it's useful to expose the information for debugging, the difference in semantics of these numbers is quite subtle.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand the exact meaning of "expected by the cluster stack". Is that the amount of nodes that the cluster stack has been configured with?

Precisely

]
@ allowed_and_current_operations cluster_operation
@ [
Expand Down
2 changes: 1 addition & 1 deletion ocaml/idl/datamodel_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ open Datamodel_roles
to leave a gap for potential hotfixes needing to increment the schema version.*)
let schema_major_vsn = 5

let schema_minor_vsn = 788
let schema_minor_vsn = 789

(* Historical schema versions just in case this is useful later *)
let rio_schema_major_vsn = 5
Expand Down
2 changes: 2 additions & 0 deletions ocaml/idl/datamodel_lifecycle.ml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ let prototyped_of_field = function
Some "24.3.0"
| "Cluster_host", "live" ->
Some "24.3.0"
| "Cluster", "expected_hosts" ->
Some "25.16.0-next"
| "Cluster", "live_hosts" ->
Some "24.3.0"
| "Cluster", "quorum" ->
Expand Down
2 changes: 1 addition & 1 deletion ocaml/idl/schematest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let hash x = Digest.string x |> Digest.to_hex
(* BEWARE: if this changes, check that schema has been bumped accordingly in
ocaml/idl/datamodel_common.ml, usually schema_minor_vsn *)

let last_known_schema_hash = "0cf3458af211661024fca9c1d0ab34ab"
let last_known_schema_hash = "2f80cd8fbfd0eedab4dfe345565bcb64"

let current_schema_hash : string =
let open Datamodel_types in
Expand Down
5 changes: 3 additions & 2 deletions ocaml/tests/common/test_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -626,12 +626,13 @@ let make_cluster_and_cluster_host ~__context ?(ref = Ref.make ())
?(token_timeout = Constants.default_token_timeout_s)
?(token_timeout_coefficient = Constants.default_token_timeout_coefficient_s)
?(cluster_config = []) ?(other_config = []) ?(host = Ref.null)
?(is_quorate = false) ?(quorum = 0L) ?(live_hosts = 0L) () =
?(is_quorate = false) ?(quorum = 0L) ?(live_hosts = 0L)
?(expected_hosts = 0L) () =
Db.Cluster.create ~__context ~ref ~uuid ~cluster_token ~pending_forget:[]
~cluster_stack ~cluster_stack_version ~allowed_operations
~current_operations ~pool_auto_join ~token_timeout
~token_timeout_coefficient ~cluster_config ~other_config ~is_quorate ~quorum
~live_hosts ;
~live_hosts ~expected_hosts ;
let cluster_host_ref =
make_cluster_host ~__context ~cluster:ref ~host ~pIF ()
in
Expand Down
1 change: 1 addition & 0 deletions ocaml/tests/test_cluster.ml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ let test_clusterd_rpc ~__context call =
; num_times_booted= 1
; is_quorate= true
; total_votes= 1
; expected_votes= 1
; quorum= 1
; quorum_members= Some [me]
; is_running= true
Expand Down
2 changes: 1 addition & 1 deletion ocaml/tests/test_cluster_host.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let create_cluster ~__context pool_auto_join =
~token_timeout_coefficient:Constants.default_token_timeout_coefficient_s
~allowed_operations:[] ~current_operations:[] ~pool_auto_join
~cluster_config:[] ~other_config:[] ~pending_forget:[] ~is_quorate:false
~quorum:0L ~live_hosts:0L ;
~quorum:0L ~live_hosts:0L ~expected_hosts:0L ;
cluster_ref

let check_cluster_option =
Expand Down
3 changes: 3 additions & 0 deletions ocaml/xapi-cli-server/records.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5132,6 +5132,9 @@ let cluster_record rpc session_id cluster =
; make_field ~name:"live-hosts"
~get:(fun () -> Int64.to_string (x ()).API.cluster_live_hosts)
()
; make_field ~name:"expected-hosts"
~get:(fun () -> Int64.to_string (x ()).API.cluster_expected_hosts)
()
]
}

Expand Down
4 changes: 4 additions & 0 deletions ocaml/xapi-idl/cluster/cluster_interface.ml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ type optional_path = string option [@@deriving rpcty]
type quorum_info = {
is_quorate: bool
; total_votes: int
(* number of nodes that the cluster stack thinks are currently in the cluster *)
; expected_votes: int
(* number of nodes that the cluster stack is expecting to be in the cluster *)
; quorum: int (** number of nodes required to form a quorum *)
; quorum_members: all_members option
}
Expand All @@ -179,6 +182,7 @@ type diagnostics = {
; is_quorate: bool
; is_running: bool
; total_votes: int
; expected_votes: int
; quorum: int
; quorum_members: all_members option
; startup_finished: bool
Expand Down
2 changes: 1 addition & 1 deletion ocaml/xapi/xapi_cluster.ml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ let create ~__context ~pIF ~cluster_stack ~pool_auto_join ~token_timeout
~pending_forget:[] ~pool_auto_join ~token_timeout
~token_timeout_coefficient ~current_operations:[]
~allowed_operations:[] ~cluster_config:[] ~other_config:[]
~is_quorate:false ~quorum:0L ~live_hosts:0L ;
~is_quorate:false ~quorum:0L ~live_hosts:0L ~expected_hosts:0L ;
Db.Cluster_host.create ~__context ~ref:cluster_host_ref
~uuid:cluster_host_uuid ~cluster:cluster_ref ~host ~enabled:true
~pIF ~current_operations:[] ~allowed_operations:[] ~other_config:[]
Expand Down
2 changes: 2 additions & 0 deletions ocaml/xapi/xapi_clustering.ml
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,8 @@ module Watcher = struct
Db.Cluster.set_quorum ~__context ~self:cluster
~value:(Int64.of_int diag.quorum) ;
Db.Cluster.set_live_hosts ~__context ~self:cluster
~value:(Int64.of_int diag.total_votes) ;
Db.Cluster.set_expected_hosts ~__context ~self:cluster
~value:(Int64.of_int diag.total_votes)
| Error (InternalError message) | Error (Unix_error message) ->
warn "%s Cannot query diagnostics due to %s, not performing update"
Expand Down
Loading