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

Add detailed logging to separate logfile #690

Merged
merged 1 commit into from
May 13, 2021
Merged

Conversation

eloquence
Copy link
Member

@eloquence eloquence commented Apr 28, 2021

Status

Ready for review

Description of Changes

Fixes #688

Makes our logging logic more flexible to configure multiple loggers that write to different logfiles, so launcher.log continues to be useful as a high level overview of all update events. Detailed information is written to launcher-detail.log, which is also rotated out after 10 copies.

To enable this additional logging, this PR switches the relevant subprocess calls from check_call to check_output. It distinguishes between success & error state, but logs in both cases.

Testing

(Estimated wall time ~30 minutes, but mostly waiting.)

  1. make clone this branch into dom0 and sudo dnf reinstall (or make staging if you don't have a previously provisioned environment) the freshly built RPM from rpm-build/RPMS/noarch.
  2. Remove or relocate the contents of ~/.securedrop_launcher/logs so you can see the behavior with newly created log files.
  3. In dom0, mkdir /tmp/sdw-migrations && touch /tmp/sdw-migrations/potato. This will force a full sdw-admin --apply run on the next update.
  4. In dom0, run /opt/securedrop/launcher/sdw-launcher.py --skip-delta 0. This will force an updater run.
  5. Look at the logs in ~/.securedrop_launcher/logs
    • Observe that launcher-detail.log contains output from sudo qubesctl --show-output state.highstate and from sdw-admin --apply
  6. Modify the file /srv/salt/update-xfce-settings and insert an echo XYZZY && exit 1 statement after the set statements. This is how we'll cause all Salt runs to error out.
  7. Repeat steps 3 to 5.
    • Observe that launcher.log contains error log entries pointing to launcher-detail.log
    • Observe that launcher-detail.log contains error logs containing the full Salt output and the XYZZY magic word we had the script insert
  8. Undo your modification from step 7 to restore the environment to a working state

Checklist

  • Linter (make flake8) passes in the development environment (this box may
    be left unchecked, as flake8 also runs in CI)

"""
Strip ANSI colors from command output
"""
return re.sub(r"\u001b\[.*?[@-~]", "", str)
Copy link
Member Author

Choose a reason for hiding this comment

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

Open to a more robust solution here, of course, just don't want to write color codes to the log file.

@conorsch conorsch self-requested a review May 5, 2021 17:45
Copy link
Contributor

@conorsch conorsch left a comment

Choose a reason for hiding this comment

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

This worked quite well! Big improvement to have these details at hand, particularly after a failed run.

@conorsch conorsch merged commit 455bad9 into main May 13, 2021
@legoktm legoktm deleted the 688-detailed-logs branch May 28, 2024 15:25
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.

Increase level of updater logging detail
2 participants