Wait for the network to be truly ready before dumping vmcore

Resolves: bz2076416
Upstream: Fedora
Conflict: None

commit 9792994f2f
Author: Coiby Xu <coxu@redhat.com>
Date:   Thu Sep 22 22:31:47 2022 +0800

    Wait for the network to be truly ready before dumping vmcore

    nm-wait-online-initrd.service installed by dracut's 35-networkmanager
    module calls nm-online with "-s" which means it returns immediately when
    NetworkManager logs "startup complete". Thus it doesn't truly wait for
    network connectivity to be established [1]. Wait for the network to be
    truly ready before dumping vmcore. There are two benefits brought by
    this approach,
      - ssh/nfs dumping won't fail because of that the network is not
       ready e.g. [2][3]
      - users don't need to use workarounds like rd.net.carrier.timeout to
        make sure the network is ready

    [1] https://bugzilla.redhat.com/show_bug.cgi?id=1485712
    [2] https://bugzilla.redhat.com/show_bug.cgi?id=1909014
    [3] https://bugzilla.redhat.com/show_bug.cgi?id=2035451

    Signed-off-by: Coiby Xu <coxu@redhat.com>
    Reviewed-by: Thomas Haller <thaller@redhat.com>
    Reviewed-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
This commit is contained in:
Coiby Xu 2022-11-23 09:42:33 +08:00
parent d22786bb5a
commit 561952f12a
1 changed files with 25 additions and 1 deletions

View File

@ -478,6 +478,26 @@ save_vmcore_dmesg_ssh()
fi
}
wait_online_network()
{
# In some cases, network may still not be ready because nm-online is called
# with "-s" which means to wait for NetworkManager startup to complete, rather
# than waiting for network connectivity specifically. Wait 10mins more for the
# network to be truely ready in these cases.
_loop=0
while [ $_loop -lt 600 ]; do
sleep 1
_loop=$((_loop + 1))
if _route=$(kdump_get_ip_route "$1" 2> /dev/null); then
printf "%s" "$_route"
return
fi
done
derror "Oops. The network still isn't ready after waiting 10mins."
exit 1
}
get_host_ip()
{
@ -491,7 +511,11 @@ get_host_ip()
derror "failed to get remote IP address!"
return 1
fi
_route=$(kdump_get_ip_route "$_kdump_remote_ip")
if ! _route=$(wait_online_network "$_kdump_remote_ip"); then
return 1
fi
_netdev=$(kdump_get_ip_route_field "$_route" "dev")
if ! _kdumpip=$(ip addr show dev "$_netdev" | grep '[ ]*inet'); then