-
Notifications
You must be signed in to change notification settings - Fork 17
lightkube doesnot work with httpx 0.28.x #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi, what authentication method are you using? Can you post the corresponding configuration section (properly anonymized)? |
There seems to be actually a bug in httpx v0.8.0 that will be fixed in 0.28.1: encode/httpx#3442 |
I released v0.15.6 to temporary avoid httpx version 0.28.0. Fixing the deprecation will require first compatiblity of RESPX lundberg/respx#277 with the changes to 0.28 and also the release of httpx 0.28.1 encode/httpx#3445 |
|
|
I have a fresh install of lightkube (version 0.15.6) which brings in httpx 0.28.1 as dependency and I'm also having this issue. $ kubectl config current-context
k3d-test
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
k3d-test-agent-0 Ready <none> 7d22h v1.30.6+k3s1
k3d-test-server-0 Ready control-plane,master 7d22h v1.30.6+k3s1 from lightkube import Client
from lightkube.resources.core_v1 import Node
client = Client()
for node in client.list(Node):
print(node.metadata.name)
Traceback (most recent call last):
File "/Users/logileifsson/tmp/registrator/__pypackages__/3.11/lib/lightkube/core/generic_client.py", line 235, in raise_for_status
resp.raise_for_status()
File "/Users/logileifsson/tmp/registrator/__pypackages__/3.11/lib/httpx/_models.py", line 829, in raise_for_status
raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '401 Unauthorized' for url 'https://0.0.0.0:57271/api/v1/nodes'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/logileifsson/tmp/registrator/__pypackages__/3.11/lib/lightkube/core/generic_client.py", line 318, in list
cont, chunk = self.handle_response("list", resp, br)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/logileifsson/tmp/registrator/__pypackages__/3.11/lib/lightkube/core/generic_client.py", line 251, in handle_response
self.raise_for_status(resp)
File "/Users/logileifsson/tmp/registrator/__pypackages__/3.11/lib/lightkube/core/generic_client.py", line 237, in raise_for_status
raise transform_exception(e)
lightkube.core.exceptions.ApiError: Unauthorized client.config
SingleConfig(context_name='k3d-test', context=Context(cluster='k3d-test', user='admin@k3d-test', namespace=None), cluster=Cluster(server='https://0.0.0.0:57271', certificate_auth=None, certificate_auth_data='LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJlRENDQVIyZ0F3SUJBZ0lCQURBS0JnZ3Foa2pPUFFRREFqQWpNU0V3SHdZRFZRUUREQmhyTTNNdGMyVnkKZG1WeUxXTmhRREUzTXpNeU1qZ3hOVFV3SGhjTk1qUXhNakF6TVRJeE5UVTFXaGNOTXpReE1qQXhNVEl4TlRVMQpXakFqTVNFd0h3WURWUVFEREJock0zTXRjMlZ5ZG1WeUxXTmhRREUzTXpNeU1qZ3hOVFV3V1RBVEJnY3Foa2pPClBRSUJCZ2dxaGtqT1BRTUJCd05DQUFTQW9odmVFQUVCRUpuQjBoRFJXak9KN1gvVDZTWHhFSk4vV3hPS0Vac2YKd2wzRlI0bGFqM0RtL2JPZFM4ano0SkxmcnNyVDRBbll5bEF2bFBmRVNPSkdvMEl3UURBT0JnTlZIUThCQWY4RQpCQU1DQXFRd0R3WURWUjBUQVFIL0JBVXdBd0VCL3pBZEJnTlZIUTRFRmdRVWxqNk9pbTZUbUFFak95b28rWk1LClBCQWVIWUF3Q2dZSUtvWkl6ajBFQXdJRFNRQXdSZ0loQUxoVnZwVnNvdXBaZjdOb2N1RXF4S0JEenZwdCtwNVIKMU5QTjdwQmJnUWFhQWlFQXliQmVRMFNnem9iZ3V0VUwxaklHTjNiMVpNcDBySWtkK3ljTW1qWlFLeEE9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K', insecure=False), user=User(exec=None, username=None, password=None, token=None, auth_provider=None, client_cert=None, client_cert_data='LS0tLS1CRUdJTiBDRVJUSUZJQ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hOVFV3V1RBVEJnY3Foa2pPClBRSUJCZ2dxaGtqT1BRTUJCd05DQUFUOXFSR3lBNTZ5cE1ySytKU1BJSllld2Z4L0hRNldKdnNrZDVYUzhtbWgKVkszVFdyS0lVV2Qvb3pjYWZhNWdLRFhkaXVEWEM0OFBFQVRCVUtneFBXMFVvMEl3UURBT0JnTlZIUThCQWY4RQpCQU1DQXFRd0R3WURWUjBUQVFIL0JBVXdBd0VCL3pBZEJnTlZIUTRFRmdRVW5iZ1paYTkwdTIyT2FmZG1Xcm40CjNpbURSZTh3Q2dZSUtvWkl6ajBFQXdJRFNBQXdSUUlnQXdDUDJEZmYrallLZjltVmFBOXdLQ2hNZUR6NlpHbU8KUUlnbnQ2ZUo0MUVDSVFDSDhmbUkybjZNVlFSd3MzUk9SZTVJMWdKU0FEbTlQVVVhMWxmVVc5cUt6QT09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K', client_key=None, client_key_data='LS0tLS1CRUdJTiBFQyBQUklWQVRFIEtFWS0tLS0tCk1IY0NBUUVFSUM4dzR5SjlCU0hMdTIyeTlTbHhoOEhYZENFeUxGbHZiVkJMU2xacnl0VkFvQW9HQ0NxR1NNNDkKQXdFSG9VUURRZ0FFdHZWbXlLbWJuQjBKTFA2SUFuQkczNXFNOTR5Q0ttR3RkZlhzSldOdUU3TDE1OFFiV2NydgowSnIrdWJnek9wY0g0cWtpV1IveXFTb2hzMkFEMnBLTVhRPT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo='), fname=PosixPath('/Users/logileifsson/.kube/config')) |
And I can confirm that downgrading httpx to 0.27.2 fixes the issue |
Thanks for the details, this is going to be useful for the investigation. For now I just released |
I'm still experiencing this issue with lightkube 0.16.2 (and 0.16.1). I don't understand why though. With
But if I bump lightkube with httpx held constant, or bump httpx to >=0.28 (or bump both), I get this error:
So for some reason, the fix in 0.16.2 is not working for me |
@ca-scribner, have you seen this issue elastic/elasticsearch#117769 ? The error message and the python version matches the stack trace above. Maybe you need to fix your certificate? The default ssl context changed a bit from 0.27.x to 0.28.x: |
ty @gtsystem, I had not seen this and I think you're right. I'm naive about this stuff, but reading python/cpython#107361 reinforces your point What I think I'm seeing is that microk8s (the k8s I was using) does not generate rfc 5280 compliant certs (or at least, the certs it generates somehow disagrees with python/cpython#107361). I was using python 3.13 when hitting this, so that seems consistent. If I drop back to python 3.12, things work fine for me. So seems like the combination of microk8s's certs+python 3.13 leads to my issue |
for anyone interested, my repro steps were (sorry if there's a typo, wrote these from memory after the fact): lxc launch ubuntu:24.04 microk8s-1p31
lxc shell microk8s-1p31 then from inside the container
|
During restarts, the k8s services of type loadbalancer can get diferent IPs and the integration tests tries to communicate with older IPs. Add a step after deploying the bundle to add loadbalancer annotations to services of type loadbalancer so that IPs persist during restart of pods. Pin httpx version in tox.ini due to bug [1] in lightkube [1] gtsystem/lightkube#78 Change-Id: I013ec1c1e9dbac3ae86c57abcd9d87a3b99f6e82
Running lightkube get/list commands failed with Unauthorized error.
Ran a sample from documentation:
Error message:
Tried the same by downgrading httpx package to 0.27.x and it worked.
There are ssl related changes to httpx 0.28.0 which might cause this issue, see release notes
https://github.com/encode/httpx/releases/tag/0.28.0
The text was updated successfully, but these errors were encountered: