2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-07-31 18:19:40 +00:00

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 <node> 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>
This commit is contained in:
Vinícius Ferrão
2026-07-22 19:48:34 -03:00
parent cf44f51463
commit d08a264e9d
+1 -1
View File
@@ -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) {