From 3d614fe4e7e278488f59032de98830c6414b7acd Mon Sep 17 00:00:00 2001 From: James Falcon Date: Tue, 19 Mar 2024 14:52:46 -0500 Subject: [PATCH] fix: Ensure network config in DataSourceOracle can be unpickled `_network_config` is only explicitly set on the instance if `_is_iscsi_root()` is True. This means that when `_is_iscsi_root()` is False, we're modifying the class variable directly. When the instance gets pickled, the class variable is not included so such changes do not get persisted. This commit fixes this. --- cloudinit/sources/DataSourceOracle.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cloudinit/sources/DataSourceOracle.py b/cloudinit/sources/DataSourceOracle.py index 8987278b94e..21962bbceea 100644 --- a/cloudinit/sources/DataSourceOracle.py +++ b/cloudinit/sources/DataSourceOracle.py @@ -123,7 +123,6 @@ class DataSourceOracle(sources.DataSource): sources.NetworkConfigSource.INITRAMFS, ) - _network_config: dict = {"config": [], "version": 1} perform_dhcp_setup = True # Careful...these can be overridden in __init__ @@ -141,6 +140,7 @@ def __init__(self, sys_cfg, *args, **kwargs): ] ) self._network_config_source = KlibcOracleNetworkConfigSource() + self._network_config: dict = {"config": [], "version": 1} url_params = self.get_url_params() self.url_max_wait = url_params.max_wait_seconds @@ -156,6 +156,8 @@ def _unpickle(self, ci_pkl_version: int) -> None: "_network_config_source", KlibcOracleNetworkConfigSource(), ) + if not hasattr(self, "_network_config"): + self._network_config = {"config": [], "version": 1} def _has_network_config(self) -> bool: return bool(self._network_config.get("config", []))