From 0611a40c4ab7b053afb54e860759378cc3c96d9e Mon Sep 17 00:00:00 2001 From: eaglegai Date: Mon, 24 Jun 2024 21:06:27 +0800 Subject: [PATCH 1/2] fix: Add get_connection_with_tls_context() for requests 2.32.2+ get_connection() is deprecated in requests 2.32.2+ so this will allow for the LXDSocketAdapter to avoid using a deprecated api. Fixed:https://github.com/canonical/cloud-init/issues/5434 Signed-off-by: eaglegai --- cloudinit/sources/DataSourceLXD.py | 5 +++++ tools/.github-cla-signers | 1 + 2 files changed, 6 insertions(+) diff --git a/cloudinit/sources/DataSourceLXD.py b/cloudinit/sources/DataSourceLXD.py index 9d7d7a1ad10..34e1db34190 100644 --- a/cloudinit/sources/DataSourceLXD.py +++ b/cloudinit/sources/DataSourceLXD.py @@ -132,6 +132,11 @@ class LXDSocketAdapter(HTTPAdapter): def get_connection(self, url, proxies=None): return SocketConnectionPool(LXD_SOCKET_PATH) + # Fix for requests 2.32.2+: + # https://github.com/psf/requests/pull/6710 + def get_connection_with_tls_context(self, request, verify, proxies=None, cert=None): + return self.get_connection(request.url, proxies) + def _raw_instance_data_to_dict(metadata_type: str, metadata_value) -> dict: """Convert raw instance data from str, bytes, YAML to dict diff --git a/tools/.github-cla-signers b/tools/.github-cla-signers index cafe0353bff..2b122f452a2 100644 --- a/tools/.github-cla-signers +++ b/tools/.github-cla-signers @@ -54,6 +54,7 @@ dermotbradley dhalturin dhensby Dorthu +eaglegai eandersson eb3095 ederst From e540e324814f322992f5f47e17def5dd7551b7c0 Mon Sep 17 00:00:00 2001 From: Chad Smith Date: Wed, 26 Jun 2024 11:28:24 -0600 Subject: [PATCH 2/2] wip --- cloudinit/sources/DataSourceLXD.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cloudinit/sources/DataSourceLXD.py b/cloudinit/sources/DataSourceLXD.py index 34e1db34190..a85853ec44a 100644 --- a/cloudinit/sources/DataSourceLXD.py +++ b/cloudinit/sources/DataSourceLXD.py @@ -134,7 +134,9 @@ def get_connection(self, url, proxies=None): # Fix for requests 2.32.2+: # https://github.com/psf/requests/pull/6710 - def get_connection_with_tls_context(self, request, verify, proxies=None, cert=None): + def get_connection_with_tls_context( + self, request, verify, proxies=None, cert=None + ): return self.get_connection(request.url, proxies)