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 error handling for full state runs; fix apply_dom0 error handling #686

Merged
merged 1 commit into from
Apr 8, 2021

Conversation

eloquence
Copy link
Member

@eloquence eloquence commented Apr 7, 2021

Status

Ready for review

Description of Changes

Fixes #668 (together with #684; will file separate issue for logging improvements)
Fixes #685

Testing

Fix for #668

  1. Install an RPM from this branch (either via make staging or dnf reinstall of the built RPM after make clone)
  2. Ensure a migration flag is present in /tmp/sdw-migrations (this will be the case after an RPM install until Removes migration flag from postinst #667 is merged)
  3. Modify your copy of /usr/share/securedrop-workstation-dom0-config/scripts/provision-all to exit 1 immediately
  4. Run the updater with /opt/securedrop/launcher/sdw-launcher.py --skip-delta 0
    • Observe that the updater ultimately reports an error
    • Observe that the apply_all error is logged in ~/.securedrop_launcher/logs/launcher.log
    • Observe that the migration flag is still present (i.e. the updater will try again)
  5. Undo your modification to /usr/share/securedrop-workstation-dom0-config/scripts/provision-all

Fix for #685

  1. Install an RPM from this branch (either via make staging or dnf reinstall of the built RPM after `make clone)
  2. Remove /tmp/sdw-migrations if it exists
  3. Modify your copy of /srv/salt/update-xfce-settings to exit 1 immediately
  4. Run the updater with /opt/securedrop/launcher/sdw-launcher.py --skip-delta 0
    • Observe that the updater ultimately reports an error
    • Observe that the apply_dom0 error is logged in ~/.securedrop_launcher/logs/launcher.log
  5. Undo your modification to /srv/salt/update-xfce-settings

@eloquence eloquence force-pushed the 668-better-error-handling branch from 728253f to e71fb58 Compare April 7, 2021 06:42
MIGRATION_DIR = "potato"
updater.run_full_install()
calls = [["sdw-admin", "--apply"], ["sudo", "rm", "-rf", MIGRATION_DIR]]
assert mock_call.has_calls(calls, any_order=False)
Copy link
Member Author

@eloquence eloquence Apr 7, 2021

Choose a reason for hiding this comment

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

This test never worked - has_calls is the wrong method name, so it just runs an assertion against the mock that will always succeed, just like assert mock_call.nonsense() would - thanks to unittest.mock.MagicMock.

MIGRATION_DIR is also not imported, so this will just create a local variable. We should IMO patch it rather than importing and modifying it (the rewritten test does so).

Copy link
Contributor

Choose a reason for hiding this comment

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

good find

@eloquence eloquence marked this pull request as ready for review April 7, 2021 07:25
launcher/sdw_updater_gui/UpdaterApp.py Show resolved Hide resolved
MIGRATION_DIR = "potato"
updater.run_full_install()
calls = [["sdw-admin", "--apply"], ["sudo", "rm", "-rf", MIGRATION_DIR]]
assert mock_call.has_calls(calls, any_order=False)
Copy link
Contributor

Choose a reason for hiding this comment

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

good find

launcher/sdw_updater_gui/UpdaterApp.py Show resolved Hide resolved
@sssoleileraaa sssoleileraaa self-requested a review April 8, 2021 00:33
Copy link
Contributor

@sssoleileraaa sssoleileraaa left a comment

Choose a reason for hiding this comment

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

Testing

Fix for #668

  1. Install an RPM from this branch (either via make staging or dnf reinstall of the built RPM after make clone)
  2. Ensure a migration flag is present in /tmp/sdw-migrations (this will be the case after an RPM install until Removes migration flag from postinst #667 is merged)
  3. Modify your copy of /usr/share/securedrop-workstation-dom0-config/scripts/provision-all to exit 1 immediately
  4. Run the updater with /opt/securedrop/launcher/sdw-launcher.py --skip-delta 0
    • Observe that the updater ultimately reports an error

Updater reports generic "Security updates failed" error message

    • Observe that the apply_all error is logged in ~/.securedrop_launcher/logs/launcher.log

logs contained "Failed to apply full system state" and that "sdw-admin --apply" returned a non-zero exit status 1

    • Observe that the migration flag is still present (i.e. the updater will try again)
  1. Undo your modification to /usr/share/securedrop-workstation-dom0-config/scripts/provision-all

Fix for #685

  1. Install an RPM from this branch (either via make staging or dnf reinstall of the built RPM after `make clone)
  2. Remove /tmp/sdw-migrations if it exists
  3. Modify your copy of /srv/salt/update-xfce-settings to exit 1 immediately
  4. Run the updater with /opt/securedrop/launcher/sdw-launcher.py --skip-delta 0

First I had a network error (oh the pain of waiting for the updater to run all the way through even though I knew it would error around the 5% mark)

    • Observe that the updater ultimately reports an error
    • Observe that the apply_dom0 error is logged in ~/.securedrop_launcher/logs/launcher.log
  1. Undo your modification to /srv/salt/update-xfce-settings

@sssoleileraaa sssoleileraaa merged commit e06c180 into main Apr 8, 2021
@sssoleileraaa sssoleileraaa deleted the 668-better-error-handling branch April 8, 2021 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants