Skip to content
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

lightkube Unauthorized errors when getting k8s node information (hugepages) #447

Open
gruyaume opened this issue Dec 16, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@gruyaume
Copy link
Collaborator

gruyaume commented Dec 16, 2024

Bug Description

I am getting many lightkube error in the log when following the accelerated networking tutorial. The issue eventually resolves on its own but we probably don't want all the stack traces in the log, we could error out more gracefully and retry on the next hook.

To Reproduce

  • Follow accelerated networking tutorial

Environment

  • Juju 3.5.5
  • UPF: 1.6/edge (678)

Relevant log output

unit-upf-0: 21:18:32 ERROR unit.upf/0.juju-log Uncaught exception while in charm code:
Traceback (most recent call last):
  File "/var/lib/juju/agents/unit-upf-0/charm/venv/lightkube/core/generic_client.py", line 235, in raise_for_status
    resp.raise_for_status()
  File "/var/lib/juju/agents/unit-upf-0/charm/venv/httpx/_models.py", line 763, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '401 Unauthorized' for url 'https://10.152.183.1/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 "/var/lib/juju/agents/unit-upf-0/charm/./src/charm.py", line 1254, in <module>
    main(UPFOperatorCharm)
  File "/var/lib/juju/agents/unit-upf-0/charm/venv/ops/__init__.py", line 343, in __call__
    return _main.main(charm_class=charm_class, use_juju_for_storage=use_juju_for_storage)
  File "/var/lib/juju/agents/unit-upf-0/charm/venv/ops/_main.py", line 543, in main
    manager.run()
  File "/var/lib/juju/agents/unit-upf-0/charm/venv/ops/_main.py", line 529, in run
    self._emit()
  File "/var/lib/juju/agents/unit-upf-0/charm/venv/ops/_main.py", line 520, in _emit
    ops.charm._evaluate_status(self.charm)
  File "/var/lib/juju/agents/unit-upf-0/charm/venv/ops/charm.py", line 1396, in _evaluate_status
    charm.on.collect_unit_status.emit()
  File "/var/lib/juju/agents/unit-upf-0/charm/venv/ops/framework.py", line 347, in emit
    framework._emit(event)
  File "/var/lib/juju/agents/unit-upf-0/charm/venv/ops/framework.py", line 857, in _emit
    self._reemit(event_path)
  File "/var/lib/juju/agents/unit-upf-0/charm/venv/ops/framework.py", line 947, in _reemit
    custom_handler(event)
  File "/var/lib/juju/agents/unit-upf-0/charm/./src/charm.py", line 464, in _on_collect_unit_status
    if not self._hugepages_are_available():
  File "/var/lib/juju/agents/unit-upf-0/charm/./src/charm.py", line 1120, in _hugepages_are_available
    return all(node.status.allocatable.get("hugepages-1Gi", "0") >= "2Gi" for node in nodes)  # type: ignore
  File "/var/lib/juju/agents/unit-upf-0/charm/./src/charm.py", line 1120, in <genexpr>
    return all(node.status.allocatable.get("hugepages-1Gi", "0") >= "2Gi" for node in nodes)  # type: ignore
  File "/var/lib/juju/agents/unit-upf-0/charm/venv/lightkube/core/generic_client.py", line 318, in list
    cont, chunk = self.handle_response("list", resp, br)
  File "/var/lib/juju/agents/unit-upf-0/charm/venv/lightkube/core/generic_client.py", line 251, in handle_response
    self.raise_for_status(resp)
  File "/var/lib/juju/agents/unit-upf-0/charm/venv/lightkube/core/generic_client.py", line 237, in raise_for_status
    raise transform_exception(e)
lightkube.core.exceptions.ApiError: Unauthorized
unit-upf-0: 21:18:33 ERROR juju.worker.uniter.operation hook "stop" (via hook dispatching script: dispatch) failed: exit status 1

Additional context

A similar issue was recently observed and addressed relating to multus:

@gruyaume gruyaume added the bug Something isn't working label Dec 16, 2024
@Gmerold Gmerold self-assigned this Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants