Fix global DNS on second apply

Resolves: RHEL-44623

Signed-off-by: Gris Ge <fge@redhat.com>
This commit is contained in:
Gris Ge 2024-06-26 11:40:24 +08:00
parent 69503b6dd6
commit f4244ca285
2 changed files with 75 additions and 1 deletions

View File

@ -0,0 +1,70 @@
From 364842c0c09f9799a2c48a1bc3ce4debb1a3ddc2 Mon Sep 17 00:00:00 2001
From: Gris Ge <fge@redhat.com>
Date: Tue, 18 Jun 2024 13:44:55 +0800
Subject: [PATCH] dns: Do not touch iface DNS when apply identical DNS state
When applying the same DNS only desire state again, nmstate incorrectly
purged interface DNS.
The root cause is we only set `self.use_global_dns` to True when
DNS changed. The fix is set `self.use_global_dns` to True always unless
iface DNS is required.
Signed-off-by: Gris Ge <fge@redhat.com>
---
libnmstate/net_state.py | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/libnmstate/net_state.py b/libnmstate/net_state.py
index 7b208daa..fe6fc31d 100644
--- a/libnmstate/net_state.py
+++ b/libnmstate/net_state.py
@@ -32,7 +32,7 @@ class NetState:
gen_conf_mode=False,
ignored_dns_ifaces=None,
):
- self.use_global_dns = False
+ self.use_global_dns = True
if current_state is None:
current_state = {}
self._ifaces = Ifaces(
@@ -76,17 +76,17 @@ class NetState:
"interface profile, using global DNS"
)
logging.warning(
- "Storing DNS to NetworkManager via global dns API, "
- "this will cause __all__ interface level DNS settings "
- "been ignored"
+ "Storing DNS to NetworkManager via global DNS "
+ "API, this will cause __all__ interface level "
+ "DNS settings been ignored"
)
- self.use_global_dns = True
else:
if self.dns.is_purge() or self._is_iface_dns_prefered():
try:
self._ifaces.gen_dns_metadata(
self._dns, self._route, ignored_dns_ifaces
)
+ self.use_global_dns = False
except NmstateValueError as e:
if (
gen_conf_mode
@@ -99,14 +99,12 @@ class NetState:
"API, this will cause __all__ interface level "
"DNS settings been ignored"
)
- self.use_global_dns = True
elif self.dns.config_changed:
logging.warning(
"Storing DNS to NetworkManager via global DNS "
"API, this will cause __all__ interface level "
"DNS settings been ignored"
)
- self.use_global_dns = True
self._ifaces.gen_route_metadata(self._route)
self._ifaces.gen_route_rule_metadata(self._route_rule, self._route)
--
2.45.2

View File

@ -4,7 +4,7 @@
Name: nmstate
Version: 1.4.6
Release: 2%{?dist}
Release: 3%{?dist}
Summary: Declarative network manager API
License: LGPLv2+
URL: https://github.com/%{srcname}/%{srcname}
@ -15,6 +15,7 @@ Source3: %{url}/releases/download/v%{version}/%{srcname}-vendor-%{version
# Patches 0X are reserved to downstream only
Patch0: BZ_2132570-nm-reverse-IPv6-order-before-adding-them-to-setting.patch
Patch10: 0001-clib-Use-build.rs-to-fix-SONAME.patch
Patch11: RHEL-44623-fix-global-dns.patch
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: gnupg2
@ -142,6 +143,9 @@ popd
/sbin/ldconfig
%changelog
* Wed Jun 26 2024 Gris Ge <fge@redhat.com> - 1.4.6-3
- Fix global DNS on second apply. RHEL-44623
* Fri May 17 2024 Gris Ge <fge@redhat.com> - 1.4.6-2
- Fix clib SONAME. RHEL-32218