Skip to content

Commit

Permalink
DataSourceOracle: prefer DS network config over initramfs
Browse files Browse the repository at this point in the history
The Oracle platform provides networking configuration from two sources:

* the primary interface configuration comes from the initramfs, because
  Oracle instance all iSCSI boot
* secondary interface configuration comes from an IMDS accessed over
  HTTP

As we need to combine these two sources of network configuration, the
default "prefer initramfs config over data source config" behaviour
isn't appropriate; we would never get the IMDS interfaces via that
route.  Instead, the Oracle data source has code to combine these two
sources, so we prefer its network configuration over the initramfs
configuration.

(This is not appropriate default behaviour, because _in general_ data
sources won't know how to merge initramfs-provided configuration into
their provided configuration, so switching this order for all data
sources would result in initramfs configuration being discarded on any
data source that implements network_config.)
  • Loading branch information
OddBloke authored and Server Team CI Bot committed Aug 19, 2019
1 parent e11b719 commit 2c52e6e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 7 additions & 0 deletions cloudinit/sources/DataSourceOracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ class DataSourceOracle(sources.DataSource):
dsname = 'Oracle'
system_uuid = None
vendordata_pure = None
network_config_sources = (
sources.NetworkConfigSource.cmdline,
sources.NetworkConfigSource.ds,
sources.NetworkConfigSource.initramfs,
sources.NetworkConfigSource.system_cfg,
)

_network_config = sources.UNSET

def __init__(self, sys_cfg, *args, **kwargs):
Expand Down
10 changes: 9 additions & 1 deletion cloudinit/sources/tests/test_oracle.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file is part of cloud-init. See LICENSE file for license information.

from cloudinit.sources import DataSourceOracle as oracle
from cloudinit.sources import BrokenMetadata
from cloudinit.sources import BrokenMetadata, NetworkConfigSource
from cloudinit import helpers

from cloudinit.tests import helpers as test_helpers
Expand Down Expand Up @@ -303,6 +303,14 @@ def test_secondary_nic_failure_isnt_blocking(
self.assertIn('Failed to fetch secondary network configuration',
self.logs.getvalue())

def test_ds_network_cfg_preferred_over_initramfs(self):
"""Ensure that DS net config is preferred over initramfs config"""
network_config_sources = oracle.DataSourceOracle.network_config_sources
self.assertLess(
network_config_sources.index(NetworkConfigSource.ds),
network_config_sources.index(NetworkConfigSource.initramfs)
)


@mock.patch(DS_PATH + "._read_system_uuid", return_value=str(uuid.uuid4()))
class TestReadMetaData(test_helpers.HttprettyTestCase):
Expand Down

0 comments on commit 2c52e6e

Please sign in to comment.