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

Collect logs improvements #5619

Merged
merged 4 commits into from
Aug 15, 2024

Conversation

TheRealFalcon
Copy link
Member

Proposed Commit Message

feat: collect-logs improvements

* Collect sensitive data by default since we ask for it more often
  than not
* Output warning that we're collecting sensitive data
* Glob most of /run/cloud-init, /etc/cloud, and /var/lib/cloud
* Stop creating empty directories in the tarball
* Require running as root given that the logs are root read-only
* Update apport accordingly

Additional Context

Test Steps

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

* Collect sensitive data by default since we ask for it more often
  than not
* Glob most of /run/cloud-init, /etc/cloud, and /var/lib/cloud
* Stop creating empty directories in the tarball
* Require running as root given that the logs are root read-only
@TheRealFalcon TheRealFalcon changed the title Collect logs again Collect logs improvements Aug 14, 2024
@holmanb
Copy link
Member

holmanb commented Aug 14, 2024

Looks like this also fixes #5297

$ whoami
ubuntu
$ apport-cli vim

*** Collecting problem information

The collected information can be sent to the developers to improve the
application. This might take a few minutes.
..

*** Send problem report to the developers?

After the problem report has been sent, please fill out the form in the
automatically opened web browser.

What would you like to do? Your options are:
  S: Send report (5.6 KB)
  V: View report
  K: Keep report file for sending later or copying to somewhere else
  I: Cancel and ignore future crashes of this program version
  C: Cancel
Please choose (S/V/K/I/C)

Copy link
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheRealFalcon nice work here, I've left a couple of comments inline but overall this looks good to me. Running locally I see the following files grabbed:

# tree
.
├── dmesg.txt
├── dpkg-version
├── etc
│   └── cloud
│       ├── build.info
│       ├── cloud.cfg
│       └── cloud.cfg.d
│           ├── 05_logging.cfg
│           ├── 90_dpkg.cfg
│           └── README
├── journal.txt
├── run
│   └── cloud-init
│       ├── cloud-id
│       ├── cloud-id-lxd
│       ├── cloud-init-generator.log
│       ├── cloud.cfg
│       ├── combined-cloud-config.json
│       ├── ds-identify.log
│       ├── enabled
│       ├── instance-data-sensitive.json
│       ├── instance-data.json
│       ├── result.json
│       └── status.json
├── var
│   ├── lib
│   │   └── cloud
│   │       ├── data
│   │       │   ├── instance-id
│   │       │   ├── previous-datasource
│   │       │   ├── previous-hostname
│   │       │   ├── previous-instance-id
│   │       │   ├── python-version
│   │       │   ├── result.json
│   │       │   ├── set-hostname
│   │       │   └── status.json
│   │       └── instance
│   │           ├── boot-finished
│   │           ├── cloud-config.txt
│   │           ├── datasource
│   │           ├── network-config.json
│   │           ├── obj.pkl
│   │           ├── user-data.txt
│   │           ├── user-data.txt.i
│   │           ├── vendor-data.txt
│   │           ├── vendor-data.txt.i
│   │           ├── vendor-data2.txt
│   │           └── vendor-data2.txt.i
│   └── log
│       ├── cloud-init-output.log
│       └── cloud-init.log
└── version

cloudinit/cmd/devel/logs.py Show resolved Hide resolved
cloudinit/cmd/devel/logs.py Outdated Show resolved Hide resolved
from cloudinit.stages import Init
from cloudinit.subp import ProcessExecutionError, subp
from cloudinit.temp_utils import tempdir
from cloudinit.util import (
chdir,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that you didn't write this, but we shouldn't need this helper at all. This is the only callsite of util.chdir(), yet tar (including busybox tar) has -C which can switch directories before running the operation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alas, it is still used in bbdeb.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alas, it is still used in bbdeb.

I'm pretty strongly opposed to shipping dead code in cloud-init that exists only for use in external utilities, but I'm also fine with saying that it's not worth dealing with right now.

cloudinit/util.py Show resolved Hide resolved
cloudinit/util.py Show resolved Hide resolved
@TheRealFalcon
Copy link
Member Author

@holmanb , I believe I addressed all of your comments.

@holmanb holmanb self-assigned this Aug 15, 2024
Copy link
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, @TheRealFalcon. Tested, thanks for this PR!

@TheRealFalcon TheRealFalcon merged commit c28092f into canonical:main Aug 15, 2024
22 checks passed
@TheRealFalcon TheRealFalcon deleted the collect-logs-again branch August 15, 2024 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants