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

Use resource prefix when apiVersion is v1 #371

Conversation

Akasurde
Copy link
Member

@Akasurde Akasurde commented Feb 8, 2022

SUMMARY

When getting a resource from the core api group, the prefix was not
passed, leading the lookup to happen in all api groups. This broad
search is not really necessary and leads to problems in some corner
cases, for example, when an api is deleted after the api group list is
cached.

This fix uses the 'api' prefix when the apiVersion is 'v1', as this is
almost certainly what the user wants. As a fallback, to retain backwards
compatibility, the old behavior is used if the first lookup failed to
find a resource. Given that the module defaults to 'v1' for the
apiVersion, there are likely many cases where a resource, such as
StatefulSet, is used while failing to provide an apiVersion. While
technically incorrect, this has worked in most cases, so we probably
shouldn't break this behavior.

Fixes #351

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

changelogs/fragments/364-use-resource-prefix.yaml
plugins/module_utils/common.py

When getting a resource from the core api group, the prefix was not
passed, leading the lookup to happen in all api groups. This broad
search is not really necessary and leads to problems in some corner
cases, for example, when an api is deleted after the api group list is
cached.

This fix uses the 'api' prefix when the apiVersion is 'v1', as this is
almost certainly what the user wants. As a fallback, to retain backwards
compatibility, the old behavior is used if the first lookup failed to
find a resource. Given that the module defaults to 'v1' for the
apiVersion, there are likely many cases where a resource, such as
StatefulSet, is used while failing to provide an apiVersion. While
technically incorrect, this has worked in most cases, so we probably
shouldn't break this behavior.
@Akasurde Akasurde changed the title Add changelog fragment Use resource prefix when apiVersion is v1 Feb 8, 2022
@softwarefactory-project-zuul
Copy link

Build succeeded.

@gravesm gravesm added the mergeit label Feb 9, 2022
@softwarefactory-project-zuul
Copy link

Build failed (gate pipeline). For information on how to proceed, see
http://docs.openstack.org/infra/manual/developers.html#automated-testing

@gravesm
Copy link
Member

gravesm commented Feb 9, 2022

recheck

@softwarefactory-project-zuul
Copy link

Build succeeded.

@softwarefactory-project-zuul
Copy link

Build failed (gate pipeline). For information on how to proceed, see
http://docs.openstack.org/infra/manual/developers.html#automated-testing

@gravesm
Copy link
Member

gravesm commented Feb 9, 2022

regate

@softwarefactory-project-zuul
Copy link

Build failed (gate pipeline). For information on how to proceed, see
http://docs.openstack.org/infra/manual/developers.html#automated-testing

@Akasurde
Copy link
Member Author

regate

@softwarefactory-project-zuul
Copy link

Build succeeded (gate pipeline).

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit 791175d into ansible-collections:main Feb 10, 2022
@Akasurde Akasurde deleted the fix-resource-request branch February 10, 2022 02:49
@Akasurde
Copy link
Member Author

@gravesm Thanks for the contribution.

gravesm added a commit to gravesm/kubernetes.core that referenced this pull request Jun 8, 2022
This ports 791175d to the refactored code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed to find exact match for v1.Namespace by [kind, name, singularName, shortNames]
2 participants