You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Drain Mode feature in Azure Functions is intended to allow ongoing invocations to finish executing during a graceful shut down, therefore when drain mode is enabled for any given function, we should not be signaling cancellation.
A request for all of the WebJobs extensions to address this went out a couple years ago, but this extension was flagged as one that does not currently use the DrainModeManager and may require changes.
Tasks
Investigate the Kafka WebJobs extension and determine if ongoing invocations are cancelled when drain mode is requested
If an ongoing invocation is being cancelled, implement changes to ensure that when drain mode is enabled, the invocation continues executing and the CT is not signaled.
How to test the behaviour
Create a new .NET (isolated) Function
Write a function that is a) using the KafkaTrigger binding and, b) handling the cancellation token
Start the function and trigger an invocation
Request drain mode via /admin/host/drain
Expected behaviour:
The function invocation should continue executing as normal
Example function:
This is an example of a function I used to test the TimerTrigger. If drain mode is enabled, we should not be hitting the catch-block:
[Function("MyTimer")]publicasyncTaskRun([TimerTrigger("*/30 * * * * *")]TimerInfomyTimer,CancellationTokencancellationToken){_logger.LogWarning($"Timer trigger function executed at: {DateTime.Now}");if(myTimer.ScheduleStatusis not null){_logger.LogWarning($"Next timer schedule at: {myTimer.ScheduleStatus.Next}");}try{cancellationToken.ThrowIfCancellationRequested();awaitTask.Delay(5000,cancellationToken);_logger.LogWarning($"Timer trigger completed at: {DateTime.Now}");}catch(OperationCanceledException){_logger.LogWarning("Timer trigger function was cancelled.");}}
Examples of this issue being addressed in other extensions
Do not pass cancelled token to ExecuteAsync when draining
The Drain Mode feature in Azure Functions is intended to allow ongoing invocations to finish executing during a graceful shut down, therefore when drain mode is enabled for any given function, we should not be signaling cancellation.
A request for all of the WebJobs extensions to address this went out a couple years ago, but this extension was flagged as one that does not currently use the DrainModeManager and may require changes.
Tasks
How to test the behaviour
/admin/host/drain
Expected behaviour:
Example function:
This is an example of a function I used to test the TimerTrigger. If drain mode is enabled, we should not be hitting the catch-block:
Examples of this issue being addressed in other extensions
Do not pass cancelled token to ExecuteAsync when draining
The text was updated successfully, but these errors were encountered: