Bowrna commented on code in PR #34457:
URL: https://github.com/apache/airflow/pull/34457#discussion_r1542691829
##########
airflow/jobs/job.py:
##########
@@ -131,22 +146,20 @@ def executors(self):
def heartrate(self) -> float:
return Job._heartrate(self.job_type)
- def is_alive(self, grace_multiplier=2.1) -> bool:
+ def is_alive(self) -> bool:
"""
Is this job currently alive.
We define alive as in a state of RUNNING, and having sent a heartbeat
within a multiple of the heartrate (default of 2.1)
-
- :param grace_multiplier: multiplier of heartrate to require heart beat
- within
"""
+ threshold_value = health_check_threshold(
+ self.job_type, self.heartrate, self.grace_multiplier
Review Comment:
@potiuk Guess I was able to identify the issue. I have added the
grace_multiplier in the __init__ part of the code
https://github.com/Bowrna/airflow/blob/ddc7d44fecf217f56d55260dc5c997ecd4179b0b/airflow/jobs/job.py#L119-L135
But when invoked from health check API, it invokes the most_recent_job
function which returns the Job object collected from the DB. There is a
possibility in code, that init function is not invoked at all until this point.
But as grace_multiplier is inside init it is throwing no attribute error. But
other params like job_type( available as param of the class) and heartrate(
available as response of the staticmethod) are available. How do I handle this
case? @potiuk. I have tried keeping grace_multiplier outside any conditions too
but it failed with same error as above
https://github.com/Bowrna/airflow/blob/ddc7d44fecf217f56d55260dc5c997ecd4179b0b/airflow/jobs/job.py#L376-L395
--
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]