Open yull1860 opened 2 years ago
Thanks for the feedback! We are currently investigating and will update you shortly.
@yull1860 the first line is intended as such since the idea is to delete all instances older than 30 days. So, the oldest date possible to 30 days ago, are the instances we are deleting. Also, since the function is async
and we don't really need to do anything with the result, returning the async operation should be OK I believe (unless my understanding of python async is wrong :))
@PramodValavala-MSFT see my comments below :
**>>> created_time_from = datetime.min
created_time_to = datetime.today() + timedelta(days = -1) a=f"testing w/ = '{created_time_from} - {created_time_to}'" a "testing w/ = '0001-01-01 00:00:00** - 2022-02-10 17:50:07.650003'"
use above parameter will result Error : Please provide value for 'createdTimeFrom' parameter.
/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py:257: RuntimeWarning: coroutine 'DurableOrchestrationClient.purge_instance_history_by' was never awaited
@ggailey777 , @cgillum , Could you please look into this ?
I think @davidmrdavid is the right guy to help with this one. :)
Hi all.
@MughundhanRaveendran-MSFT:
I think the await
may be needed here. And looking into the docs, I think it's needed in quite a few places in other code snippets.
As for the use of datetime.min
, I need to set up a reproducer for that.
@MughundhanRaveendran-MSFT - do you mind assigning me to this ticket as well so I can follow up on it? Thanks!
Hi all,
I can confirm I'm running into issues using datetime.min for the created_time_from as well. Here is the stacktrace I get indicating there is a HTTP 400 status code message returned:
Result: Failure Exception: Exception:
The operation failed with an unexpected status code 400 Stack:
File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 403, in _handle__invocation_request
call_result = await self._run_async_func(
File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 655, in _run_async_func
return await ExtensionManager.get_async_invocation_wrapper(
File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/extension.py", line 147, in get_async_invocation_wrapper
result = await function(**args)
File "/home/site/wwwroot/orchestration_maintenance/main.py", line 27, in main
result = await client.purge_instance_history_by(created_time_from, created_time_to)
File "/home/site/wwwroot/.python_packages/lib/site-packages/azure/durable_functions/models/DurableOrchestrationClient.py", line 413, in purge_instance_history_by
return self._parse_purge_instance_history_response(response)
File "/home/site/wwwroot/.python_packages/lib/site-packages/azure/durable_functions/models/DurableOrchestrationClient.py", line 628, in _parse_purge_instance_history_response
raise Exception(result)
Since I want to remove every result before a given date, I managed to clear out things by removing the created_time_from al together. My code now looks something like this
async def main(maintenanceTimer: func.TimerRequest, starter: str):
"""Main entrypoint."""
client = df.DurableOrchestrationClient(starter)
created_time_to = datetime.today() + timedelta(days=-1)
logger.info(f"Purging orchestration runs older than {created_time_to}")
result = await client.purge_instance_history_by(created_time_to)
if result:
logger.info(f"{result.instances_deleted} instances deleted")
else:
logger.warning("Nothing returned from purge instance history.")
Is this still being worked on?
I just merged a documentation update to add the missing await
statement, so that should be reflected in the documentation no later than tomorrow. Apologies for the delay on that, but it should be addressed now
Regarding the use of datetime.min
: I still need to look into that. I managed to repro the issue a few months back, and it seemed to be a problem with Azurite in particular, but I would need to re-run some tests to confirm.
The python sample code using purge_instance_history_by is not correct, wrong line commented and see bold words for update .
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.