diff options
author | Brett Holman <brett.holman@canonical.com> | 2023-03-19 19:24:49 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-19 20:24:49 -0500 |
commit | a60c0845806baff72c74603286d048efbafab664 (patch) | |
tree | 4ae8acc8555cc90948e8895ca72f599c4ec96d3a /cloudinit/sources/DataSourceLXD.py | |
parent | 3634678465e7b8f8608bcb9a1f5773ae7837cbe9 (diff) | |
download | cloud-init-git-a60c0845806baff72c74603286d048efbafab664.tar.gz |
datasource: Optimize datasource detection, fix bugs (#2060)
Commit d1ffbea556a06105 enabled skipping python datasource detection on
OpenStack when no other datasources (besides DataSourceNone) can be discovered.
This allowed one to override detection, which is a requirement for OpenStack
Ironic which does not advertise itself to cloud-init.
Since no further datasources can be detected at this stage in the code, this
pattern can be generalized to other datasources to facilitate troubleshooting
or providing a general workaround to runtime detection bugs.
Additionally, this pattern can be extended to kernel commandline datasource
definition. Since kernel commandline is highest priority of the
configurations, it makes sense to override python code datasource
detection as well.
Include an integration test on LXD for this behavior that configures kernel
commandline and reboots to verify that the specified datasource is forced.
Diffstat (limited to 'cloudinit/sources/DataSourceLXD.py')
-rw-r--r-- | cloudinit/sources/DataSourceLXD.py | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/cloudinit/sources/DataSourceLXD.py b/cloudinit/sources/DataSourceLXD.py index ab440cc8..2643149b 100644 --- a/cloudinit/sources/DataSourceLXD.py +++ b/cloudinit/sources/DataSourceLXD.py @@ -181,16 +181,13 @@ class DataSourceLXD(sources.DataSource): super()._unpickle(ci_pkl_version) self.skip_hotplug_detect = True - def _is_platform_viable(self) -> bool: + @staticmethod + def ds_detect() -> bool: """Check platform environment to report if this datasource may run.""" return is_platform_viable() def _get_data(self) -> bool: """Crawl LXD socket API instance data and return True on success""" - if not self._is_platform_viable(): - LOG.debug("Not an LXD datasource: No LXD socket found.") - return False - self._crawled_metadata = util.log_time( logfunc=LOG.debug, msg="Crawl of metadata service", |