Skip to content

Commit 02ca33e

Browse files
committed
CA-404512: Add feature flag to the new clustering interface
The new clustering interface uses a constructor `Extended` address when a cluster hots is trying to join a cluster. This causes problems during upgrades as a newly upgraded host might send out the new address format to old hosts, which do not understand this format, causing the new hosts not able to join. The fix would be to use a new cluster_address feature flag/pool restrictions to control the use of the new clustering interface. This makes sure that the new interface would only be used if all of the hosts understand this new interface, i.e. have this feature enabled. The cluster_address feature is controlled by v6d and is pool-wide, therefore the new interface would only be enabled if all v6ds are updated to the correct level, which also implies that the accompanying xapi are updated to the correct level. Signed-off-by: Vincent Liu <[email protected]>
1 parent 96f7cd1 commit 02ca33e

File tree

6 files changed

+31
-22
lines changed

6 files changed

+31
-22
lines changed

ocaml/xapi-types/features.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ type feature =
5858
| USB_passthrough
5959
| Network_sriov
6060
| Corosync
61+
| Cluster_address
6162
| Zstd_export
6263
| Pool_secret_rotation
6364
| Certificate_verification
@@ -123,6 +124,7 @@ let keys_of_features =
123124
; (USB_passthrough, ("restrict_usb_passthrough", Negative, "USB_passthrough"))
124125
; (Network_sriov, ("restrict_network_sriov", Negative, "Network_sriov"))
125126
; (Corosync, ("restrict_corosync", Negative, "Corosync"))
127+
; (Cluster_address, ("restrict_cluster_address", Negative, "Cluster_address"))
126128
; (Zstd_export, ("restrict_zstd_export", Negative, "Zstd_export"))
127129
; ( Pool_secret_rotation
128130
, ("restrict_pool_secret_rotation", Negative, "Pool_secret_rotation")

ocaml/xapi-types/features.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ type feature =
6565
| USB_passthrough (** Enable the use of USB passthrough. *)
6666
| Network_sriov (** Enable the use of Network SRIOV. *)
6767
| Corosync (** Enable the use of corosync. *)
68+
| Cluster_address (** Enable the use of extended cluster address interface *)
6869
| Zstd_export (** Enable the use of VM export with zstd compression. *)
6970
| Pool_secret_rotation (** Enable Pool Secret Rotation *)
7071
| Certificate_verification (** Used by XenCenter *)

ocaml/xapi/xapi_cluster.ml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
*)
1414

1515
open Xapi_clustering
16-
open Ipaddr_rpc_type
1716

1817
module D = Debug.Make (struct let name = "xapi_cluster" end)
1918

@@ -65,12 +64,8 @@ let create ~__context ~pIF ~cluster_stack ~pool_auto_join ~token_timeout
6564
let hostuuid = Inventory.lookup Inventory._installation_uuid in
6665
let hostname = Db.Host.get_hostname ~__context ~self:host in
6766
let member =
68-
Extended
69-
{
70-
ip= Ipaddr.of_string_exn (ipstr_of_address ip_addr)
71-
; hostuuid
72-
; hostname
73-
}
67+
Xapi_cluster_host_helpers.get_cluster_host_address ~__context ~ip_addr
68+
~hostuuid ~hostname
7469
in
7570
let token_timeout_ms = Int64.of_float (token_timeout *. 1000.0) in
7671
let token_timeout_coefficient_ms =

ocaml/xapi/xapi_cluster_helpers.ml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
* GNU Lesser General Public License for more details.
1313
*)
1414

15+
module D = Debug.Make (struct let name = __MODULE__ end)
16+
1517
let finally = Xapi_stdext_pervasives.Pervasiveext.finally
1618

1719
let all_cluster_operations = [`add; `remove; `enable; `disable; `destroy]
@@ -104,6 +106,12 @@ let with_cluster_operation ~__context ~(self : [`Cluster] API.Ref.t) ~doc ~op
104106
with _ -> ()
105107
)
106108

109+
let cluster_address_enabled ~__context =
110+
let r = Pool_features.is_enabled ~__context Features.Cluster_address in
111+
D.debug "%s extended cluster address is %s" __FUNCTION__
112+
(if r then "enabled" else "disabled") ;
113+
r
114+
107115
let corosync3_enabled ~__context =
108116
let pool = Helpers.get_pool ~__context in
109117
let restrictions = Db.Pool.get_restrictions ~__context ~self:pool in

ocaml/xapi/xapi_cluster_host.ml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
*)
1414

1515
open Xapi_clustering
16-
open Ipaddr_rpc_type
1716

1817
module D = Debug.Make (struct let name = "xapi_cluster_host" end)
1918

@@ -126,12 +125,8 @@ let join_internal ~__context ~self =
126125
let host = Db.Cluster_host.get_host ~__context ~self in
127126
let hostname = Db.Host.get_hostname ~__context ~self:host in
128127
let member =
129-
Extended
130-
{
131-
ip= Ipaddr.of_string_exn (ipstr_of_address ip_addr)
132-
; hostuuid
133-
; hostname
134-
}
128+
Xapi_cluster_host_helpers.get_cluster_host_address ~__context ~ip_addr
129+
~hostuuid ~hostname
135130
in
136131
let ip_list =
137132
List.filter_map
@@ -338,14 +333,8 @@ let enable ~__context ~self =
338333
let hostuuid = Inventory.lookup Inventory._installation_uuid in
339334
let hostname = Db.Host.get_hostname ~__context ~self:host in
340335
let member =
341-
Cluster_interface.(
342-
Extended
343-
{
344-
ip= Ipaddr.of_string_exn (ipstr_of_address ip_addr)
345-
; hostuuid
346-
; hostname
347-
}
348-
)
336+
Xapi_cluster_host_helpers.get_cluster_host_address ~__context ~ip_addr
337+
~hostuuid ~hostname
349338
in
350339
let cluster_ref = Db.Cluster_host.get_cluster ~__context ~self in
351340
let cluster_stack =

ocaml/xapi/xapi_cluster_host_helpers.ml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,17 @@ let with_cluster_host_operation ~__context ~(self : [`Cluster_host] API.Ref.t)
106106
(Datamodel_common._cluster_host, Ref.string_of self)
107107
with _ -> ()
108108
)
109+
110+
let get_cluster_host_address ~__context ~ip_addr ~hostuuid ~hostname =
111+
let open Ipaddr_rpc_type in
112+
if Xapi_cluster_helpers.cluster_address_enabled ~__context then
113+
Cluster_interface.(
114+
Extended
115+
{
116+
ip= Ipaddr.of_string_exn (ipstr_of_address ip_addr)
117+
; hostuuid
118+
; hostname
119+
}
120+
)
121+
else
122+
Cluster_interface.(IPv4 (ipstr_of_address ip_addr))

0 commit comments

Comments
 (0)