-
Notifications
You must be signed in to change notification settings - Fork 66
Fix purge requests without a creation start time #616
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -419,7 +419,8 @@ async def purge_instance_history_by( | |
| Parameters | ||
| ---------- | ||
| created_time_from : Optional[datetime] | ||
| Delete orchestration history which were created after this Date. | ||
| Delete orchestration history which were created after this Date. Defaults to the | ||
| earliest datetime supported by Python. | ||
| created_time_to: Optional[datetime] | ||
| Delete orchestration history which were created before this Date. | ||
| runtime_status: Optional[List[OrchestrationRuntimeStatus]] | ||
|
|
@@ -431,6 +432,9 @@ async def purge_instance_history_by( | |
| PurgeHistoryResult | ||
| The results of the request to purge history | ||
| """ | ||
| if created_time_from is None: | ||
| created_time_from = datetime.min | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's my understanding that |
||
|
|
||
| options = RpcManagementOptions(created_time_from=created_time_from, | ||
| created_time_to=created_time_to, | ||
| runtime_status=runtime_status) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -351,8 +351,11 @@ async def test_delete_500_purge_instance_history(binding_string): | |
|
|
||
| @pytest.mark.asyncio | ||
| async def test_delete_200_purge_instance_history_by(binding_string): | ||
| mock_request = MockRequest(expected_url=f"{RPC_BASE_URL}instances/?runtimeStatus=Running", | ||
| response=[200, dict(instancesDeleted=1)]) | ||
| mock_request = MockRequest( | ||
| expected_url=f"{RPC_BASE_URL}instances/" | ||
| "?createdTimeFrom=0001-01-01T00:00:00.000000Z" | ||
| "&runtimeStatus=Running", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I don't think purging "Running" instances is actually valid, so I suggest that these tests use a valid status filter to avoid confusing readers (or agents) about what a valid use case for purge is. |
||
| response=[200, dict(instancesDeleted=1)]) | ||
| client = DurableOrchestrationClient(binding_string) | ||
| client._delete_async_request = mock_request.delete | ||
|
|
||
|
|
@@ -364,8 +367,11 @@ async def test_delete_200_purge_instance_history_by(binding_string): | |
|
|
||
| @pytest.mark.asyncio | ||
| async def test_delete_404_purge_instance_history_by(binding_string): | ||
| mock_request = MockRequest(expected_url=f"{RPC_BASE_URL}instances/?runtimeStatus=Running", | ||
| response=[404, MESSAGE_404]) | ||
| mock_request = MockRequest( | ||
| expected_url=f"{RPC_BASE_URL}instances/" | ||
| "?createdTimeFrom=0001-01-01T00:00:00.000000Z" | ||
| "&runtimeStatus=Running", | ||
| response=[404, MESSAGE_404]) | ||
| client = DurableOrchestrationClient(binding_string) | ||
| client._delete_async_request = mock_request.delete | ||
|
|
||
|
|
@@ -377,8 +383,11 @@ async def test_delete_404_purge_instance_history_by(binding_string): | |
|
|
||
| @pytest.mark.asyncio | ||
| async def test_delete_500_purge_instance_history_by(binding_string): | ||
| mock_request = MockRequest(expected_url=f"{RPC_BASE_URL}instances/?runtimeStatus=Running", | ||
| response=[500, MESSAGE_500]) | ||
| mock_request = MockRequest( | ||
| expected_url=f"{RPC_BASE_URL}instances/" | ||
| "?createdTimeFrom=0001-01-01T00:00:00.000000Z" | ||
| "&runtimeStatus=Running", | ||
| response=[500, MESSAGE_500]) | ||
| client = DurableOrchestrationClient(binding_string) | ||
| client._delete_async_request = mock_request.delete | ||
|
|
||
|
|
||
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.
One risk from this change is that an API call that previously returned a 400 now attempts to delete everything, which can be quite destructive. I'm not as familiar with the original issue, but we should think carefully about whether this risk is worth the benefit.