Skip to content

Commit 355529e

Browse files
committed
[R] Fix: ES client causes urllib3 DeprecationWarning (#5592, PR #5909)
2 parents 3ef0ee9 + aadc4f3 commit 355529e

19 files changed

+38
-23
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

requirements.all.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ blinker==1.7.0
1010
boto3==1.28.63
1111
boto3-stubs==1.28.63
1212
botocore==1.31.63
13-
botocore-stubs==1.34.31
13+
botocore-stubs==1.34.34
1414
brotli==1.1.0
1515
cachetools==5.3.2
16-
certifi==2023.11.17
16+
certifi==2024.2.2
1717
cffi==1.16.0
1818
chalice==1.30.0+12
1919
charset-normalizer==3.3.2
@@ -26,7 +26,7 @@ cryptography==42.0.2
2626
deprecated==1.2.13
2727
docker==6.1.2
2828
docutils==0.16
29-
elasticsearch==7.10.1
29+
elasticsearch==7.17.9
3030
elasticsearch-dsl==7.4.0
3131
et-xmlfile==1.1.0
3232
fastavro==1.8.2
@@ -51,8 +51,8 @@ google-crc32c==1.5.0
5151
google-resumable-media==2.7.0
5252
googleapis-common-protos==1.62.0
5353
greenlet==3.0.3
54-
grpcio==1.60.0
55-
grpcio-status==1.60.0
54+
grpcio==1.60.1
55+
grpcio-status==1.60.1
5656
http-message-signatures==0.4.4
5757
http_sfv==0.9.9
5858
httplib2==0.22.0
@@ -68,7 +68,7 @@ jsonschema==4.17.3
6868
jsonschema-spec==0.1.6
6969
lazy-object-proxy==1.10.0
7070
locust==2.12.2
71-
markupsafe==2.1.4
71+
markupsafe==2.1.5
7272
mccabe==0.7.0
7373
more-itertools==9.0.0
7474
moto==4.1.13
@@ -107,7 +107,7 @@ pyrsistent==0.20.0
107107
python-dateutil==2.8.2
108108
python-editor==1.0.4
109109
python-gitlab==3.13.0
110-
pytz==2023.4
110+
pytz==2024.1
111111
pyyaml==6.0.1
112112
pyzmq==25.1.2
113113
readchar==4.0.5

requirements.dev.trans.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
blessed==1.20.0
22
blinker==1.7.0
3-
botocore-stubs==1.34.31
3+
botocore-stubs==1.34.34
44
brotli==1.1.0
55
click==8.1.7
66
colorama==0.4.4

requirements.trans.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
bagit==1.8.1
22
bagit-profile==1.3.1
33
cachetools==5.3.2
4-
certifi==2023.11.17
4+
certifi==2024.2.2
55
cffi==1.16.0
66
charset-normalizer==3.3.2
77
cryptography==42.0.2
88
google-cloud-core==2.4.1
99
google-crc32c==1.5.0
1010
google-resumable-media==2.7.0
1111
googleapis-common-protos==1.62.0
12-
grpcio==1.60.0
13-
grpcio-status==1.60.0
12+
grpcio==1.60.1
13+
grpcio-status==1.60.1
1414
http_sfv==0.9.9
1515
idna==3.6
16-
markupsafe==2.1.4
16+
markupsafe==2.1.5
1717
orderedmultidict==1.0.1
1818
packaging==23.2
1919
proto-plus==1.23.0
@@ -23,7 +23,7 @@ pyasn1-modules==0.3.0
2323
pycparser==2.21
2424
pyopenssl==24.0.0
2525
python-dateutil==2.8.2
26-
pytz==2023.4
26+
pytz==2024.1
2727
s3transfer==0.7.0
2828
setuptools-scm==5.0.2
2929
six==1.16.0

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ botocore==1.31.63
66
chevron==0.14.0
77
deprecated==1.2.13
88
elasticsearch-dsl==7.4.0
9-
elasticsearch==7.10.1
9+
elasticsearch==7.17.9
1010
fastavro==1.8.2
1111
furl==2.1.3
1212
google-auth[pyopenssl]==2.23.3

src/azul/es.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
RequestsHttpConnection,
2121
Urllib3HttpConnection,
2222
)
23+
from elasticsearch.transport import (
24+
Transport,
25+
)
2326

2427
from azul import (
2528
config,
@@ -165,7 +168,8 @@ def _create_client(cls, host, port, timeout):
165168
# error handling, we disable the implicit retries via max_retries=0.
166169
common_params = dict(hosts=[dict(host=host, port=port)],
167170
timeout=timeout,
168-
max_retries=0)
171+
max_retries=0,
172+
transport_class=ProductAgnosticTransport)
169173
if host.endswith('.amazonaws.com'):
170174
aws_auth = CachedBotoAWSRequestsAuth(aws_host=host,
171175
aws_region=aws.region_name,
@@ -178,3 +182,14 @@ def _create_client(cls, host, port, timeout):
178182
else:
179183
return Elasticsearch(connection_class=AzulUrllib3HttpConnection,
180184
**common_params)
185+
186+
187+
class ProductAgnosticTransport(Transport):
188+
"""
189+
A transport class that disables client-side product verification. This
190+
bypasses the check that would otherwise prevent us from using ES v7.15+ with
191+
OpenSearch.
192+
"""
193+
194+
def _do_verify_elasticsearch(self, headers, timeout):
195+
self._verified_elasticsearch = True

src/azul/indexer/index_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ def flatten(value: JSON, *path) -> Iterable[tuple[tuple[str, ...], AnyJSON]]:
401401
def delete_indices(self, catalog: CatalogName):
402402
es_client = ESClientFactory.get()
403403
for index_name in self.index_names(catalog):
404-
if es_client.indices.exists(index_name):
404+
if es_client.indices.exists(index=index_name):
405405
es_client.indices.delete(index=index_name)
406406

407407
def contribute(self,

test/azul_test_case.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ class RE(str):
137137

138138
'Call to deprecated function (or staticmethod) patch_source_cache',
139139

140-
# FIXME: ES client causes urllib3 DeprecationWarning
141-
# https://github.com/DataBiosphere/azul/issues/5592
142-
(
143-
'HTTPResponse.getheaders() is deprecated and will be removed in urllib3 v2.1.0.'
144-
' Instead access HTTPResponse.headers directly.',
145-
'elasticsearch.connection.http_urllib3'
140+
# FIXME: DeprecationWarning for ES body parameter
141+
# https://github.com/DataBiosphere/azul/issues/5912
142+
#
143+
RE(
144+
'The \'body\' parameter is deprecated for the \'.*\' API '
145+
'and will be removed in .*. Instead use .*'
146146
),
147147
},
148148
UserWarning: {

test/service/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def _add_docs(self, num_docs):
180180
for doc in docs
181181
)
182182
)
183-
self.es_client.bulk(body, index=self._index_name, refresh=True)
183+
self.es_client.bulk(body=body, index=self._index_name, refresh=True)
184184

185185
@property
186186
def _index_name(self):

0 commit comments

Comments
 (0)