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

ResourceNotUniqueError returned when really it's ResourceNotFound #310

Closed
willthames opened this issue Jun 24, 2019 · 7 comments
Closed
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@willthames
Copy link
Contributor

willthames commented Jun 24, 2019

Short test case for openshift

docker run -d -p 8443:8443 --name openshift-origin  openshift/origin:v3.9 start master --listen https://0.0.0.0:8443
docker exec openshift-origin cat /var/lib/origin/openshift.local.config/master/admin.kubeconfig | sed 's/172\.17\.0\.2/127.0.0.1/'g  > ~/.kube/oo.config
from kubernetes import config
from openshift.dynamic import DynamicClient
import os
import yaml

k8s_client = config.new_client_from_config(config_file=os.path.expanduser("~/.kube/oo.config"))
dyn_client = DynamicClient(k8s_client)

service = dyn_client.resources.get(api_version='v1', short_names=["doesnotexist"])
data = yaml.safe_load(open("test.yaml"))
resp = dyn_client.apply(service, body=data, namespace="test")
Traceback (most recent call last):
  File "namespace.py", line 9, in <module>
    service = dyn_client.resources.get(api_version='v1', short_names=["doesnotexist"])
  File "/Users/will/venv/openshift-0.9.0/lib/python3.7/site-packages/openshift/dynamic/client.py", line 753, in get
    results = self.search(**kwargs)
  File "/Users/will/venv/openshift-0.9.0/lib/python3.7/site-packages/openshift/dynamic/client.py", line 794, in search
    results = self.__search(self.__build_search(**kwargs), self.__resources, [])
  File "/Users/will/venv/openshift-0.9.0/lib/python3.7/site-packages/openshift/dynamic/client.py", line 836, in __search
    matches.extend(self.__search([key] + parts[1:], resources, reqParams))
  File "/Users/will/venv/openshift-0.9.0/lib/python3.7/site-packages/openshift/dynamic/client.py", line 822, in __search
    return self.__search(parts[1:], resourcePart, reqParams + [part] )
  File "/Users/will/venv/openshift-0.9.0/lib/python3.7/site-packages/openshift/dynamic/client.py", line 836, in __search
    matches.extend(self.__search([key] + parts[1:], resources, reqParams))
  File "/Users/will/venv/openshift-0.9.0/lib/python3.7/site-packages/openshift/dynamic/client.py", line 822, in __search
    return self.__search(parts[1:], resourcePart, reqParams + [part] )
  File "/Users/will/venv/openshift-0.9.0/lib/python3.7/site-packages/openshift/dynamic/client.py", line 818, in __search
    return self.__search(parts[1:], resourcePart.resources, reqParams)
  File "/Users/will/venv/openshift-0.9.0/lib/python3.7/site-packages/openshift/dynamic/client.py", line 836, in __search
    matches.extend(self.__search([key] + parts[1:], resources, reqParams))
  File "/Users/will/venv/openshift-0.9.0/lib/python3.7/site-packages/openshift/dynamic/client.py", line 827, in __search
    if getattr(_resource, term) == value:
  File "/Users/will/venv/openshift-0.9.0/lib/python3.7/site-packages/openshift/dynamic/client.py", line 524, in __getattr__
    if self.base_resource():
  File "/Users/will/venv/openshift-0.9.0/lib/python3.7/site-packages/openshift/dynamic/client.py", line 421, in base_resource
    self.__base_resource = self.client.resources.get(group=self.group, api_version=self.api_version, kind=self.base_kind)
  File "/Users/will/venv/openshift-0.9.0/lib/python3.7/site-packages/openshift/dynamic/client.py", line 767, in get
    raise ResourceNotUniqueError('Multiple matches found for {}: {}'.format(kwargs, results))
openshift.dynamic.exceptions.ResourceNotUniqueError: Multiple matches found for {'group': '', 'api_version': 'v1', 'kind': 'Template'}: [<Resource(v1/processedtemplates)>, <Resource(v1/templates)>]
@willthames
Copy link
Contributor Author

Compared to native kubernetes (here, docker-for-desktop)

Traceback (most recent call last):
  File "namespace.py", line 10, in <module>
    service = dyn_client.resources.get(api_version='v1', short_names=["doesnotexist"])
  File "/Users/will/venv/openshift-0.9.0/lib/python3.7/site-packages/openshift/dynamic/client.py", line 765, in get
    raise ResourceNotFoundError('No matches found for {}'.format(kwargs))
openshift.dynamic.exceptions.ResourceNotFoundError: No matches found for {'api_version': 'v1', 'short_names': ['doesnotexist]}

@geauxvirtual
Copy link

Similar to what is described here, in #270 and here ansible/ansible#55221, using sts in the k8s module in Ansible worked with kubernetes 7.0.1 and openshift 0.7.2 modules, but fails in kubernetes 8.0.1 and openshift 0.8.8 modules along with kubernetes 9.x and openshift 0.9.0 modules.

Changing sts to StatefulSet allows the k8s module to function under kubernetes 9.x and openshift 0.9.0 modules.

@fabianvf
Copy link
Member

fabianvf commented Jul 9, 2019

wow that is bizarre, why are we returning templates in that search?

@openshift-bot
Copy link

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci-robot openshift-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 12, 2020
@openshift-bot
Copy link

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

@openshift-ci-robot openshift-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Oct 13, 2020
@openshift-bot
Copy link

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

@openshift-ci-robot
Copy link

@openshift-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

5 participants