Skip to content

Commit

Permalink
Fix sporadic failures on nmcli invocation
Browse files Browse the repository at this point in the history
The serial console somehow looks like it messes up with the interpolation
of `mn_id`. Using serial terminal produces more stable results and problem
seems to go away.
In additional there are changes to prevent the uninitialized value
warnings in autoinst-log on this jobs.

https://progress.opensuse.org/issues/155170
  • Loading branch information
b10n1k committed Feb 22, 2024
1 parent ccdcfa5 commit 40b811b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
11 changes: 5 additions & 6 deletions lib/mm_network.pm
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ sub configure_static_ip {
my $ip = $args{ip};
my $mtu = $args{mtu} // get_var('MM_MTU', 1380);
my $is_nm = $args{is_nm} // is_networkmanager();
my $device = $args{device};
my $device = $args{device} // '\S';

if ($is_nm) {
my $nm_id;
my $nm_list = script_output("nmcli -t -f DEVICE,NAME c | grep -v ^lo: | grep '$device' | head -n1");
my $nm_list = script_output("nmcli -t -f DEVICE,NAME c | grep -v '^lo:' | grep -e '$device' | head -n1");
($device, $nm_id) = split(':', $nm_list);

record_info('set_ip', "Device: $device\n NM ID: $nm_id\nIP: $ip\nMTU: $mtu");
Expand Down Expand Up @@ -105,11 +105,11 @@ sub configure_dhcp {
sub configure_default_gateway {
my (%args) = @_;
my $is_nm = $args{is_nm} // is_networkmanager();
my $device = $args{device};
my $device = $args{device} // '\S';
if ($is_nm) {
my $nm_id;
# When $device is not specified grep just does nothing and first connection is selected
my $nm_list = script_output("nmcli -t -f DEVICE,NAME c | grep -v ^lo: | grep '$device' | head -n1");
my $nm_list = script_output("nmcli -t -f DEVICE,NAME c | grep -v '^lo:' | grep -e '$device' | head -n1");
($device, $nm_id) = split(':', $nm_list);

assert_script_run "nmcli connection modify '$nm_id' ipv4.gateway 10.0.2.2";
Expand All @@ -127,8 +127,7 @@ sub configure_static_dns {
my $servers = join(" ", @{$conf->{nameserver}});

if ($is_nm) {
$nm_id = script_output('nmcli -t -f NAME c | grep -v ^lo: | head -n 1') unless ($nm_id);

$nm_id = script_output("nmcli -t -f NAME c | grep -v '^lo' | head -n 1") unless ($nm_id);
assert_script_run "nmcli connection modify '$nm_id' ipv4.dns '$servers'";
} else {
assert_script_run("sed -i -e 's|^NETCONFIG_DNS_STATIC_SERVERS=.*|NETCONFIG_DNS_STATIC_SERVERS=\"$servers\"|' /etc/sysconfig/network/config");
Expand Down
4 changes: 2 additions & 2 deletions tests/network/setup_multimachine.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use mm_network 'setup_static_mm_network';
use utils qw(zypper_call permit_root_ssh set_hostname ping_size_check);
use Utils::Systemd qw(disable_and_stop_service systemctl check_unit_file);
use version_utils qw(is_sle is_opensuse);
use serial_terminal 'select_serial_terminal';

sub run {
my ($self) = @_;
Expand All @@ -28,8 +29,7 @@ sub run {
}
mutex_wait 'barrier_setup_mm_done';

select_console 'root-console';

select_serial_terminal;
# Do not use external DNS for our internal hostnames
assert_script_run('echo "10.0.2.101 server master" >> /etc/hosts');
assert_script_run('echo "10.0.2.102 client minion" >> /etc/hosts');
Expand Down

0 comments on commit 40b811b

Please sign in to comment.