Skip to content

Commit a34b3d4

Browse files
authored
CP-44105: Adjust Net.reset_state for pool.eject_self (#6481)
As pool.eject_self calls interface-rename script to rename the network interfaces, this behaviour should be done compatibly. So, move the interface-rename to networkd with compatibility check. When reset networkd state legacy: use interface-rename script to sort and rename new: use networkd network_device_order with initial empty order to sort
2 parents 9c78090 + 2d99b0d commit a34b3d4

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

ocaml/networkd/bin/network_server.ml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,21 @@ let sync_state () =
136136
write_config ()
137137

138138
let reset_state () =
139-
let interface_order, _ = sort Network_config.initial_interface_order in
140-
config := Network_config.read_management_conf interface_order
139+
let reset_order =
140+
match !config.interface_order with
141+
| Some _ ->
142+
(* Use empty config interface_order to sort to generate fresh-install
143+
state for currently-installed hardware *)
144+
sort Network_config.empty_config.interface_order |> fst
145+
| None ->
146+
ignore
147+
(Forkhelpers.execute_command_get_output
148+
"/etc/sysconfig/network-scripts/interface-rename.py"
149+
["--reset-to-install"]
150+
) ;
151+
None
152+
in
153+
config := Network_config.read_management_conf reset_order
141154

142155
let set_gateway_interface _dbg name =
143156
(* Remove dhclient conf (if any) for the old and new gateway interfaces.

ocaml/xapi/xapi_pif.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ let refresh_internal ~__context ~interface_tables ~self =
116116
info "PIF: device name changed from %s to %s" original_name name ;
117117
name
118118
| None -> (
119-
(* This clause should be unlike to happen, if enter this, check the if
119+
(* This clause should be unlikely to happen, if enter this, check the if
120120
we can get mac from networkd. If yes there may be a bug *)
121121
warn "PIF %s: no device found for position %d" original_name position ;
122122
try

ocaml/xapi/xapi_pool.ml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,7 +2088,6 @@ let eject_self ~__context ~host =
20882088
configuration_file
20892089
in
20902090
write_first_boot_management_interface_configuration_file () ;
2091-
Net.reset_state () ;
20922091
Xapi_inventory.update Xapi_inventory._current_interfaces "" ;
20932092
(* Destroy my control domains, since you can't do this from the API [operation not allowed] *)
20942093
( try
@@ -2148,15 +2147,10 @@ let eject_self ~__context ~host =
21482147
(!Xapi_globs.remote_db_conf_fragment_path ^ ".bak")
21492148
)
21502149
() ;
2151-
(* Reset the domain 0 network interface naming configuration
2152-
* back to a fresh-install state for the currently-installed
2153-
* hardware.
2154-
*)
2155-
ignore
2156-
(Forkhelpers.execute_command_get_output
2157-
"/etc/sysconfig/network-scripts/interface-rename.py"
2158-
["--reset-to-install"]
2159-
)
2150+
(* Reset the domain 0 network interface order back to a fresh-install
2151+
* state for the currently-installed hardware and reset networkd config.
2152+
*)
2153+
Net.reset_state ()
21602154
)
21612155
(fun () -> Xapi_fuse.light_fuse_and_reboot_after_eject ()) ;
21622156
Xapi_hooks.pool_eject_hook ~__context

0 commit comments

Comments
 (0)