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

fix(app): use group in dynamic k8s client #151

Merged
merged 4 commits into from
Mar 30, 2022
Merged

Conversation

olevski
Copy link
Member

@olevski olevski commented Mar 30, 2022

Some recent issues were possibly related to this.

It was never confirmed whether this would have helped or not. But it is still a good idea to use the API group if available to avoid confusion and problems in the future.

I checked the python k8s client and when the group is not passed in to the resource.get function it defaults to None

@olevski olevski requested review from ableuler and a team as code owners March 30, 2022 14:34
controller/utils.py Outdated Show resolved Hide resolved
controller/utils.py Show resolved Hide resolved
@olevski
Copy link
Member Author

olevski commented Mar 30, 2022

Just for reference this is the error that prompted this PR:

{"message": "Handler 'update_status' failed with an exception. Will ignore.", "exc_info": "Traceback (most recent call last):\n  File \"/app/controller/utils.py\", line 199, in get_api\n    return api_cache[(api_version, kind)]\n  File \"/us
r/local/lib/python3.8/site-packages/expiringdict/__init__.py\", line 77, in __getitem__\n    item = OrderedDict.__getitem__(self, key)\nKeyError: ('v1alpha1', 'JupyterServer')\n\nDuring handling of the above exception, another exception occu
rred:\n\nTraceback (most recent call last):\n  File \"/usr/local/lib/python3.8/site-packages/kopf/_core/actions/execution.py\", line 283, in execute_handler_once\n    result = await invoke_handler(\n  File \"/usr/local/lib/python3.8/site-pac
kages/kopf/_core/actions/execution.py\", line 378, in invoke_handler\n    result = await invocation.invoke(\n  File \"/usr/local/lib/python3.8/site-packages/kopf/_core/actions/invocation.py\", line 140, in invoke\n    await asyncio.shield(fu
ture)  # slightly expensive: creates tasks\n  File \"/usr/local/lib/python3.8/concurrent/futures/thread.py\", line 57, in run\n    result = self.fn(*self.args, **self.kwargs)\n  File \"/app/controller/server_controller.py\", line 282, in upd
ate_status\n    custom_resource_api = get_api(config.api_version, config.custom_resource_name)\n  File \"/app/controller/utils.py\", line 202, in get_api\n    api_cache[(api_version, kind)] = client.resources.get(\n  File \"/usr/local/lib/py
thon3.8/site-packages/kubernetes/dynamic/discovery.py\", line 211, in get\n    raise ResourceNotFoundError('No matches found for {}'.format(kwargs))\nkubernetes.dynamic.exceptions.ResourceNotFoundError: No matches found for {'api_version': '
v1alpha1', 'kind': 'JupyterServer'}", "timestamp": "2022-03-30T13:42:18.225715+00:00", "object": {"apiVersion": "v1", "kind": "PersistentVolumeClaim", "name": "tasko-2eol-test-2dpinned-2dimage-2d-4b1037c7", "uid": "0b5b36fa-57a6-480d-88c0-f9
c2b2b3a521", "namespace": "ci-renku-2534"}, "severity": "error"}

@olevski olevski requested a review from ableuler March 30, 2022 15:31
Copy link
Contributor

@ableuler ableuler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely an improvement, even if it should not fix the problem we've seen. 👍

@olevski olevski merged commit 31b5de1 into main Mar 30, 2022
@olevski olevski deleted the fix-resource-caching branch March 30, 2022 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants