summaryrefslogtreecommitdiff
path: root/cloudinit/sources
diff options
context:
space:
mode:
authorChad Smith <chad.smith@canonical.com>2023-01-11 16:28:58 -0700
committerGitHub <noreply@github.com>2023-01-11 16:28:58 -0700
commita85f103e2c59dd80157e535354d41f03545d7314 (patch)
tree207ce4333e8aaf44f6091380fcee37b4a91a1f70 /cloudinit/sources
parenteb22a2426d4df1d1870dbef04f5edf7f58356ee1 (diff)
downloadcloud-init-git-a85f103e2c59dd80157e535354d41f03545d7314.tar.gz
lxd: handle 404 from missing devices route for LXD 4.0
LXD 4.0 will not get a backport of the devices route on LXD socket API. This prevented launching Jammy from hosts with LXD 4.0. Allow cloud-init to support LXD backplanes without the "devices" route and use fallback network config when absent. LP: #2001737
Diffstat (limited to 'cloudinit/sources')
-rw-r--r--cloudinit/sources/DataSourceLXD.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/cloudinit/sources/DataSourceLXD.py b/cloudinit/sources/DataSourceLXD.py
index 49a7567c..eea1e294 100644
--- a/cloudinit/sources/DataSourceLXD.py
+++ b/cloudinit/sources/DataSourceLXD.py
@@ -277,6 +277,14 @@ def _get_json_response(
session: requests.Session, url: str, do_raise: bool = True
):
url_response = _do_request(session, url, do_raise)
+ if not url_response.ok:
+ LOG.debug(
+ "Skipping %s on [HTTP:%d]:%s",
+ url,
+ url_response.status_code,
+ url_response.text,
+ )
+ return {}
try:
return url_response.json()
except JSONDecodeError as exc:
@@ -386,7 +394,9 @@ class _MetaDataReader:
md.update(self._process_config(session))
if MetaDataKeys.DEVICES in metadata_keys:
url = url_helper.combine_url(self._version_url, "devices")
- md["devices"] = _get_json_response(session, url)
+ devices = _get_json_response(session, url, do_raise=False)
+ if devices:
+ md["devices"] = devices
return md