Skip to content

Commit e53e443

Browse files
committed
CP-44106: Add interface sort error print
Signed-off-by: Changlei Li <[email protected]>
1 parent 2aa6876 commit e53e443

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

ocaml/networkd/bin/network_server.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ let sort_and_update () =
9797
; interface_order= Some new_order
9898
}
9999
| Error err ->
100-
error "Failed to sort interface order"
100+
error "Failed to sort interface order [%s]"
101+
(Network_device_order.string_of_error err)
101102

102103
let sort_on_first_boot () =
103104
if Network_utils.is_sorted_by_script () then
@@ -107,7 +108,8 @@ let sort_on_first_boot () =
107108
| Ok (sorted, _) ->
108109
Some sorted
109110
| Error err ->
110-
error "Failed to sort interface order" ;
111+
error "Failed to sort interface order [%s]"
112+
(Network_device_order.string_of_error err) ;
111113
Some []
112114

113115
let build_config () =

ocaml/networkd/lib/network_config.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ let parse_dns_config args =
8787
(nameservers, domains)
8888

8989
let write_manage_iface_to_inventory bridge_name =
90+
info "Writing management interface to inventory: %s" bridge_name ;
9091
Inventory.update Inventory._management_interface bridge_name
9192

9293
let read_management_conf interface_order =

ocaml/networkd/lib/network_device_order.ml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@ type error =
3636
| Duplicate_position
3737
| Invalid_biosdevname_key_value of (string * string)
3838

39+
let string_of_error = function
40+
| Pci_addr_parse_error s ->
41+
Printf.sprintf "Invalid PCI address: %s" s
42+
| Mac_addr_parse_error s ->
43+
Printf.sprintf "Invalid MAC address: %s" s
44+
| Rule_parse_error s ->
45+
Printf.sprintf "Invalid rule: %s" s
46+
| Missing_biosdevname_key k ->
47+
Printf.sprintf "Missing key in biosdevname output: %s" k
48+
| Duplicate_mac_address ->
49+
"Duplicate MAC address"
50+
| Duplicate_position ->
51+
"Duplicate position"
52+
| Invalid_biosdevname_key_value (k, v) ->
53+
Printf.sprintf "Invalid key-value pair in biosdevname output: %s=%s" k v
54+
3955
module Pciaddr = struct
4056
type t = Xcp_pci.address
4157

ocaml/networkd/lib/network_device_order.mli

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ type error =
2424
| Duplicate_position
2525
| Invalid_biosdevname_key_value of (string * string)
2626

27+
val string_of_error : error -> string
28+
(** [string_of_error e] returns a string representation of the error [e]. *)
29+
2730
(** PCI address in format SBDF: domain:bus:device:function *)
2831
module Pciaddr : sig
2932
(** Type of the PCI address *)

0 commit comments

Comments
 (0)