1 Star 0 Fork 27

桐小哥/cloud-init

forked from src-openEuler/cloud-init 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-fix-azure-disable-use-dns-for-secondary-nics-5314.patch 4.35 KB
一键复制 编辑 原始数据 按行查看 历史
桐小哥 提交于 2024-06-11 10:41 . backport upstream bugfix patches
From 42930d8459b59b22cab3f76d85d170871174b479 Mon Sep 17 00:00:00 2001
From: Alberto Contreras <alberto.contreras@canonical.com>
Date: Wed, 29 May 2024 09:10:53 +0200
Subject: [PATCH] fix(azure): disable use-dns for secondary nics (#5314)
DNS resolution through secondary NICs is not supported on Azure. Disable
it.
Without this, we see seconds of delay resolving urls in cloud-init logs
from Jammy+, see SF ticket.
Per cjp256's comment, the first NIC under metadata.imds.network is
ensured
to be the primary one. We use this to determine primary NICs instead of
relying on fragile driver and/or NIC names.
Fixes: SF: #00380708
Co-authored-by: Calvin Mwadime <calvin.mwadime@canonical.com>
---
cloudinit/sources/DataSourceAzure.py | 3 +++
tests/unittests/sources/test_azure.py | 20 +++++++++++++-------
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
index 11c14e2..e384b32 100644
--- a/cloudinit/sources/DataSourceAzure.py
+++ b/cloudinit/sources/DataSourceAzure.py
@@ -1965,6 +1965,9 @@ def generate_network_config_from_instance_network_metadata(
# addresses.
nicname = "eth{idx}".format(idx=idx)
dhcp_override = {"route-metric": (idx + 1) * 100}
+ # DNS resolution through secondary NICs is not supported, disable it.
+ if idx > 0:
+ dhcp_override["use-dns"] = False
dev_config: Dict[str, Any] = {
"dhcp4": True,
"dhcp4-overrides": dhcp_override,
diff --git a/tests/unittests/sources/test_azure.py b/tests/unittests/sources/test_azure.py
index 2a477f8..3a36418 100644
--- a/tests/unittests/sources/test_azure.py
+++ b/tests/unittests/sources/test_azure.py
@@ -718,14 +718,20 @@ class TestGenerateNetworkConfig:
"match": {"macaddress": "00:0d:3a:04:75:98"},
"dhcp6": False,
"dhcp4": True,
- "dhcp4-overrides": {"route-metric": 200},
+ "dhcp4-overrides": {
+ "route-metric": 200,
+ "use-dns": False,
+ },
},
"eth2": {
"set-name": "eth2",
"match": {"macaddress": "00:0d:3a:04:75:98"},
"dhcp6": False,
"dhcp4": True,
- "dhcp4-overrides": {"route-metric": 300},
+ "dhcp4-overrides": {
+ "route-metric": 300,
+ "use-dns": False,
+ },
},
},
"version": 2,
@@ -952,7 +958,7 @@ class TestNetworkConfig:
"dhcp6": False,
"match": {"macaddress": "00:0d:3a:04:75:98"},
"set-name": "eth0",
- }
+ },
},
"version": 2,
}
@@ -1534,7 +1540,7 @@ scbus-1 on xpt0 bus 0
"dhcp6": False,
"dhcp4": True,
"dhcp4-overrides": {"route-metric": 100},
- }
+ },
},
"version": 2,
}
@@ -1563,14 +1569,14 @@ scbus-1 on xpt0 bus 0
"match": {"macaddress": "22:0d:3a:04:75:98"},
"dhcp6": False,
"dhcp4": True,
- "dhcp4-overrides": {"route-metric": 200},
+ "dhcp4-overrides": {"route-metric": 200, "use-dns": False},
},
"eth2": {
"set-name": "eth2",
"match": {"macaddress": "33:0d:3a:04:75:98"},
"dhcp6": False,
"dhcp4": True,
- "dhcp4-overrides": {"route-metric": 300},
+ "dhcp4-overrides": {"route-metric": 300, "use-dns": False},
},
},
"version": 2,
@@ -1603,7 +1609,7 @@ scbus-1 on xpt0 bus 0
"dhcp6": False,
"dhcp4": True,
"dhcp4-overrides": {"route-metric": 100},
- }
+ },
},
"version": 2,
}
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tong_1001/cloud-init.git
git@gitee.com:tong_1001/cloud-init.git
tong_1001
cloud-init
cloud-init
master

搜索帮助