-
Notifications
You must be signed in to change notification settings - Fork 16
Support Backend Delete and Disable Collection Requirements [#602] #637
Conversation
…nlogstatus.skipped. - Allow setting the disabled field in the PATCH ConnectionConfig endpoint - Set disabled_at if disabled is updated - Skip running a collection and return the default value if its associated connectionconfig is disable.
… deleting a collection while the privacy request is in progress.
- Update copy/pasted docstring - Add test for deleting collection and then restarting from failure. - Add new connection config disabled key to api response
… deleted or disabled for completeness.
|
@ethyca/docs-authors minor one-line change added to docs about the disabled field for a connectionconfig |
| def integration_mongodb_config(db) -> ConnectionConfig: | ||
| connection_config = ConnectionConfig( | ||
| key="mongo_example", | ||
| connection_type=ConnectionType.mongodb, | ||
| access=AccessLevel.write, | ||
| secrets=integration_secrets["mongo_example"], | ||
| name="mongo_example", | ||
| ) | ||
| connection_config.save(db) | ||
| yield connection_config | ||
| connection_config.delete(db) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This connectionconfig wasn't being saved to the db previously, which was fine, but now I'd like to be able to persist it to test disabling it mid-privacy request, for example, and I'm changing the fixture scope so updates to disabled are reset for another test.
| @pytest.mark.integration | ||
| def test_restart_graph_from_failure( | ||
| db, | ||
| policy, | ||
| example_datasets, | ||
| integration_postgres_config, | ||
| integration_mongodb_config, | ||
| mongo_postgres_dataset_graph, | ||
| ) -> None: | ||
| """Run a failed privacy request and restart from failure""" | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test isn't new, I've just renamed the file and added more execution-related tests
| f"ConnectionConfig {connection_config.key} is disabled.", | ||
| ) | ||
|
|
||
| @retry(action_type=ActionType.access, default_return=[]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We used to have this default_return parameter, and it was removed, but I'm restoring it now because it's handy for when a collection is skipped, we just return the "default_return".
| * `disabled` determines whether the ConnectionConfig is active. If True, we skip running queries for any collection associated with that ConnectionConfig. | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 all good from me - thank you for including!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @conceptualshark!
eastandwestwind
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me @pattisdr ! I especially appreciate the thorough test additions / edits here, as well as clear naming of methods/vars throughout the PR. Thanks!
| ) | ||
| op.add_column( | ||
| "connectionconfig", | ||
| sa.Column("disabled_at", sa.DateTime(timezone=True), nullable=True), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good foresight to add this disabled_at column
| return super().delete(db=db) | ||
|
|
||
|
|
||
| @event.listens_for(ConnectionConfig.disabled, "set") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know about this sqlalchemy feature, awesome!
|
thanks for the quick turnaround @eastandwestwind! |
* WIP Add disabled and disabled_at to connectionconfig and add executionlogstatus.skipped. - Allow setting the disabled field in the PATCH ConnectionConfig endpoint - Set disabled_at if disabled is updated - Skip running a collection and return the default value if its associated connectionconfig is disable. * Add tests for disabling collections in progress and skipping collections on restart. * Remove unused var. * Add tests for deleting a collection before you make a new request and deleting a collection while the privacy request is in progress. * Move migration. * - Remove unused property - Update copy/pasted docstring - Add test for deleting collection and then restarting from failure. - Add new connection config disabled key to api response * Add missing mocked function. * Update scopes to match. * Add tests that execution logs are untouched if a connection config is deleted or disabled for completeness. * Log request id instead of request object.
❗ Contains migration; verify downrev before merging.
Purpose
Support deleted/disabled collection execution requirements. A lot of this behavior was already true, we're just adding the new concept of a "disabled" collection, and then adding integration tests to confirm the behavior below:
Changes
disabledfield to ConnectionConfig (default value of False), as well asdisabled_at.disabled_atis automatically set ifdisabledis updated.skippedstatus to ExecutionLog.skip_if_disabledcheck to theretrydecorator which wraps access and erasure requests. If a collection's associatedConnectionConfigis disabled, created a skipped execution log and return empty data to downstream collections. This way, we still get the logs, and the overall graph doesn't have to change if a collection is disabled, but no queries are run for that collection.Checklist
CHANGELOG.mdfileCHANGELOG.mdfile is being appended toUnreleasedsection 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.Run Unsafe PR Checkslabel has been applied, and checks have passed, if this PR touches any external servicesTicket
Fixes #602