kdumpctl: distinguish the failed reason of ssh
On a host with ipaddr not ready before kdump service, ssh return errno 255. While if no ssh-key, ssh also return errno 255. For both of cases, the current kdump code promote user to run 'kdumpctl propagate'. This confuses user who already installs ssh-key. In order to tell these two cases from each other, the ssh warning message should be involved, and parsed. For the no ssh-key case , warning message is "Permission denied" or "No such file or directory". For the other, warning message is "Network Unreachable" This patch also does a slight change to enlarge the timeout from 60s to 180s. This value can meet test at the time being Signed-off-by: Pingfan Liu <piliu@redhat.com> Acked-by: Kairui Song <kasong@redhat.com>
This commit is contained in:
parent
3e8526cf04
commit
680c0d3414
25
kdumpctl
25
kdumpctl
@ -738,24 +738,38 @@ check_and_wait_network_ready()
|
|||||||
local start_time=$(date +%s)
|
local start_time=$(date +%s)
|
||||||
local cur
|
local cur
|
||||||
local diff
|
local diff
|
||||||
|
local retval
|
||||||
|
local errmsg
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
ssh -q -i $SSH_KEY_LOCATION -o BatchMode=yes $DUMP_TARGET mkdir -p $SAVE_PATH
|
errmsg=$(ssh -i $SSH_KEY_LOCATION -o BatchMode=yes $DUMP_TARGET mkdir -p $SAVE_PATH 2>&1)
|
||||||
|
retval=$?
|
||||||
|
|
||||||
# ssh exits with the exit status of the remote command or with 255 if an error occurred
|
# ssh exits with the exit status of the remote command or with 255 if an error occurred
|
||||||
if [ $? -eq 0 ]; then
|
if [ $retval -eq 0 ]; then
|
||||||
return 0
|
return 0
|
||||||
elif [ $? -ne 255 ]; then
|
elif [ $retval -ne 255 ]; then
|
||||||
|
echo "Could not create $DUMP_TARGET:$SAVE_PATH, you should check the privilege on server side" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# if server removes the authorized_keys or, no /root/.ssh/kdump_id_rsa
|
||||||
|
echo $errmsg | grep -q "Permission denied\|No such file or directory"
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "Could not create $DUMP_TARGET:$SAVE_PATH, you probably need to run \"kdumpctl propagate\"" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
cur=$(date +%s)
|
cur=$(date +%s)
|
||||||
diff=$( $cur - $start_time )
|
let "diff = $cur - $start_time"
|
||||||
# 60s time out
|
# 60s time out
|
||||||
if [ $diff -gt 60 ]; then
|
if [ $diff -gt 180 ]; then
|
||||||
break;
|
break;
|
||||||
fi
|
fi
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo "Could not create $DUMP_TARGET:$SAVE_PATH, ipaddr is not ready yet. You should check network connection" >&2
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -763,7 +777,6 @@ check_ssh_target()
|
|||||||
{
|
{
|
||||||
check_and_wait_network_ready
|
check_and_wait_network_ready
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Could not create $DUMP_TARGET:$SAVE_PATH, you probably need to run \"kdumpctl propagate\"" >&2
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
|
Loading…
Reference in New Issue
Block a user