Skip to content

Commit

Permalink
CA-403101: Keep host.last_update_hash for host joined a pool
Browse files Browse the repository at this point in the history
Signed-off-by: Gang Ji <[email protected]>
  • Loading branch information
gangj committed Dec 2, 2024
1 parent 536db8c commit 21d1156
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 7 deletions.
9 changes: 9 additions & 0 deletions ocaml/idl/datamodel_host.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,15 @@ let create_params =
; param_release= dundee_release
; param_default= Some (VDateTime Date.epoch)
}
; {
param_type= String
; param_name= "last_update_hash"
; param_doc=
"The SHA256 checksum of updateinfo of the most recently applied update \
on the host"
; param_release= numbered_release "24.39.0-next"
; param_default= Some (VString "")
}
]

let create =
Expand Down
3 changes: 2 additions & 1 deletion ocaml/tests/common/test_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,13 @@ let make_host ~__context ?(uuid = make_uuid ()) ?(name_label = "host")
?(external_auth_service_name = "") ?(external_auth_configuration = [])
?(license_params = []) ?(edition = "free") ?(license_server = [])
?(local_cache_sr = Ref.null) ?(chipset_info = []) ?(ssl_legacy = false)
?(last_software_update = Date.epoch) () =
?(last_software_update = Date.epoch) ?(last_update_hash = "") () =
let host =
Xapi_host.create ~__context ~uuid ~name_label ~name_description ~hostname
~address ~external_auth_type ~external_auth_service_name
~external_auth_configuration ~license_params ~edition ~license_server
~local_cache_sr ~chipset_info ~ssl_legacy ~last_software_update
~last_update_hash
in
Db.Host.set_cpu_info ~__context ~self:host ~value:default_cpu_info ;
host
Expand Down
2 changes: 1 addition & 1 deletion ocaml/tests/test_host.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let add_host __context name =
~external_auth_service_name:"" ~external_auth_configuration:[]
~license_params:[] ~edition:"" ~license_server:[]
~local_cache_sr:Ref.null ~chipset_info:[] ~ssl_legacy:false
~last_software_update:Xapi_stdext_date.Date.epoch
~last_software_update:Xapi_stdext_date.Date.epoch ~last_update_hash:""
)

(* Creates an unlicensed pool with the maximum number of hosts *)
Expand Down
2 changes: 1 addition & 1 deletion ocaml/xapi/dbsync_slave.ml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ let create_localhost ~__context info =
~external_auth_configuration:[] ~license_params:[] ~edition:""
~license_server:[("address", "localhost"); ("port", "27000")]
~local_cache_sr:Ref.null ~chipset_info:[] ~ssl_legacy:false
~last_software_update:Date.epoch
~last_software_update:Date.epoch ~last_update_hash:""
in
()

Expand Down
8 changes: 4 additions & 4 deletions ocaml/xapi/xapi_host.ml
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ let is_host_alive ~__context ~host =
let create ~__context ~uuid ~name_label ~name_description:_ ~hostname ~address
~external_auth_type ~external_auth_service_name ~external_auth_configuration
~license_params ~edition ~license_server ~local_cache_sr ~chipset_info
~ssl_legacy:_ ~last_software_update =
~ssl_legacy:_ ~last_software_update ~last_update_hash =
(* fail-safe. We already test this on the joining host, but it's racy, so multiple concurrent
pool-join might succeed. Note: we do it in this order to avoid a problem checking restrictions during
the initial setup of the database *)
Expand Down Expand Up @@ -1053,9 +1053,9 @@ let create ~__context ~uuid ~name_label ~name_description:_ ~hostname ~address
)
~control_domain:Ref.null ~updates_requiring_reboot:[] ~iscsi_iqn:""
~multipathing:false ~uefi_certificates:"" ~editions:[] ~pending_guidances:[]
~tls_verification_enabled ~last_software_update ~recommended_guidances:[]
~latest_synced_updates_applied:`unknown ~pending_guidances_recommended:[]
~pending_guidances_full:[] ~last_update_hash:"" ;
~tls_verification_enabled ~last_software_update ~last_update_hash
~recommended_guidances:[] ~latest_synced_updates_applied:`unknown
~pending_guidances_recommended:[] ~pending_guidances_full:[] ;
(* If the host we're creating is us, make sure its set to live *)
Db.Host_metrics.set_last_updated ~__context ~self:metrics ~value:(Date.now ()) ;
Db.Host_metrics.set_live ~__context ~self:metrics ~value:host_is_us ;
Expand Down
1 change: 1 addition & 0 deletions ocaml/xapi/xapi_host.mli
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ val create :
-> chipset_info:(string * string) list
-> ssl_legacy:bool
-> last_software_update:API.datetime
-> last_update_hash:string
-> [`host] Ref.t

val destroy : __context:Context.t -> self:API.ref_host -> unit
Expand Down
1 change: 1 addition & 0 deletions ocaml/xapi/xapi_pool.ml
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,7 @@ let rec create_or_get_host_on_master __context rpc session_id (host_ref, host) :
~local_cache_sr ~chipset_info:host.API.host_chipset_info
~ssl_legacy:false
~last_software_update:host.API.host_last_software_update
~last_update_hash:host.API.host_last_update_hash
in
(* Copy other-config into newly created host record: *)
no_exn
Expand Down

0 comments on commit 21d1156

Please sign in to comment.