Open
Description
First check
- I added a descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn't find it.
- I searched the Prefect documentation for this issue.
- I checked that this issue is related to Prefect and not one of its dependencies.
Bug summary
When running a prefect flow as a kubernetes job if the flow run is cancelled while tasks are in a running state the concurrency slots used by the tasks are not released though the tasks are in a cancelled state.
This is reproducible via the following steps with the code below with a flow run triggered as a kuberenetes job
- Create a concurrency limit in Prefect Cloud
- Add a task label to use that concurrency limit
- Trigger the flow and cancel the flow once the tasks that use that concurrency limit are in a “running” state and populate the concurrency limit queue
- The tasks’ state will change from “running” to “canceled”, but will remain in the concurrency limit queue
potentially related but separate issue:
#7732
Reproduction
from prefect import flow, task, get_run_logger
import time
@task(tags=["some_concurrency_tag"])
def log_something(x):
logger = get_run_logger()
logger.info(f"this is log number {x}")
time.sleep(60)
@flow
def smoke_test_flow():
for x in range(0, 100):
log_something.submit(x)
if __name__ == "__main__":
smoke_test_flow()
Error
No response
Versions
runs from the base docker image prefecthq/prefect:2.8.0-python3.10
Additional context
Cluster config, minus any sensitive information
{
"location": "southcentralus",
"name": "prefect-k8s-dev",
"tags": {
"Application": "",
"BudgetAlert": "",
"BusinessGroup": "Data Analytics",
"CostCode": "",
"Priority": "",
"TechnicalContact": "",
"environment": "dev",
"prefect": "true"
},
"type": "Microsoft.ContainerService/ManagedClusters",
"properties": {
"provisioningState": "Succeeded",
"powerState": {
"code": "Running"
},
"kubernetesVersion": "1.24.9",
"dnsPrefix": "prefect-k8s-dev",
"agentPoolProfiles": [
{
"name": "default",
"count": 2,
"vmSize": "Standard_DS2_v2",
"osDiskSizeGB": 50,
"osDiskType": "Ephemeral",
"kubeletDiskType": "OS",
"maxPods": 110,
"type": "VirtualMachineScaleSets",
"enableAutoScaling": false,
"provisioningState": "Succeeded",
"powerState": {
"code": "Running"
},
"orchestratorVersion": "1.24.9",
"enableNodePublicIP": false,
"mode": "System",
"enableEncryptionAtHost": false,
"enableUltraSSD": false,
"osType": "Linux",
"osSKU": "Ubuntu",
"nodeImageVersion": "AKSUbuntu-1804gen2containerd-2023.01.20",
"upgradeSettings": {},
"enableFIPS": false
}
]
}
}