xcat-core icon indicating copy to clipboard operation
xcat-core copied to clipboard

makehosts host aliases failed when nics table has interface with same IP (xCAT 2.16.5)

Open bermang opened this issue 2 years ago • 0 comments
trafficstars

Hello,

When running makehosts with host aliases in the hosts table ('hostnames' field) and the nics table has nic defined with the same IP as the host, makehosts will not write the host aliases. The use case is configuring a bond when the install NIC is part of. The initial install is done on one of the links of the bond and confignetworks will configure the bond as postscript.

There are several related issues to this behavior, in /opt/xcat/lib/perl/xCAT_plugin/hosts.pm -

  1. The code below (lines 85-93) replace the aliases with the nics aliases. So it drops the aliases completely anyway (should add the aliases instead?)
  2. the hother variable anyway takes only the first alias. more than that will be lost when using this.
if ($nics) {

                    # we're processing the nics table and we found an
                    #   existing entry for this ip so just add this
                    # node name as an alias for the existing entry
                    chomp($hosts[$idx]);
                    my ($hip, $hnode, $hdom, $hother) = split(/ /, $hosts[$idx]);

                    $hosts[$idx] = build_line($callback, $ip, $hnode, $domain, $othernames);
  1. The code below (lines 793-807) will not work for more than one nic alias based on regex. it must use space as separator and the code do not deal with this case.
# for example: nicaliases.ib0=|maestro-(\d+)$|m($1)-ib0|
            if ($aliases =~ /^\|\S*\|$/) {
                $aliases = xCAT::Table::transRegexAttrs($node, $aliases);
            }

            if ($aliases =~ /\|/) {
                my @names = split(/\|/, $aliases);
                my $index = 0;
                foreach my $alias (@names) {
                    $nich->{$nicname}->{nicaliases}->[$index] = $alias;
                    $index++;
                }
            } else {
                $nich->{$nicname}->{nicaliases}->[0] = $aliases;
            }

Maybe better in this case (ip conflict between nics and hosts) simply ignore the nics table or just add the aliases?

THX!

bermang avatar Feb 21 '23 15:02 bermang