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

Treat listable but non-watchable resources as non-watchable #871

Merged
merged 1 commit into from
Nov 28, 2021

Conversation

nolar
Copy link
Owner

@nolar nolar commented Nov 28, 2021

Accidentally detected when trying to reproduce an unrelated issue #870:

It fails on pods & nodes of metrics.k8s.io, on "componentstatuses" of "v1", and some other resources, which are now listable but non-watchable:

[2021-11-28 23:13:18,250] kopf._core.reactor.o [ERROR   ] Watcher for componentstatuses.v1@none has failed: ('watch is not supported on resources of kind "componentstatuses"', {'kind': 'Status', 'apiVersion': 'v1', 'metadata': {}, 'status': 'Failure', 'message': 'watch is not supported on resources of kind "componentstatuses"', 'reason': 'MethodNotAllowed', 'details': {'kind': 'componentstatuses'}, 'code': 405})
Traceback (most recent call last):
  File "/Users/nolar/src/kopf/kopf/_cogs/clients/errors.py", line 148, in check_response
    response.raise_for_status()
  File "/Users/nolar/.pyenv/versions/kopf397/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1000, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 405, message='Method Not Allowed', url=URL('https://127.0.0.1:61610/api/v1/componentstatuses?watch=true')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/nolar/src/kopf/kopf/_cogs/aiokits/aiotasks.py", line 107, in guard
    await coro
  File "/Users/nolar/src/kopf/kopf/_core/reactor/queueing.py", line 175, in watcher
    async for raw_event in stream:
  File "/Users/nolar/src/kopf/kopf/_cogs/clients/watching.py", line 82, in infinite_watch
    async for raw_event in stream:
  File "/Users/nolar/src/kopf/kopf/_cogs/clients/watching.py", line 186, in continuous_watch
    async for raw_input in stream:
  File "/Users/nolar/src/kopf/kopf/_cogs/clients/watching.py", line 251, in watch_objs
    async for raw_input in api.stream(
  File "/Users/nolar/src/kopf/kopf/_cogs/clients/api.py", line 200, in stream
    response = await request(
  File "/Users/nolar/src/kopf/kopf/_cogs/clients/auth.py", line 45, in wrapper
    return await fn(*args, **kwargs, context=context)
  File "/Users/nolar/src/kopf/kopf/_cogs/clients/api.py", line 85, in request
    await errors.check_response(response)  # but do not parse it!
  File "/Users/nolar/src/kopf/kopf/_cogs/clients/errors.py", line 150, in check_response
    raise cls(payload, status=response.status) from e
kopf._cogs.clients.errors.APIClientError: ('watch is not supported on resources of kind "componentstatuses"', {'kind': 'Status', 'apiVersion': 'v1', 'metadata': {}, 'status': 'Failure', 'message': 'watch is not supported on resources of kind "componentstatuses"', 'reason': 'MethodNotAllowed', 'details': {'kind': 'componentstatuses'}, 'code': 405})
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.4", GitCommit:"e87da0bd6e03ec3fea7933c4b5263d151aafd07c", GitTreeState:"clean", BuildDate:"2021-02-18T16:12:00Z", GoVersion:"go1.15.8", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.3+k3s1", GitCommit:"61a2aab25eeb97c26fa3f2b177e4355a7654c991", GitTreeState:"clean", BuildDate:"2021-11-04T00:24:35Z", GoVersion:"go1.16.8", Compiler:"gc", Platform:"linux/amd64"}
$ kubectl get --raw /api/v1/ | jq '.resources[] | select(.name=="componentstatuses")'
{
  "name": "componentstatuses",
  "singularName": "",
  "namespaced": false,
  "kind": "ComponentStatus",
  "verbs": [
    "get",
    "list"
  ],
  "shortNames": [
    "cs"
  ]
}

The same behaviour can be observed at least down to Kubernetes 1.17.

It is not clear how and why did it work before, especially when this feature (the cluster observation and monitoring of "everything") was added.

@nolar nolar added the bug Something isn't working label Nov 28, 2021
@nolar nolar changed the title Treat listable but non-watchable resource as non-watchable Treat listable but non-watchable resources as non-watchable Nov 28, 2021
Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
@nolar nolar force-pushed the proper-nonwatchable-resource-detection branch from 7f7c034 to 8f5bfce Compare November 28, 2021 22:37
@nolar nolar enabled auto-merge November 28, 2021 22:37
@nolar nolar merged commit a9aa4ed into main Nov 28, 2021
@nolar nolar deleted the proper-nonwatchable-resource-detection branch November 28, 2021 22:44
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

Successfully merging this pull request may close these issues.

None yet

1 participant