Skip to content

Commit

Permalink
Merge pull request #18713 from b10n1k/ping_client_wa
Browse files Browse the repository at this point in the history
Fix sporadic failures on nmcli invocation
  • Loading branch information
okurz committed Feb 26, 2024
2 parents 8baef5f + 40b811b commit 20b62fa
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 20b62fa

Please sign in to comment.