canonical / cloud-init

Official upstream for the cloud-init: cloud instance initialization
https://cloud-init.io/
Other
3.02k stars 888 forks source link

cloud-init collect logs needs to defer to distro for debug data #3447

Open ubuntu-server-builder opened 1 year ago

ubuntu-server-builder commented 1 year ago

This bug was originally filed in Launchpad as LP: #1843602

Launchpad details
affected_projects = []
assignee = None
assignee_name = None
date_closed = None
date_created = 2019-09-11T15:15:39.838265+00:00
date_fix_committed = None
date_fix_released = None
id = 1843602
importance = medium
is_complete = False
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1843602
milestone = None
owner = raharper
owner_name = Ryan Harper
private = False
status = triaged
submitter = raharper
submitter_name = Ryan Harper
tags = []
duplicates = []

Launchpad user Ryan Harper(raharper) wrote on 2019-09-11T15:15:39.838265+00:00

While triaging a bug in sles'based distro using cloud-init, the collect-logs output had a few issues:

1) the user did not have systemd journal privs

Unexpected error while running command. Command: ['journalctl', '--boot=0', '-o', 'short-precise'] Exit code: 1 Reason: - Stdout: Stderr: Hint: You are currently not seeing messages from other users and the system. Users in the 'systemd-journal' group can see all messages. Pass -q to turn off this notice. No journal files were opened due to insufficient permissions.

2) we tried to collect dpkg-version on a non debian distro

Unexpected error while running command. Command: ['dpkg-query', '--show', '-f=${Version}\n', 'cloud-init'] Exit code: - Reason: [Errno 2] No such file or directory Stdout: - Stderr: -

3) version file is empty

4) dmesg as non-root user fails

Unexpected error while running command. Command: ['dmesg'] Exit code: 1 Reason: - Stdout: Stderr: dmesg: read kernel buffer failed: Operation not permitted

ubuntu-server-builder commented 1 year ago

Launchpad user Dan Watkins(oddbloke) wrote on 2019-09-17T08:11:28.163802+00:00

When you say "defer to distro", do you specifically mean defer to the distro classes?

ubuntu-server-builder commented 1 year ago

Launchpad user Ryan Harper(raharper) wrote on 2019-09-17T09:08:07.739149+00:00

Yes, collect-logs should use the distro classes to extract information, like cloud-init's package version, and paths to distro specific files of interest.