Repository navigation
Closed
Labels
affected_version:3.0Issues Reported for 3.0area:corekind:bugThis is a clearly a bugpriority:mediumBug that should be fixed before next release but would not block a release
Description
Apache Airflow version
3.0.1
If "Other Airflow 2 version" selected, which one?
No response
What happened?
When stopping a running task manually via UI, the on_kill hook is not executed, and no log message appears.
What you think should happen instead?
The on_kill hook should be called and so the log message should be printed out.
How to reproduce
I use the following Operator to test this issue:
from time import sleep
from typing import TYPE_CHECKING
from airflow.models.baseoperator import BaseOperator
import time
import requests
if TYPE_CHECKING:
from airflow.sdk.definitions.context import Context
class TestSmoothOperator(BaseOperator):
"""Operator that logs a YouTube link to Sade song "Smooth Operator"."""
ui_color = "#e8f7e4"
yt_link: str = "https://www.youtube.com/watch?v=4TYv2PhG89A"
def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)
def pre_execute(self, context):
print("pre Execute!")
def post_execute(self, context):
print("post Execute!")
def execute(self, context: Context):
# Number of times to loop
num_iterations = 3
for i in range(num_iterations):
print(f"Iteration {i + 1}: Sleeping for 20 seconds...")
time.sleep(20) # Sleep for 20 seconds
print(f"Iteration {i + 1}: Woke up after 20 seconds!")
self.log.info("Enjoy Sade - Smooth Operator: %s", self.yt_link)
def post_execute(self, context):
print("post Execute!")
def on_kill(self) -> None:
self.log.info("Logging on Kill!")
print("please someone kill me!")
I use the following DAG:
import os
from datetime import timedelta
from airflow import DAG
import airflow_runtime.tools.airflow_tools
import airflow_runtime.tools.default_args
import airflow_runtime.tools.emr_spark
from airflow_runtime.tools.test_smooth_operator import TestSmoothOperator
DAG_ID = os.path.basename(__file__).replace(".py", "")
schedule = None
with DAG(
DAG_ID,
default_args=airflow_runtime.tools.default_args.default_args,
max_active_runs=1,
dagrun_timeout=timedelta(minutes=30),
on_success_callback=airflow_runtime.tools.airflow_tools.cleanup_xcom,
tags=["vscode", "development"],
schedule=schedule,
catchup=False,
) as dag:
op_kwargs = {"instance_names": ["my-instance"]}
start_instance = TestSmoothOperator(
task_id="test_smoothOperator",
)
start_instance
- Start the Task
- Stop the Task
- Check the logs
Operating System
AWS EKS / Kubernetes; Helm chart 1.17.0-dev
Versions of Apache Airflow Providers
Deployment
Official Apache Airflow Helm Chart
Deployment details
Kubernetes 1.30
Airflow 3.0.1
Anything else?
The problem occurs every time.
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
affected_version:3.0Issues Reported for 3.0area:corekind:bugThis is a clearly a bugpriority:mediumBug that should be fixed before next release but would not block a release
Activity
boring-cyborg commentedon May 23, 2025
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.
eladkal commentedon May 23, 2025
We'll check it for Airflow 3.0.2
jroachgolf84 commentedon May 23, 2025
Just curious - when you say "stop", do you mean "Mark as Failed"? Or just pausing the DAG?
hendricjabs commentedon May 23, 2025
Thank you for your fast response!
@jroachgolf84 I mean "Mark as Failed".
gopidesupavan commentedon May 31, 2025
un assigned myslef, dont have bandwitdh to do next few days.
gbloisi-openaire commentedon Jul 21, 2025
I got to the same issue with SparkKubernetesOperator noticing sparkapplication are not deleted when a DAG or task is stopped by the "Mark as Failed" action in UI.
I can confirm this is still standing as of Airflow 3.0.3 and it seems to me a quite severe issue.
It is not working also when there is an explicit kill in the logs:
[2025-07-21, 10:11:14] INFO - The Pod has an Event: Started container spark-kubernetes-driver from spec.containers{spark-kubernetes-driver}: source="airflow.providers.cncf.kubernetes.utils.pod_manager.PodManager" Waiting until 120s to get the POD scheduled...: source="airflow.providers.cncf.kubernetes.utils.pod_manager.PodManager" [2025-07-21, 10:11:19] ERROR - Server indicated the task shouldn't be running anymore. Terminating process: detail={"detail":{"reason":"not_running","message":"TI is no longer in the running state and task should terminate","current_state":"failed"}}: source="task" [2025-07-21, 10:11:19] ERROR - Task killed!: source="task"gopidesupavan commentedon Jul 22, 2025
have fix for this will get it..