From d08a264e9d4db2528ae8edf5bd6dda82aaba8d8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Wed, 22 Jul 2026 19:48:34 -0300 Subject: [PATCH] fix(rinv): sort FRU output deterministically The FRU key sort used only `$a <=> $b`, a numeric comparison that returns 0 for the non-numeric FRU field names, leaving them in hash-iteration order. That order is randomized per process, so `rinv all` printed its fields in a different order on each run. Add `$a cmp $b` as a tiebreaker so the output is stable. Recovered from the unmerged lenovobuild branch (original 9cd3fac6). Co-authored-by: Jarrod Johnson <10814490+jjohnson42@users.noreply.github.com> --- xCAT-server/lib/xcat/plugins/ipmi.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 7cd34129c..a7b31db1b 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -3203,7 +3203,7 @@ sub fru_initted { my @types = @{ $sessdata->{invtypes} }; my $format = "%-20s %s"; - foreach $key (sort { $a <=> $b } keys %{ $sessdata->{fru_hash} }) { + foreach $key (sort { $a <=> $b or $a cmp $b } keys %{ $sessdata->{fru_hash} }) { my $fru = $sessdata->{fru_hash}->{$key}; my $type; foreach $type (split /,/, $fru->rec_type) {