- cloud-setup: allow bigger restart bursts

- cloud-setup: azure: ensure that primary address is placed
 first
This commit is contained in:
eabdullin 2024-10-07 10:12:30 +03:00
parent 208e437eaf
commit fb9aae8c40
3 changed files with 198 additions and 2 deletions

View File

@ -0,0 +1,46 @@
From 6016ef0813a6c048369cc27ae85fc12699bacab5 Mon Sep 17 00:00:00 2001
From: Lubomir Rintel <lkundrak@v3.sk>
Date: Tue, 27 Aug 2024 00:29:17 +0200
Subject: [PATCH] cloud-setup: allow bigger restart bursts
On daemon startup, we may end up enqueueing many nm-cloud-setup.service
restarts in very a short time. That is perfectly fine, just bump the
thresholds so that systemd doesn't get in the way too quickly.
100 requests in 1 seconds seem like a fair choice -- little bit on the
conservative side, yet still giving the service manager some room to
interfere on a chance things really go awry.
https://issues.redhat.com/browse/RHEL-49694
(cherry picked from commit 927cff9f178911b2a146259a89bfcc9727cbd8c3)
(cherry picked from commit 4dc35c72744f8820575ab0ea4638c4ddd880547d)
(cherry picked from commit 097dfdf711d2f968d0580839f5a7a54731c68f34)
---
src/nm-cloud-setup/nm-cloud-setup.service.in | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/nm-cloud-setup/nm-cloud-setup.service.in b/src/nm-cloud-setup/nm-cloud-setup.service.in
index 4aa6017e48..10acf8add6 100644
--- a/src/nm-cloud-setup/nm-cloud-setup.service.in
+++ b/src/nm-cloud-setup/nm-cloud-setup.service.in
@@ -8,6 +8,17 @@ After=NetworkManager.service
Type=oneshot
ExecStart=@libexecdir@/nm-cloud-setup
+# The service restart gets triggered from dispatcher script
+# (pre-up and dhcp4-change actions), possibly ending up with many
+# restart requests at the same time (e.g. on initial daemon startup
+# on a machine with multiple NICs). The systemd handles multiple
+# concurrent restart requests gracefully (the newer requests supersede
+# older, which wait for them to finish), but the default limits are way
+# too low: 5 restarts in 10 seconds. Raise that high enough for us to
+# be on the safe side.
+StartLimitIntervalSec=1
+StartLimitBurst=100
+
#Environment=NM_CLOUD_SETUP_LOG=TRACE
# Cloud providers are disabled by default. You need to
--
2.46.0

View File

@ -0,0 +1,141 @@
From 81bba3f2321939bb9fd0200a91ac0bec79960732 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=8D=C3=B1igo=20Huguet?= <ihuguet@redhat.com>
Date: Tue, 27 Aug 2024 12:08:16 +0200
Subject: [PATCH] cloud-setup: azure: ensure that primary address is placed
first
The primary address is that placed at position 0 of all the IP Addresses
of the interface. Sometimes we put it in a different position in the
ipv4s array because we insert them in the order we receive, but it might
happen that the HTTP responses comes back in wrong order.
In order to solve this, we pass the index of the IPv4 address to the
callback and the address is added in the right position directly.
Co-authored-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
(cherry picked from commit 72014db629cff33611ade58190d45a714efa1bbf)
(cherry picked from commit c976e212372da9683a1e2f8618e3bcfdf21d5e25)
(cherry picked from commit 55812963fde9519bb2752c46575a740fa0fea688)
---
src/nm-cloud-setup/nmcs-provider-azure.c | 43 ++++++++++++++++--------
1 file changed, 29 insertions(+), 14 deletions(-)
diff --git a/src/nm-cloud-setup/nmcs-provider-azure.c b/src/nm-cloud-setup/nmcs-provider-azure.c
index 771c43d9ad..78eda16cbb 100644
--- a/src/nm-cloud-setup/nmcs-provider-azure.c
+++ b/src/nm-cloud-setup/nmcs-provider-azure.c
@@ -102,6 +102,11 @@ typedef struct {
guint n_iface_data_pending;
} AzureIfaceData;
+typedef struct {
+ AzureIfaceData *iface_data;
+ guint64 ipaddress_idx;
+} AzureIpAddressReqData;
+
static void
_azure_iface_data_destroy(AzureIfaceData *iface_data)
{
@@ -112,7 +117,8 @@ static void
_get_config_fetch_done_cb(NMHttpClient *http_client,
GAsyncResult *result,
AzureIfaceData *iface_data,
- GetConfigFetchType fetch_type)
+ GetConfigFetchType fetch_type,
+ guint64 ipaddress_idx)
{
NMCSProviderGetConfigTaskData *get_config_data;
NMCSProviderGetConfigIfaceData *iface_get_config;
@@ -149,9 +155,7 @@ _get_config_fetch_done_cb(NMHttpClient *http_client,
_LOGD("interface[%" G_GSSIZE_FORMAT "]: received address %s",
iface_data->intern_iface_idx,
nm_inet4_ntop(tmp_addr, tmp_addr_str));
- iface_get_config->ipv4s_arr[iface_get_config->ipv4s_len] = tmp_addr;
- iface_get_config->has_ipv4s = TRUE;
- iface_get_config->ipv4s_len++;
+ iface_get_config->ipv4s_arr[ipaddress_idx] = tmp_addr;
break;
case GET_CONFIG_FETCH_TYPE_IPV4_SUBNET_0_ADDRESS:
@@ -203,10 +207,14 @@ _get_config_fetch_done_cb_ipv4_ipaddress_x_privateipaddress(GObject *source
GAsyncResult *result,
gpointer user_data)
{
+ AzureIpAddressReqData *ipaddress_req_data = user_data;
+
_get_config_fetch_done_cb(NM_HTTP_CLIENT(source),
result,
- user_data,
- GET_CONFIG_FETCH_TYPE_IPV4_IPADDRESS_X_PRIVATEIPADDRESS);
+ ipaddress_req_data->iface_data,
+ GET_CONFIG_FETCH_TYPE_IPV4_IPADDRESS_X_PRIVATEIPADDRESS,
+ ipaddress_req_data->ipaddress_idx);
+ g_free(ipaddress_req_data);
}
static void
@@ -217,7 +225,8 @@ _get_config_fetch_done_cb_ipv4_subnet_0_address(GObject *source,
_get_config_fetch_done_cb(NM_HTTP_CLIENT(source),
result,
user_data,
- GET_CONFIG_FETCH_TYPE_IPV4_SUBNET_0_ADDRESS);
+ GET_CONFIG_FETCH_TYPE_IPV4_SUBNET_0_ADDRESS,
+ 0);
}
static void
@@ -228,7 +237,8 @@ _get_config_fetch_done_cb_ipv4_subnet_0_prefix(GObject *source,
_get_config_fetch_done_cb(NM_HTTP_CLIENT(source),
result,
user_data,
- GET_CONFIG_FETCH_TYPE_IPV4_SUBNET_0_PREFIX);
+ GET_CONFIG_FETCH_TYPE_IPV4_SUBNET_0_PREFIX,
+ 0);
}
static void
@@ -265,9 +275,10 @@ _get_config_ips_prefix_list_cb(GObject *source, GAsyncResult *result, gpointer u
nm_sprintf_buf(iface_idx_str, "%" G_GSSIZE_FORMAT, iface_data->intern_iface_idx);
while (nm_utils_parse_next_line(&response_str, &response_len, &line, &line_len)) {
- gint64 ips_prefix_idx;
- gs_free char *uri = NULL;
- char buf[100];
+ AzureIpAddressReqData *ipaddress_req_data;
+ gint64 ips_prefix_idx;
+ gs_free char *uri = NULL;
+ char buf[100];
if (line_len == 0)
continue;
@@ -284,8 +295,11 @@ _get_config_ips_prefix_list_cb(GObject *source, GAsyncResult *result, gpointer u
if (ips_prefix_idx < 0)
continue;
- iface_data->n_iface_data_pending++;
+ ipaddress_req_data = g_new(AzureIpAddressReqData, 1);
+ ipaddress_req_data->iface_data = iface_data;
+ ipaddress_req_data->ipaddress_idx = ips_prefix_idx;
+ iface_data->n_iface_data_pending++;
nm_http_client_poll_req(
NM_HTTP_CLIENT(source),
(uri = _azure_uri_interfaces(iface_idx_str,
@@ -302,11 +316,12 @@ _get_config_ips_prefix_list_cb(GObject *source, GAsyncResult *result, gpointer u
NULL,
NULL,
_get_config_fetch_done_cb_ipv4_ipaddress_x_privateipaddress,
- iface_data);
+ ipaddress_req_data);
}
- iface_data->iface_get_config->ipv4s_len = 0;
iface_data->iface_get_config->ipv4s_arr = g_new(in_addr_t, iface_data->n_iface_data_pending);
+ iface_data->iface_get_config->has_ipv4s = TRUE;
+ iface_data->iface_get_config->ipv4s_len = iface_data->n_iface_data_pending;
{
gs_free char *uri = NULL;
--
2.46.0

View File

@ -6,7 +6,7 @@
%global epoch_version 1 %global epoch_version 1
%global real_version 1.48.10 %global real_version 1.48.10
%global rpm_version %{real_version} %global rpm_version %{real_version}
%global release_version 1 %global release_version 2
%global snapshot %{nil} %global snapshot %{nil}
%global git_sha %{nil} %global git_sha %{nil}
%global bcond_default_debug 0 %global bcond_default_debug 0
@ -189,7 +189,7 @@ Name: NetworkManager
Summary: Network connection manager and user applications Summary: Network connection manager and user applications
Epoch: %{epoch_version} Epoch: %{epoch_version}
Version: %{rpm_version} Version: %{rpm_version}
Release: %{release_version}%{?snap}%{?dist} Release: %{release_version}%{?snap}%{?dist}.alma.1
Group: System Environment/Base Group: System Environment/Base
License: GPL-2.0-or-later AND LGPL-2.1-or-later License: GPL-2.0-or-later AND LGPL-2.1-or-later
URL: https://networkmanager.dev/ URL: https://networkmanager.dev/
@ -210,6 +210,10 @@ Source9: readme-ifcfg-rh-migrated.txt
# Patch0001: 0001-some.patch # Patch0001: 0001-some.patch
Patch0001: 0001-revert-change-default-value-for-ipv4.dad-timeout-from-0-to-200ms.patch Patch0001: 0001-revert-change-default-value-for-ipv4.dad-timeout-from-0-to-200ms.patch
# Sources were taken from latest stable release:
Patch1001: 1001-cloud-setup-allow-bigger-restart-bursts-rhel-56739.patch
Patch1002: 1002-cloud-setup-ensure-azure-places-primary-address-first-rhel-56386.patch
# Bugfixes that are only relevant until next rebase of the package. # Bugfixes that are only relevant until next rebase of the package.
# Patch1001: 1001-some.patch # Patch1001: 1001-some.patch
@ -1268,6 +1272,11 @@ fi
%changelog %changelog
* Mon Oct 07 2024 Eduard Abdullin <eabdullin@almalinux.org> - 1:1.48.10-2.alma.1
- cloud-setup: allow bigger restart bursts
- cloud-setup: azure: ensure that primary address is placed
first
* Thu Aug 22 2024 Íñigo Huguet <ihuguet@redhat.com> - 1:1.48.10-1 * Thu Aug 22 2024 Íñigo Huguet <ihuguet@redhat.com> - 1:1.48.10-1
- Unblock the autoconnect for children when parent is available (RHEL-46904) - Unblock the autoconnect for children when parent is available (RHEL-46904)
- Fix crash produced by malformed LLDP package when debug logging (RHEL-46199) - Fix crash produced by malformed LLDP package when debug logging (RHEL-46199)