From 959672ef14905086cfa1eda54752326f6f835af9 Mon Sep 17 00:00:00 2001 From: Kilian Cavalotti Date: Thu, 8 Aug 2024 15:52:49 -0700 Subject: [PATCH] Tries to address #7463 - run the remote `bridge` command in a login shell, to make sure PATH is properly defined - add `set -o pipefail` to ensure that errors are properly propagated back through the remote SSH command --- perl-xCAT/xCAT/MacMap.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/MacMap.pm b/perl-xCAT/xCAT/MacMap.pm index a3cf3acbec..f863760719 100644 --- a/perl-xCAT/xCAT/MacMap.pm +++ b/perl-xCAT/xCAT/MacMap.pm @@ -723,7 +723,7 @@ sub refresh_switch { my $mymac; my $myport; - my @res=xCAT::Utils->runcmd("ssh -o StrictHostKeyChecking=no -o PasswordAuthentication=no $switch 'bridge fdb show|grep -i -v permanent|tr A-Z a-z 2>/dev/null' 2>/dev/null",-1); + my @res=xCAT::Utils->runcmd("ssh -o StrictHostKeyChecking=no -o PasswordAuthentication=no $switch \"bash -lc 'set -o pipefail; bridge fdb show |grep -i -v permanent |tr A-Z a-z 2>/dev/null'\" 2>/dev/null",-1); if ($::RUNCMD_RC) { xCAT::MsgUtils->message("S", "Failed to get mac table with ssh to $switch, fall back to snmp! To obtain mac table with ssh, please make sure the passwordless root ssh to $switch is available"); if ($self->{collect_mac_info}) { @@ -774,6 +774,7 @@ sub refresh_switch { } } + my $session = $self->getsnmpsession('community' => $community, 'switch' => $switch); unless ($session) { xCAT::MsgUtils->message("S", "Failed to communicate with $switch");