Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update apport reporting #1851

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions scripts/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ validate () {
# not to do that.
# If we run an autoinstall that customizes the security section as part
# of the test-suite, we will need to adapt this test.
python3 scripts/check-yaml-fields.py $tmpdir/var/log/installer/subiquity-curtin-apt.conf \
python3 scripts/check-yaml-fields.py $tmpdir/var/log/installer/curtin-install/subiquity-curtin-apt.conf \
apt.security[0].uri='"http://security.ubuntu.com/ubuntu/"' \
apt.security[0].arches='["amd64", "i386"]' \
apt.security[1].uri='"http://ports.ubuntu.com/ubuntu-ports"'
Expand Down Expand Up @@ -259,7 +259,7 @@ LANG=C.UTF-8 timeout --foreground 60 \
--kernel-cmdline autoinstall \
--source-catalog examples/sources/install.yaml
validate
python3 scripts/check-yaml-fields.py $tmpdir/var/log/installer/subiquity-curtin-apt.conf \
python3 scripts/check-yaml-fields.py $tmpdir/var/log/installer/curtin-install/subiquity-curtin-apt.conf \
apt.disable_components='[non-free, restricted]' \
apt.preferences[0].pin-priority=200 \
apt.preferences[0].pin='"origin *ubuntu.com*"' \
Expand Down
8 changes: 6 additions & 2 deletions subiquity/cmd/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,13 @@ def main():
logfiles = setup_logger(dir=logdir, base="subiquity-server")

logger = logging.getLogger("subiquity")
version = os.environ.get("SNAP_REVISION", "unknown")
revision = os.environ.get("SNAP_REVISION", "unknown")
version = os.environ.get("SNAP_VERSION", "unknown")
snap = os.environ.get("SNAP", "unknown")
logger.info(f"Starting Subiquity server revision {version} of snap {snap}")
logger.info(
f"Starting Subiquity server revision {revision} of snap {snap} "
f"of version {version}"
)
logger.info(f"Arguments passed: {sys.argv}")
logger.debug(f"Kernel commandline: {opts.kernel_cmdline}")
logger.debug(f"Environment: {os.environ}")
Expand Down
8 changes: 6 additions & 2 deletions subiquity/cmd/tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,12 @@ def main():

async def run_with_loop():
subiquity_interface = SubiquityClient(opts)
subiquity_interface.note_file_for_apport("InstallerLog", logfiles["debug"])
subiquity_interface.note_file_for_apport("InstallerLogInfo", logfiles["info"])
subiquity_interface.note_file_for_apport(
"InstallerClientLog", logfiles["debug"]
)
subiquity_interface.note_file_for_apport(
"InstallerClientLogInfo", logfiles["info"]
)
await subiquity_interface.run()

asyncio.run(run_with_loop())
Expand Down
11 changes: 10 additions & 1 deletion subiquity/common/errorreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

from subiquity.common.types import ErrorReportKind, ErrorReportRef, ErrorReportState
from subiquitycore.async_helpers import run_in_thread, schedule_task
from subiquitycore.file_util import write_file

log = logging.getLogger("subiquity.common.errorreport")

Expand Down Expand Up @@ -132,7 +133,9 @@ def _bg_add_info():
if not self.reporter.dry_run:
self.pr.add_hooks_info(None)
apport.hookutils.attach_hardware(self.pr)
self.pr["Syslog"] = apport.hookutils.recent_syslog(re.compile("."))
self.pr["InstallerJournal"] = apport.hookutils.recent_syslog(
re.compile(".")
)
snap_name = os.environ.get("SNAP_NAME", "")
if snap_name != "":
self.add_tags([snap_name])
Expand Down Expand Up @@ -343,6 +346,7 @@ class ErrorReporter(object):
def __init__(self, context, dry_run, root, client=None):
self.context = context
self.dry_run = dry_run
self.root = root
self.crash_directory = os.path.join(root, "var/crash")
self.client = client

Expand Down Expand Up @@ -408,6 +412,11 @@ def make_apport_report(self, kind, thing, *, wait=False, exc=None, **kw):
report.pr["Title"] = "{} crashed with {}".format(thing, type(exc).__name__)
tb = traceback.TracebackException.from_exception(exc)
report.pr["Traceback"] = "".join(tb.format())
# Write out traceback for apport consumption
traceback_log = os.path.join(
self.root, "var/log/installer", "subiquity-traceback.txt"
)
write_file(traceback_log, "".join(tb.format()))
self._reports_by_exception[exc] = report
else:
report.pr["Title"] = thing
Expand Down
2 changes: 1 addition & 1 deletion subiquity/server/apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ async def apply_apt_config(self, context, final: bool):
self.configured_tree = await self.mounter.setup_overlay([self.source_path])

config_location = os.path.join(
self.app.root, "var/log/installer/subiquity-curtin-apt.conf"
self.app.root, "var/log/installer/curtin-install/subiquity-curtin-apt.conf"
)
generate_config_yaml(config_location, self.apt_config(final))
self.app.note_data_for_apport("CurtinAptConfig", config_location)
Expand Down
8 changes: 6 additions & 2 deletions system_setup/cmd/tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,12 @@ def main():

async def run_with_loop():
subiquity_interface = SystemSetupClient(opts)
subiquity_interface.note_file_for_apport("InstallerLog", logfiles["debug"])
subiquity_interface.note_file_for_apport("InstallerLogInfo", logfiles["info"])
subiquity_interface.note_file_for_apport(
"InstallerClientLog", logfiles["debug"]
)
subiquity_interface.note_file_for_apport(
"InstallerClientLogInfo", logfiles["info"]
)
await subiquity_interface.run()

asyncio.run(run_with_loop())
Expand Down