cloud-init/SOURCES/orabug35950168-DataSourceOracle-network-getdata-updates.patch

116 lines
4.2 KiB
Diff

Patch to adapt DataSourceOracle and make it functional for OCI.
Also includes setting for retries and timeouts previously provided by
a separate patch to help PCA instances get IMDS data.
Orabug: 37065979
Signed-off-by: Rajesh Harekal <rajesh.harekal@oracle.com>
---
diff -git a/cloudinit/sources/DataSourceOracle.py b/cloudinit/sources/DataSourceOracle.py
--- a/cloudinit/sources/DataSourceOracle.py 2025-03-07 16:04:37.773216485 -0800
+++ a/cloudinit/sources/DataSourceOracle.py 2025-03-07 16:32:33.174574170 -0800
@@ -15,6 +15,7 @@
import base64
import ipaddress
+import os
import json
import logging
import time
@@ -32,6 +33,8 @@
LOG = logging.getLogger(__name__)
+ISCSI_IBFT_PATH='/sys/firmware/acpi/tables/iBFT'
+
BUILTIN_DS_CONFIG = {
# Don't use IMDS to configure secondary NICs by default
"configure_secondary_nics": False,
@@ -135,8 +138,8 @@
perform_dhcp_setup = True
# Careful...these can be overridden in __init__
- url_max_wait = 30
- url_timeout = 5
+ url_max_wait = 180
+ url_timeout = 20
def __init__(self, sys_cfg, *args, **kwargs):
super(DataSourceOracle, self).__init__(sys_cfg, *args, **kwargs)
@@ -149,7 +152,7 @@
]
)
self._network_config_source = KlibcOracleNetworkConfigSource()
- self._network_config: dict = {"config": [], "version": 1}
+ self._network_config = sources.UNSET
url_params = self.get_url_params()
self.url_max_wait = url_params.max_wait_seconds
@@ -274,7 +277,7 @@
def _is_iscsi_root(self) -> bool:
"""Return whether we are on a iscsi machine."""
- return self._network_config_source.is_applicable()
+ return self._network_config_source.is_applicable() or bool(os.path.exists(ISCSI_IBFT_PATH))
def _get_iscsi_config(self) -> dict:
return self._network_config_source.render_config()
@@ -294,34 +297,31 @@
set_primary = False
# this is v1
- if self._is_iscsi_root():
- self._network_config = self._get_iscsi_config()
- if not self._has_network_config():
- LOG.warning(
- "Could not obtain network configuration from initramfs. "
- "Falling back to IMDS."
+ if self._network_config == sources.UNSET:
+ # this is v1
+ if not self._has_network_config():
+ self._network_config = self.distro.generate_fallback_config()
+ set_primary = True
+
+ set_secondary = self.ds_cfg.get(
+ "configure_secondary_nics",
+ BUILTIN_DS_CONFIG["configure_secondary_nics"],
)
- set_primary = True
-
- set_secondary = self.ds_cfg.get(
- "configure_secondary_nics",
- BUILTIN_DS_CONFIG["configure_secondary_nics"],
- )
- if set_primary or set_secondary:
- try:
- # Mutate self._network_config to include primary and/or
- # secondary VNICs
- self._add_network_config_from_opc_imds(set_primary)
- except Exception:
- util.logexc(
- LOG,
- "Failed to parse IMDS network configuration!",
- )
+ if set_primary or set_secondary:
+ try:
+ # Mutate self._network_config to include primary and/or
+ # secondary VNICs
+ self._add_network_config_from_opc_imds(set_primary)
+ except Exception:
+ util.logexc(
+ LOG,
+ "Failed to parse IMDS network configuration!",
+ )
- # we need to verify that the nic selected is not a netfail over
- # device and, if it is a netfail master, then we need to avoid
- # emitting any match by mac
- _ensure_netfailover_safe(self._network_config)
+ # we need to verify that the nic selected is not a netfail over
+ # device and, if it is a netfail master, then we need to avoid
+ # emitting any match by mac
+ _ensure_netfailover_safe(self._network_config)
return self._network_config