summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Smith <chad.smith@canonical.com>2023-03-21 14:43:55 -0600
committergit-ubuntu importer <ubuntu-devel-discuss@lists.ubuntu.com>2023-03-21 23:03:10 +0000
commitf297548858cdd285600e802544b7ae48209b62d2 (patch)
tree8b44f7ae387ce691b834b47a979c8e42cf8243f3
parent2eee228719fedc909d3c021bee5050436b36af01 (diff)
downloadcloud-init-git-f297548858cdd285600e802544b7ae48209b62d2.tar.gz
23.1.1-0ubuntu2 (patches unapplied)
Imported using git-ubuntu import.
-rw-r--r--debian/apport-general-hook.py99
-rw-r--r--debian/changelog14
-rw-r--r--debian/cloud-init.postinst4
-rw-r--r--debian/cloud-init.preinst9
-rwxr-xr-xdebian/rules1
5 files changed, 125 insertions, 2 deletions
diff --git a/debian/apport-general-hook.py b/debian/apport-general-hook.py
new file mode 100644
index 00000000..fccac954
--- /dev/null
+++ b/debian/apport-general-hook.py
@@ -0,0 +1,99 @@
+"""General Apport hook for all reports that are using cloud-init."""
+
+import json
+import logging
+
+
+def _get_azure_data(ds_data) -> dict[str, str]:
+ compute = ds_data.get("meta_data", {}).get("imds", {}).get("compute")
+ if not compute:
+ return {}
+ name_to_report_map = {
+ "publisher": "ImagePublisher",
+ "offer": "ImageOffer",
+ "sku": "ImageSKU",
+ "version": "ImageVersion",
+ "vmSize": "VMSize",
+ }
+ azure_data = {}
+ for src_key, report_key_name in name_to_report_map.items():
+ azure_data[report_key_name] = compute[src_key]
+ return azure_data
+
+
+def _get_ec2_data(ds_data) -> dict[str, str]:
+ document = (
+ ds_data.get("dynamic", {}).get("instance-identity", {}).get("document")
+ )
+ if not document:
+ return {}
+ wanted_keys = {
+ "architecture",
+ "billingProducts",
+ "imageId",
+ "instanceType",
+ "region",
+ }
+ return {
+ key: value for key, value in document.items() if key in wanted_keys
+ }
+
+
+PLATFORM_SPECIFIC_INFO = {"azure": _get_azure_data, "ec2": _get_ec2_data}
+
+
+def add_datasource_specific_info(report, platform: str, ds_data) -> None:
+ """Add datasoure specific information from the ds dictionary.
+
+ ds_data contains the "ds" entry from data from
+ /run/cloud/instance-data.json.
+ """
+ platform_info = PLATFORM_SPECIFIC_INFO.get(platform)
+ if not platform_info:
+ return
+ retrieved_data = platform_info(ds_data)
+ for key, value in retrieved_data.items():
+ if not value:
+ continue
+ report[platform.capitalize() + key.capitalize()] = value
+
+
+def add_info(report, ui) -> None:
+ """Entry point for Apport.
+
+ Add a subset of non-sensitive cloud-init data from
+ /run/cloud/instance-data.json that will be helpful for debugging.
+ """
+ try:
+ with open("/run/cloud-init/instance-data.json", "r") as fopen:
+ instance_data = json.load(fopen)
+ except FileNotFoundError:
+ logging.getLogger().warning(
+ "cloud-init run data not found on system. "
+ "Unable to add cloud-specific data."
+ )
+ return
+
+ v1 = instance_data.get("v1")
+ if not v1:
+ logging.getLogger().warning(
+ "instance-data.json lacks 'v1' metadata. Present keys: %s",
+ sorted(instance_data.keys()),
+ )
+ return
+
+ for key, report_key in {
+ "cloud_id": "CloudID",
+ "cloud_name": "CloudName",
+ "machine": "CloudArchitecture",
+ "platform": "CloudPlatform",
+ "region": "CloudRegion",
+ "subplatform": "CloudSubPlatform",
+ }.items():
+ value = v1.get(key)
+ if value:
+ report[report_key] = value
+
+ add_datasource_specific_info(
+ report, v1["platform"], instance_data.get("ds")
+ )
diff --git a/debian/changelog b/debian/changelog
index 98826869..e29c28b2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,17 @@
+cloud-init (23.1.1-0ubuntu2) lunar; urgency=medium
+
+ * d/apport-general-hook.py: Add general apport hook to append cloud type,
+ image and instance size information to bug reports (LP: #1724623)
+ * d/cloud-init.postinst: MAAS prefer yaml.safe_load over yaml.load
+ (LP: #2009746)
+ * d/cloud-init.preinst: Oracle to remove vestigial /etc/cloud.cloud.cfg.d/
+ 99-disable-network-config.cfg because system config is now honored before
+ datasource config (LP: #1956788)
+ * Upstream snapshot based on upstream/main at 85b2fbc2.
+ - Bugs fixed in this snapshot: (LP: #1956788)
+
+ -- Chad Smith <chad.smith@canonical.com> Tue, 21 Mar 2023 14:43:55 -0600
+
cloud-init (23.1.1-0ubuntu1) lunar; urgency=medium
* Upstream snapshot based on main at 4896402b.
diff --git a/debian/cloud-init.postinst b/debian/cloud-init.postinst
index 268f3ec8..079b429d 100644
--- a/debian/cloud-init.postinst
+++ b/debian/cloud-init.postinst
@@ -38,10 +38,10 @@ def update(src, cand):
REMOVER = object
if len(sys.argv) == 5:
REMOVER = sys.argv[4]
-newcfg = yaml.load(newyaml)
+newcfg = yaml.safe_load(newyaml)
with open(fname, "r") as fp:
- cfg = yaml.load(fp)
+ cfg = yaml.safe_load(fp)
if not cfg: cfg = {}
cfg = update(cfg, newcfg)
diff --git a/debian/cloud-init.preinst b/debian/cloud-init.preinst
index 6168aecf..0dcef7c4 100644
--- a/debian/cloud-init.preinst
+++ b/debian/cloud-init.preinst
@@ -181,6 +181,13 @@ cleanup_lp1552999() {
"$hdir/cloud-init-local.service" "$hdir/cloud-init.service"
}
+cleanup_oci_network_lp1956788() {
+ # Remove vestigial /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
+ # from Oracle now that datasource honors system cfg above datasource cfg.
+ grep DataSourceOracle /var/lib/cloud/instance/datasource > /dev/null 2>&1 || return 0
+ rm -f /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
+}
+
case "$1" in
install|upgrade)
if dpkg --compare-versions "$2" le "0.5.11-0ubuntu1"; then
@@ -224,6 +231,8 @@ case "$1" in
fi
cleanup_lp1552999 "$oldver"
+ cleanup_oci_network_lp1956788
+
esac
#DEBHELPER#
diff --git a/debian/rules b/debian/rules
index 108a9442..9e2718b0 100755
--- a/debian/rules
+++ b/debian/rules
@@ -23,5 +23,6 @@ override_dh_auto_install:
install -D -m 0644 ./tools/21-cloudinit.conf debian/cloud-init/etc/rsyslog.d/21-cloudinit.conf
install -D ./tools/Z99-cloud-locale-test.sh debian/cloud-init/etc/profile.d/Z99-cloud-locale-test.sh
install -D ./tools/Z99-cloudinit-warnings.sh debian/cloud-init/etc/profile.d/Z99-cloudinit-warnings.sh
+ install -m 0644 -D debian/apport-general-hook.py debian/cloud-init/usr/share/apport/general-hooks/cloud-init.py
install -m 0644 -D debian/apport-launcher.py debian/cloud-init/usr/share/apport/package-hooks/cloud-init.py
flist=$$(find $(CURDIR)/debian/ -type f -name version.py) && sed -i 's,@@PACKAGED_VERSION@@,$(DEB_VERSION),' $${flist:-did-not-find-version-py-for-replacement}