Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Cache/Surface Resume/Restart Privacy Request Details [#574] #591

Merged
merged 11 commits into from
Jun 9, 2022

Conversation

pattisdr
Copy link
Contributor

@pattisdr pattisdr commented Jun 2, 2022

❗ Contains migration; check downrev before merging

Purpose

In the event of a paused or failed privacy request, surface to the user how to resume/restart that request.

Changes

  • When a privacy request is paused or fails at a specific collection, cache additional information to aid in restarting: instead of storing a string containing the paused collection and paused step, store a dictionary containing both of these pieces, plus data needed for resuming the request if applicable.
  • Added two keys to the privacy request status endpoint for paused/failed privacy requests: "resume_endpoint" and "stopped_collection_details".
  • Save "paused_at" when either a pre-execution webhook or a manual collection pauses the request.

A GET /privacy_request/?request_id=<privacy_request_id> now returns something like:

{
    "items": [
        {
            "id": "pri_ed4a6b7d-deab-489a-9a9f-9c2b19cd0713",
            "created_at": "2022-06-06T20:12:28.809815+00:00",
            "started_processing_at": "2022-06-06T20:12:28.986462+00:00",
            "reviewed_at": null,
            "reviewed_by": null,
            "reviewer": null,
            "finished_processing_at": null,
            "status": "paused",
            ...,
            "stopped_collection_details": {
                "step": "access",
                "collection": "manual_key:filing_cabinet",
                "action_needed": [
                    {
                        "locators": {
                            "customer_id": [
                                1
                            ]
                        },
                        "get": [
                            "authorized_user",
                            "customer_id",
                            "id",
                            "payment_card_id"
                        ],
                        "update": null
                    }
                ]
            },
            "resume_endpoint": "/privacy-request/pri_ed4a6b7d-deab-489a-9a9f-9c2b19cd0713/manual_input"
        }
    ],
    "total": 1,
    "page": 1,
    "size": 50
}

A request that needs erasure input looks like this:

{
    "items": [
        {
            "id": "pri_59ea0129-fc6d-4a12-a5bd-2ee647bf5cec",
            "created_at": "2022-06-06T20:22:05.436361+00:00",
            "started_processing_at": "2022-06-06T20:22:05.473280+00:00",
            "reviewed_at": null,
            "reviewed_by": null,
            "reviewer": null,
            "finished_processing_at": null,
            "status": "paused",
            "external_id": null,
            ...,
            "stopped_collection_details": {
                "step": "erasure",
                "collection": "manual_key:filing_cabinet",
                "action_needed": [
                    {
                        "locators": {
                            "id": 2
                        },
                        "get": null,
                        "update": {
                            "authorized_user": null
                        }
                    }
                ]
            },
            "resume_endpoint": "/privacy-request/pri_59ea0129-fc6d-4a12-a5bd-2ee647bf5cec/erasure_confirm"
        }
    ],
    "total": 1,
    "page": 1,
    "size": 50
}

Checklist

  • Update CHANGELOG.md file
    • Merge in main so the most recent CHANGELOG.md file is being appended to
    • Add description within the Unreleased section in an appropriate category. Add a new category from the list at the top of the file if the needed one isn't already there.
    • Add a link to this PR at the end of the description with the PR number as the text. example: #1
  • Applicable documentation updated (guides, quickstart, postman collections, tutorial, fidesdemo, database diagram.
  • If docs updated (select one):
    • documentation complete, or draft/outline provided (tag docs-team to complete/review on this branch)
    • documentation issue created (tag docs-team to complete issue separately)
  • Good unit test/integration test coverage
  • This PR contains a DB migration. If checked, the reviewer should confirm with the author that the down_revision correctly references the previous migration before merging
  • The Run Unsafe PR Checks label has been applied, and checks have passed, if this PR touches any external services

Ticket

Fixes #570

@pattisdr pattisdr force-pushed the fidesops_570_surface_resume_instructions branch 2 times, most recently from edb55d5 to 057930a Compare June 6, 2022 20:14
@pattisdr pattisdr marked this pull request as ready for review June 7, 2022 15:20
Base automatically changed from fidesops_574_restart_from_failure to main June 7, 2022 15:42
…ta. The manual connector is probably not a SQL database, but it's a pretty readable way to surface what needs to be performed manually. The actually format will probably change.

- To the privacy request status endpoint, surface the stopped step, stopped collection, manual queries, and resume endpoint for paused or failed privacy requests.
…uest execution to store all details under the same key: the step, the collection, and any action needed to resume.

- Add a ManualQueryConfig
- Get rid of using the SQLQueryConfig to cache queries, instead opt to store these in a more generic way for later flexibility.
…a manual collection.

- Start setting finished_processing_at on errored privacy requests that fail due to a collection issue.
@pattisdr pattisdr force-pushed the fidesops_570_surface_resume_instructions branch from 28f14d3 to 8d039d5 Compare June 7, 2022 16:19
@pattisdr pattisdr changed the title Surface Resume/Restart Instructions [#574] Cache/Surface Resume/Restart Privacy Request Details [#574] Jun 8, 2022
…resume_instructions

# Conflicts:
#	CHANGELOG.md
docs/fidesops/docs/guides/reporting.md Outdated Show resolved Hide resolved
docs/fidesops/docs/guides/reporting.md Outdated Show resolved Hide resolved
src/fidesops/api/v1/endpoints/privacy_request_endpoints.py Outdated Show resolved Hide resolved
src/fidesops/models/privacy_request.py Show resolved Hide resolved
src/fidesops/service/connectors/query_config.py Outdated Show resolved Hide resolved
tests/api/v1/endpoints/test_privacy_request_endpoints.py Outdated Show resolved Hide resolved
tests/integration_tests/test_manual_task.py Outdated Show resolved Hide resolved
@pattisdr
Copy link
Contributor Author

pattisdr commented Jun 9, 2022

thanks for taking the time to review @sanders41! I believe I've addressed your comments.

@pattisdr
Copy link
Contributor Author

pattisdr commented Jun 9, 2022

@ethyca/docs-authors I've added a docs draft for how to view details on how to resume or restart your paused and failed privacy requests to the guides.

Copy link
Contributor

@sanders41 sanders41 left a comment

Choose a reason for hiding this comment

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

LGTM!

@sanders41 sanders41 merged commit 4f3ee0b into main Jun 9, 2022
@sanders41 sanders41 deleted the fidesops_570_surface_resume_instructions branch June 9, 2022 15:09
sanders41 pushed a commit that referenced this pull request Sep 22, 2022
* WIP Cache SQL queries for the manual connector for retrieve/update data.  The manual connector is probably not a SQL database, but it's a pretty readable way to surface what needs to be performed manually.  The actually format will probably change.

- To the privacy request status endpoint, surface the stopped step, stopped collection, manual queries, and resume endpoint for paused or failed privacy requests.

* Add unit tests asserting expected response for paused/failed privacy requests.

* Refactor caching details about the collection that halted privacy request execution to store all details under the same key: the step, the collection, and any action needed to resume.

- Add a ManualQueryConfig
- Get rid of using the SQLQueryConfig to cache queries, instead opt to store these in a more generic way for later flexibility.

* Get rid of elements that cache a SQLQuery from an earlier draft. We're now caching more generic components.

* Remove import of element that no longer exists.

* Add new paused_at field for when a request is paused by a webhook or a manual collection.

- Start setting finished_processing_at on errored privacy requests that fail due to a collection issue.

* Small docstring changes.

* Add changelog and docs.

* Respond to CR -

* Fix wording in docs.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Surface to user how to Pause/Resume Privacy Request
3 participants