atul-astronomer opened a new issue, #46410:
URL: https://github.com/apache/airflow/issues/46410
### Apache Airflow version
main (development)
### If "Other Airflow 2 version" selected, which one?
_No response_
### What happened?
The DAG has failed on the retry because TI object does not have attribute
next_method
### What you think should happen instead?
DAG should succeed on the second try.
### How to reproduce
The following DAG can be used to reproduce.
```python
class RetryOperator(BaseOperator):
def execute(self, context):
ti = context["ti"]
has_next_method = bool(ti.next_method)
try_number = ti.try_number
self.log.info(
f"In `execute`: has_next_method: {has_next_method},
try_number:{try_number}"
)
self.defer(
trigger=SuccessTrigger(),
method_name="next",
kwargs={"execute_try_number": try_number},
)
def next(self, context, execute_try_number, event=None):
self.log.info("In next!")
ti = context["ti"]
has_next_method = bool(ti.next_method)
try_number = ti.try_number
self.log.info(
f"In `next`: has_next_method: {has_next_method},
try_number:{try_number}, excute_try_number: {execute_try_number}"
)
if try_number == 1:
# Force a retry
raise AirflowException("Force a retry")
# Did we run `execute`?
if execute_try_number != try_number:
raise AirflowException("`execute` wasn't run during retry!")
return None # Success!
with DAG(
"triggerer_retry", schedule=None, start_date=datetime(2021, 9, 13),
tags=['core']
) as dag:
RetryOperator(task_id="retry", retries=1,
retry_delay=timedelta(seconds=15))
```
### Operating System
Linux
### Versions of Apache Airflow Providers
_No response_
### Deployment
Other
### Deployment details
_No response_
### Anything else?
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]