Skip to content

Conversation

pquentin
Copy link
Member

@pquentin pquentin commented Jan 6, 2025

Closes elastic/elasticsearch-py#2731

When sniffing is enabled, warn_if_varying_node_config_options checks if all node configs use the same options besides host, port, and a few others. This is done using dataclasses.asdict, which will try to use the same mechanism as pickling to convert SSLContext objects to a dictionary. However, SSLContext objects cannot be pickled, and there's no good way to check that they are identical.

Instead, we choose to ignore ssl_context. We also have to stop using asdict() because it converts all keys, even those we don't need. Instead, we use the shallow copy workaround from the docs: https://docs.python.org/3/library/dataclasses.html#dataclasses.asdict.

It's not triggered for normal code.
@pquentin pquentin merged commit af34992 into elastic:main Jan 6, 2025
11 checks passed
github-actions bot pushed a commit that referenced this pull request Jan 6, 2025
* Fix use of SSLContext with sniffing

* Fix lint

* Ignore enabled_cleanup_closed warning

It's not triggered for normal code.

* Remove warning filter

(cherry picked from commit af34992)
github-actions bot pushed a commit that referenced this pull request Jan 6, 2025
* Fix use of SSLContext with sniffing

* Fix lint

* Ignore enabled_cleanup_closed warning

It's not triggered for normal code.

* Remove warning filter

(cherry picked from commit af34992)
pquentin pushed a commit that referenced this pull request Jan 6, 2025
pquentin pushed a commit that referenced this pull request Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: cannot pickle 'SSLContext' object when more than one host is used in client configuration and SSL Workaround is enabled
2 participants