Skip to content
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

Don't signal shutdown Cancellation Token when starting Drain Mode and include end to end tests #2795

Open
nzthiago opened this issue Nov 30, 2021 · 13 comments · Fixed by #2821

Comments

@nzthiago
Copy link
Member

nzthiago commented Nov 30, 2021

Customers don't expect a shut down Cancellation Token (related: #2782) when the host enters drain mode.

To ensure currently executing .NET in process functions are allowed to complete successfully we should not signal a host shutdown cancellation token when entering drain mode.

Also as part of the Drain Mode End to End Tests we should have one or more end to end tests that has:

  • A long running function that doesn't have a cancellation token in its declaration and a long running function that does have a cancellation token in its declaration
  • one or multiple function invocations are started for both functions (with and without cancellation token), then enables Drain Mode, then ensures those functions are allowed to complete successfully
@nzthiago nzthiago changed the title Include end to end test for Drain Mode with currently executing function invocations Don't send shutdown Cancellation Token when starting Drain Mode and include end to end tests Dec 1, 2021
@liliankasem
Copy link
Member

Potentially related to #2776

@fabiocav fabiocav changed the title Don't send shutdown Cancellation Token when starting Drain Mode and include end to end tests Don't signal shutdown Cancellation Token when starting Drain Mode and include end to end tests Dec 1, 2021
@fabiocav fabiocav added this to the Functions Sprint 116 milestone Jan 12, 2022
@es-alt
Copy link

es-alt commented Feb 28, 2022

@soninaren , what nuget version is this in?

@soninaren
Copy link
Member

@soninaren , what nuget version is this in?

Should be version 3.0.33. I don't think it has been released yet.

@es-alt
Copy link

es-alt commented Mar 2, 2022

@soninaren , this affects us a lot in production with HttpTriggered functions. Is there at least an approximate estimate of when 3.0.33 can be released?

@soninaren
Copy link
Member

@lecamarade are you using the webjobs sdk or a function app. I think the function release is already in progress.

@es-alt
Copy link

es-alt commented Mar 7, 2022

@soninaren , we use a function app. If release is in progress, are we talking, days, weeks or months?

@soninaren
Copy link
Member

@soninaren , we use a function app. If release is in progress, are we talking, days, weeks or months?

Based on the current release progress it looks like it should be complete in a couple of weeks.

@mathewc
Copy link
Member

mathewc commented May 15, 2023

Reactivating this because we're seeing inconsistent behavior across various extensions when drain is initiated. For example, the latest versions of both the Azure Queues and ServiceBus extensions trigger the cancellation token when drain is started.

@mathewc mathewc reopened this May 15, 2023
@drdamour
Copy link

drdamour commented Oct 19, 2023

i've been using azure functions for going on 4 years and drain mode is still a mystery to me. I had incorrectly assumed that it WOULD send cancellation tokens and got really confused when it did for some extensions and not for others. Seems like some docs around drain mode are missing in the az function space and it should be encouraged for extensions to document their expected drain mode behaviour

the recent "fix" in event hub extension pointed out IDrainModeManager which i had never come across in the Az functions docs.

limited results from google on this, some appear to be completely wrong like https://learn.microsoft.com/en-us/answers/questions/770912/why-do-i-see-drainmode-mode-enabled-in-the-logs-an?source=docs

At this time, it sends a request to the Admin API to enter drain mode. Then all currently executing Functions on that instance receive a cancellation token which the customer can handle.

emphasis added.

and https://datanrg.blogspot.com/2021/06/azure-function-drain-mode.html

When the host is put in drain mode, It should:
Stop listening for new incoming requests,
Cancellation token is passed as a parameter to the function invocation,
Finally, a scale-in operation is performed.

@liliankasem
Copy link
Member

@drdamour IDrainModeManager is for internal use and is not intended for customers to use in their applications so you will not hear about this in the docs anywhere.

The intended behaviour for drain mode is:

  1. Stop listening for new incoming requests
  2. Allow existing function invocations to finish executing without interruption
  3. Scale-in operation is performed when all invocations are completed

I think there was some miscommunication on the intended behaviour which is why some extensions send a cancellation token and some don't, this is something that is actively being fix across the board.

@liliankasem
Copy link
Member

🤷‍♀️ news to me

@drdamour
Copy link

well...if it works as advertised it certainly fulfills a need i as an app developer have, though more in the durable functions space of knowing when my instance has entered drain mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants