diff options
author | Thomas Haller <thaller@redhat.com> | 2021-01-07 21:27:01 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2021-01-08 09:06:18 +0100 |
commit | 02f4b0cbd5c268c602a877a66923ad134d09e8ca (patch) | |
tree | d6e07ffc90b02c87c2d4c2c070404fab448b10f1 | |
parent | 5e70e802e0765e3e5e0fcdb6a468ea2023fe83e2 (diff) | |
download | NetworkManager-02f4b0cbd5c268c602a877a66923ad134d09e8ca.tar.gz |
platform/tests: workaround failure to add veth device on copr
On copr builds, the unit tests sometimes fail to create a veth
interface. In those cases, kernel rejects the netlink request
with EPERM. copr uses mock on Fedora 33 hosts.
I think this is a kernel bug. Add a workaround by retrying a few times.
-rw-r--r-- | src/platform/tests/test-common.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/platform/tests/test-common.c b/src/platform/tests/test-common.c index 8a83d7c61c..6014204371 100644 --- a/src/platform/tests/test-common.c +++ b/src/platform/tests/test-common.c @@ -1572,8 +1572,8 @@ nmtstp_link_veth_add(NMPlatform *platform, const char *name, const char *peer) { - const NMPlatformLink *pllink = NULL; - gboolean success; + const NMPlatformLink *pllink = NULL; + gboolean success = FALSE; g_assert(nm_utils_ifname_valid_kernel(name, NULL)); @@ -1586,9 +1586,28 @@ nmtstp_link_veth_add(NMPlatform *platform, if (success) { pllink = nmtstp_assert_wait_for_link(platform, name, NM_LINK_TYPE_VETH, 100); nmtstp_assert_wait_for_link(platform, peer, NM_LINK_TYPE_VETH, 10); + } else { + /* iproute2 might fail in copr. See below. + * We accept that and try our platform implementation instead. */ + _LOGI("iproute2 failed to add veth device. Retry with platform code."); + external_command = FALSE; } - } else - success = NMTST_NM_ERR_SUCCESS(nm_platform_link_veth_add(platform, name, peer, &pllink)); + } + + if (!external_command) { + int try_count = 0; + int r; + +again: + r = nm_platform_link_veth_add(platform, name, peer, &pllink); + if (r == -EPERM && try_count++ < 5) { + /* in copr (mock with Fedora 33 builders), this randomly fails with EPERM. + * Very odd. Try to work around by retrying. */ + _LOGI("netlink failuer EPERM to add veth device. Retry."); + goto again; + } + success = NMTST_NM_ERR_SUCCESS(r); + } g_assert(success); _assert_pllink(platform, success, pllink, name, NM_LINK_TYPE_VETH); |