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

ensure exceptions in reply job processing don't crash the application #827

Merged
merged 2 commits into from
Feb 27, 2020

Conversation

redshiftzero
Copy link
Contributor

Description

#820 consists of two parts:

  1. Ensuring that exceptions in reply job processing cannot crash the app, and
  2. Resolving races between the sync and the reply job (see comment here).

This just addresses the first part. I do not see crashers now locally, instead the reply will show up as failed.

Test Plan

  1. Apply diff here from the case @creviera found:
diff --git a/securedrop_client/api_jobs/uploads.py b/securedrop_client/api_jobs/uploads.py
index 8616b71..dac78c1 100644
--- a/securedrop_client/api_jobs/uploads.py
+++ b/securedrop_client/api_jobs/uploads.py
@@ -98,7 +98,7 @@ class SendReplyJob(ApiJob):
         # TODO: Once https://github.com/freedomofpress/securedrop-client/issues/648, we will want to
         # pass the default request timeout to reply_source instead of setting it on the api object
         # directly.
-        api_client.default_request_timeout = 5
+        api_client.default_request_timeout = 0.01
         return api_client.reply_source(sdk_source, encrypted_reply, self.reply_uuid)
  1. Sending a reply should not crash the app. Instead it will show up as failed in this case. Since it's a timeout it will also pause the queue.

I can confirm that the crash I initially reported in #820 (not due to the timeout, but a generic exception so harder to repro) is resolved by this, instead now I see:

2020-02-26 17:51:10,472 - securedrop_client.api_jobs.uploads:90(_set_status_to_failed) INFO: SQL error when setting reply a1e1263f-2e47-43bd-b507-807c5c9647d9 as failed, skipping: No row was found for one()

which is caused due to the DraftReply being deleted during the sync action, which we need to resolve (item 2 in the Description section).

Checklist

If these changes modify code paths involving cryptography, the opening of files in VMs or network (via the RPC service) traffic, Qubes testing in the staging environment is required. For fine tuning of the graphical user interface, testing in any environment in Qubes is required. Please check as applicable:

  • I have tested these changes in the appropriate Qubes environment
  • I do not have an appropriate Qubes OS workstation set up (the reviewer will need to test these changes)
  • These changes should not need testing in Qubes

If these changes add or remove files other than client code, packaging logic (e.g., the AppArmor profile) may need to be updated. Please check as applicable:

  • I have submitted a separate PR to the packaging repo
  • No update to the packaging logic (e.g., AppArmor profile) is required for these changes
  • I don't know and would appreciate guidance

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.

looks great! confirmed fixes crashing

@sssoleileraaa sssoleileraaa merged commit 656ba79 into master Feb 27, 2020
@sssoleileraaa sssoleileraaa deleted the exc-reply-crasher branch February 27, 2020 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants