Skip to content

Commit

Permalink
Cleanup code for elasticsearch<8 (apache#35707)
Browse files Browse the repository at this point in the history
* update elasticsearch doc for `use_ssl` parameter

* Remove outdated support for elasticsearch<8

* bring back retry_timeout
  • Loading branch information
eladkal authored Dec 1, 2023
1 parent cf052dc commit 396b1ba
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
9 changes: 6 additions & 3 deletions airflow/providers/elasticsearch/log/es_task_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,17 @@ def get_es_kwargs_from_config() -> dict[str, Any]:
if elastic_search_config
else {}
)
# For elasticsearch>8 retry_timeout have changed for elasticsearch to retry_on_timeout
# in Elasticsearch() compared to previous versions.
# Read more at: https://elasticsearch-py.readthedocs.io/en/v8.8.2/api.html#module-elasticsearch
# TODO: Remove in next major release (drop support for elasticsearch<8 parameters)
if (
elastic_search_config
and "retry_timeout" in elastic_search_config
and not kwargs_dict.get("retry_on_timeout")
):
warnings.warn(
"retry_timeout is not supported with elasticsearch>=8. Please use `retry_on_timeout`.",
AirflowProviderDeprecationWarning,
stacklevel=2,
)
retry_timeout = elastic_search_config.get("retry_timeout")
if retry_timeout is not None:
kwargs_dict["retry_on_timeout"] = retry_timeout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ cert, etc.) use the ``elasticsearch_configs`` setting in your ``airflow.cfg``
remote_logging = True
[elasticsearch_configs]
use_ssl=True
verify_certs=True
ca_certs=/path/to/CA_certs
Expand Down
5 changes: 0 additions & 5 deletions tests/providers/elasticsearch/log/test_es_task_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,14 +671,11 @@ def test_retrieve_config_keys():
"""
with conf_vars(
{
("elasticsearch_configs", "use_ssl"): "True",
("elasticsearch_configs", "http_compress"): "False",
("elasticsearch_configs", "timeout"): "10",
}
):
args_from_config = get_es_kwargs_from_config().keys()
# use_ssl is removed from config
assert "use_ssl" not in args_from_config
# verify_certs comes from default config value
assert "verify_certs" in args_from_config
# timeout comes from config provided value
Expand All @@ -698,8 +695,6 @@ def test_retrieve_retry_on_timeout():
}
):
args_from_config = get_es_kwargs_from_config().keys()
# use_ssl is removed from config
assert "retry_timeout" not in args_from_config
# verify_certs comes from default config value
assert "retry_on_timeout" in args_from_config

Expand Down

0 comments on commit 396b1ba

Please sign in to comment.