diff options
author | Chad Smith <chad.smith@canonical.com> | 2022-10-21 15:55:58 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-21 15:55:58 -0600 |
commit | 41922bf0144ffe7ae3b3d3bc6378b921e076b3b1 (patch) | |
tree | 15338e9c0740baedc5fef0a97b0906ee7c75099f /cloudinit/apport.py | |
parent | cea875a4b500195b3c6dcdcbf7664857f1511aed (diff) | |
download | cloud-init-git-41922bf0144ffe7ae3b3d3bc6378b921e076b3b1.tar.gz |
cli: collect logs and apport subiquity support
cli/apport: collect-logs include subiquity logs config when present
Add support for both cloud-init collect-logs and apport to
include subiquity live installer artifacts if present to aid in
bug triage.
Apport integration to attach subiquity, curtin and
ubuntu-desktop-installer report keys when logs or
config files are present.
`ubuntu-bug cloud-init` will also automatically tag the
bug as curtin, subiquity or ubuntu-desktop-installer if
related logs are present in the bug report.
Additional collect-logs support to collect
/var/lib/cloud/data in the event that cloud-init is disabled
by systemd generator with /run/cloud-init/disabled flag.
In these situations we want to collect /var/lib/cloud/data
dir for more context on prior cloud-init behavior.
Diffstat (limited to 'cloudinit/apport.py')
-rw-r--r-- | cloudinit/apport.py | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/cloudinit/apport.py b/cloudinit/apport.py index 7cba0bf5..7f3d6e5a 100644 --- a/cloudinit/apport.py +++ b/cloudinit/apport.py @@ -3,11 +3,17 @@ # This file is part of cloud-init. See LICENSE file for license information. """Cloud-init apport interface""" + from cloudinit.cmd.devel import read_cfg_paths +from cloudinit.cmd.devel.logs import ( + INSTALLER_APPORT_FILES, + INSTALLER_APPORT_SENSITIVE_FILES, +) try: from apport.hookutils import ( attach_file, + attach_file_if_exists, attach_root_command_outputs, root_command_output, ) @@ -110,30 +116,57 @@ def attach_cloud_info(report, ui=None): report["CloudName"] = "None" +def attach_installer_files(report, ui=None): + """Attach any subiquity installer logs config. + + To support decoupling apport integration from installer config/logs, + we eventually want to either source this function or APPORT_FILES + attribute from subiquity and/or ubuntu-desktop-installer package-hooks + python modules. + """ + for apport_file in INSTALLER_APPORT_FILES: + attach_file_if_exists(report, apport_file.path, apport_file.label) + + def attach_user_data(report, ui=None): """Optionally provide user-data if desired.""" if ui: user_data_file = _get_user_data_file() prompt = ( - "Your user-data or cloud-config file can optionally be provided" - " from {0} and could be useful to developers when addressing this" - " bug. Do you wish to attach user-data to this bug?".format( - user_data_file - ) + "Your user-data, cloud-config or autoinstall files can optionally " + " be provided from {0} and could be useful to developers when" + " addressing this bug. Do you wish to attach user-data to this" + " bug?".format(user_data_file) ) response = ui.yesno(prompt) if response is None: raise StopIteration # User cancelled if response: attach_file(report, user_data_file, "user_data.txt") + for apport_file in INSTALLER_APPORT_SENSITIVE_FILES: + attach_file_if_exists( + report, apport_file.path, apport_file.label + ) def add_bug_tags(report): """Add any appropriate tags to the bug.""" + new_tags = [] + if report.get("CurtinError"): + new_tags.append("curtin") + if report.get("SubiquityLog"): + new_tags.append("subiquity") if "JournalErrors" in report.keys(): errors = report["JournalErrors"] if "Breaking ordering cycle" in errors: - report["Tags"] = "systemd-ordering" + new_tags.append("systemd-ordering") + if report.get("UdiLog"): + new_tags.append("ubuntu-desktop-installer") + if new_tags: + report.setdefault("Tags", "") + if report["Tags"]: + report["Tags"] += " " + report["Tags"] += " ".join(new_tags) def add_info(report, ui): @@ -151,6 +184,7 @@ def add_info(report, ui): attach_hwinfo(report, ui) attach_cloud_info(report, ui) attach_user_data(report, ui) + attach_installer_files(report, ui) add_bug_tags(report) return True |