Owen-CH-Leung commented on code in PR #33135:
URL: https://github.com/apache/airflow/pull/33135#discussion_r1285897313
##########
airflow/providers/elasticsearch/log/es_task_handler.py:
##########
@@ -292,27 +292,24 @@ def es_read(self, log_id: str, offset: int | str,
metadata: dict) -> list | Elas
}
try:
- max_log_line = self.client.count(index=self.index_patterns,
body=query)["count"]
+ max_log_line = self.client.count(index=self.index_patterns,
body=query)["count"] # type: ignore
except NotFoundError as e:
self.log.exception("The target index pattern %s does not exist",
self.index_patterns)
raise e
- except ElasticsearchException as e:
- self.log.exception("Could not get current log size with log_id:
%s", log_id)
- raise e
logs: list[Any] | ElasticSearchResponse = []
if max_log_line != 0:
try:
query.update({"sort": [self.offset_field]})
- res = self.client.search(
+ res = self.client.search( # type: ignore
index=self.index_patterns,
body=query,
size=self.MAX_LINE_PER_PAGE,
from_=self.MAX_LINE_PER_PAGE * self.PAGE,
)
logs = ElasticSearchResponse(self, res)
- except elasticsearch.exceptions.ElasticsearchException:
- self.log.exception("Could not read log with log_id: %s",
log_id)
+ except Exception as err:
Review Comment:
Yes the exception `elasticsearch.exceptions.ElasticsearchException` is no
longer present. Instead new class of exceptions are defined such as
`UnsupportedProductError`, `NotFoundError` and so on. See this file:
https://github.com/elastic/elasticsearch-py/blob/main/elasticsearch/exceptions.py
And I feel like all those errors can occur when calling the ES API. So maybe
we should raise the exception after logging to the error log ?
--
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]