Skip to content

Commit

Permalink
Check attr on parent not self re TaskContextLogger set_context (#35780)
Browse files Browse the repository at this point in the history
To know whether we should supply `identifier` param, need to check parent class.
  • Loading branch information
dstandish committed Nov 21, 2023
1 parent 379b7c0 commit 2a06e27
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion airflow/providers/amazon/aws/log/s3_task_handler.py
Expand Up @@ -78,7 +78,9 @@ def hook(self):
)

def set_context(self, ti: TaskInstance, *, identifier: str | None = None) -> None:
if getattr(self, "supports_task_context_logging", False):
# todo: remove-at-min-airflow-version-2.8
# after Airflow 2.8 can always pass `identifier`
if getattr(super(), "supports_task_context_logging", False):
super().set_context(ti, identifier=identifier)
else:
super().set_context(ti)
Expand Down
4 changes: 3 additions & 1 deletion airflow/providers/elasticsearch/log/es_task_handler.py
Expand Up @@ -443,7 +443,9 @@ def set_context(self, ti: TaskInstance, *, identifier: str | None = None) -> Non
self.handler.setLevel(self.level)
self.handler.setFormatter(self.formatter)
else:
if getattr(self, "supports_task_context_logging", False):
# todo: remove-at-min-airflow-version-2.8
# after Airflow 2.8 can always pass `identifier`
if getattr(super(), "supports_task_context_logging", False):
super().set_context(ti, identifier=identifier)
else:
super().set_context(ti)
Expand Down
4 changes: 3 additions & 1 deletion airflow/providers/google/cloud/log/gcs_task_handler.py
Expand Up @@ -142,7 +142,9 @@ def client(self) -> storage.Client:
)

def set_context(self, ti: TaskInstance, *, identifier: str | None = None) -> None:
if getattr(self, "supports_task_context_logging", False):
# todo: remove-at-min-airflow-version-2.8
# after Airflow 2.8 can always pass `identifier`
if getattr(super(), "supports_task_context_logging", False):
super().set_context(ti, identifier=identifier)
else:
super().set_context(ti)
Expand Down
4 changes: 3 additions & 1 deletion airflow/providers/microsoft/azure/log/wasb_task_handler.py
Expand Up @@ -96,7 +96,9 @@ def hook(self):
return None

def set_context(self, ti: TaskInstance, *, identifier: str | None = None) -> None:
if getattr(self, "supports_task_context_logging", False):
# todo: remove-at-min-airflow-version-2.8
# after Airflow 2.8 can always pass `identifier`
if getattr(super(), "supports_task_context_logging", False):
super().set_context(ti, identifier=identifier)
else:
super().set_context(ti)
Expand Down

0 comments on commit 2a06e27

Please sign in to comment.