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

qubes: Add client-side timeouts #547

Merged
merged 6 commits into from
Sep 20, 2023
Merged

qubes: Add client-side timeouts #547

merged 6 commits into from
Sep 20, 2023

Conversation

apyrgio
Copy link
Contributor

@apyrgio apyrgio commented Sep 13, 2023

Extend the client-side capabilities of the Qubes isolation provider, by
adding client-side timeout logic.

This implementation brings the same logic that we used server-side to
the client, by taking into account the original file size and the number
of pages that the server returns.

Since the code does not have the exact same insight as the server has,
the calculated timeouts are in two places:

  1. The timeout for getting the number of pages. This timeout takes into
    account:
    • the disposable qube startup time, and
    • the time it takes to convert a file type to PDF
  2. The total timeout for converting the PDF into pixels, in the same way
    that we do it on the server-side.

Besides these changes, we also ensure that partial reads (e.g., due to
EOF) are detected (see exact=... argument)

Some things that are not resolved in this PR are:

Fixes #446
Refs #443
Refs #430

@apyrgio apyrgio added enhancement New feature or request timeout Dangerzone Times Out P:Qubes QubesOS integration labels Sep 13, 2023
@apyrgio apyrgio added this to the 0.5.0 milestone Sep 13, 2023
Copy link
Contributor

@deeplow deeplow left a comment

Choose a reason for hiding this comment

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

This is an initial review. Next week I'll do a more thorough one.

Also, the approach here seems to be a constant timeout for the whole document calculated at the beginning. I was thinking more of a per-page timeout. Is the intention to make this a per-page timeout once we actually stream the pages? (currently we only send them all in bulk when all is finished because we are blocked on #443)

dangerzone/util.py Show resolved Hide resolved
dangerzone/util.py Show resolved Hide resolved
tests/test_util.py Outdated Show resolved Hide resolved
@apyrgio
Copy link
Contributor Author

apyrgio commented Sep 14, 2023

Also, the approach here seems to be a constant timeout for the whole document calculated at the beginning. I was thinking more of a per-page timeout. Is the intention to make this a per-page timeout once we actually stream the pages? (currently we only send them all in bulk when all is finished because we are blocked on #443)

Yeap, ideally we should make it a per-page timeout, but we need to get rid of the server-side qubes wrapper to do that.

@apyrgio
Copy link
Contributor Author

apyrgio commented Sep 14, 2023

Ouch, there are lots of errors in this PR that I didn't see in my local environment. I'll send fixes for them soon as well.

Copy link
Contributor

@deeplow deeplow left a comment

Choose a reason for hiding this comment

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

LGTM

Add a simple stopwatch implementation to track the elapsed time since an
event, or the remaining time until a timeout.
Add a function that can read data from non-blocking fds, which we will
used later on to read from standard streams with a timeout.
Factor out the logic behind the calculate_timeout() method, used in
Dangerzone conversions, so that isolation providers can call it
directly.
Extend the client-side capabilities of the Qubes isolation provider, by
adding client-side timeout logic.

This implementation brings the same logic that we used server-side to
the client, by taking into account the original file size and the number
of pages that the server returns.

Since the code does not have the exact same insight as the server has,
the calculated timeouts are in two places:

1. The timeout for getting the number of pages. This timeout takes into
   account:
   * the disposable qube startup time, and
   * the time it takes to convert a file type to PDF
2. The total timeout for converting the PDF into pixels, in the same way
   that we do it on the server-side.

Besides these changes, we also ensure that partial reads (e.g., due to
EOF) are detected (see exact=... argument)

Some things that are not resolved in this commit are:
* We have both client-side and server-side timeouts for the first phase
  of the conversion. Once containers can stream data back to the
  application (see #443), these server-side timeouts can be removed.
* We do not show a proper error message when a timeout occurs. This will
  be part of the error handling PR (see #430)

Fixes #446
Refs #443
Refs #430
@apyrgio apyrgio merged commit 20157be into main Sep 20, 2023
11 checks passed
@apyrgio apyrgio deleted the 446-client-timeouts branch October 2, 2023 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P:Qubes QubesOS integration timeout Dangerzone Times Out
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Qubes: Client-side timeouts
2 participants