Skip to content

Commit

Permalink
Merge pull request #615 from amadev/release/0.28
Browse files Browse the repository at this point in the history
Fix discovery: check resources of api_version exist
  • Loading branch information
nolar committed Dec 15, 2020
2 parents a7c5e55 + 54bd133 commit 1e517d0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions kopf/clients/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ async def discover(
if context is None:
raise RuntimeError("API instance is not injected by the decorator.")

if resource.api_version not in context._discovered_resources:
name = resource.plural if subresource is None else f'{resource.plural}/{subresource}'

if not context._discovered_resources.get(resource.api_version, {}).get(name):
async with context._discovery_lock:
if resource.api_version not in context._discovered_resources:
context._discovered_resources[resource.api_version] = {}
Expand All @@ -39,7 +41,6 @@ async def discover(
else:
raise

name = resource.plural if subresource is None else f'{resource.plural}/{subresource}'
return context._discovered_resources[resource.api_version].get(name, None)


Expand Down

0 comments on commit 1e517d0

Please sign in to comment.