Azure / Azure/azure-functions-host

Drain mode is not initiated when terminating a Functionapp in Kubernetes

Open
#8,879 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 12h
Merged PRs (30d)
38

Description

#### Investigative information

When I ran my Functionapp in a Kubernetes cluster, I observed that the Functionapp initiates drain mode and unregisters all the listeners from my application when I delete a Kubernetes pod or scale in my Kubernetes deployment.

![image](https://user-images.githubusercontent.com/10017600/199207669-e1ba3a2b-6d4e-4199-896d-601c7ee679c8.png)

However, when I upgraded my Functionapp to use the Azure Functions V4 runtime, I noticed the Functionapp no longer initiates drain mode as before - subsequent messages put into the queues continued to trigger the functions.

![image](https://user-images.githubusercontent.com/10017600/199207148-9865480c-85a2-4650-85fb-aa6ba715bedd.png)

#### Expected behavior

* Functionapp initiates drain mode and unregisters all the listeners from the application when a Kubernetes pod termination occurs.

#### Actual behavior

* Functionapp continues to execute to handle incoming triggers.

#### Related information

The above can be reproduced in a personal sample project I have created here:
- [Sample codes for containerized functionapp on v4 runtime](https://gitlab.com/victorchuack/adf-playground/-/tree/containerization-v4)
- [Sample codes for containerized functionapp on v3 runtime](https://gitlab.com/victorchuack/adf-playground/-/tree/containerization-v3)
Note: The only changes are in the Dockerfile and the csproj, as shown in the [diffs here](https://gitlab.com/victorchuack/adf-playground/-/compare/containerization-v3...containerization-v4?from_project_id=32222648&straight=true)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the behavior with the linked containerized Function App samples, comparing the v3 and v4 branches and their Dockerfiles and project files. Investigate the host's Kubernetes pod-termination path and verify that deleting or scaling in a pod initiates drain mode, unregisters listeners, and stops subsequent queue-triggered executions.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp, docker, kubernetes
Domain
backend, cloud, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.