Skip to content

Commit

Permalink
Fix ResourceTimeout
Browse files Browse the repository at this point in the history
Signed-off-by: Alina Buzachis <abuzachis@redhat.com>
  • Loading branch information
alinabuzachis committed Jan 20, 2022
1 parent 2a926e6 commit 919b8d0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions plugins/module_utils/k8s/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,19 @@ def perform_action(svc, definition: Dict, params: Dict) -> Dict:
namespace = definition["metadata"].get("namespace")
label_selectors = params.get("label_selectors")
state = params.get("state", None)
kind = definition.get("kind")
api_version = definition.get("apiVersion")
module = svc.module
result = {}

resource = svc.find_resource(definition["kind"], definition["apiVersion"])
try:
if kind and kind.endswith("List"):
resource = svc.find_resource(kind, api_version, fail=False)
else:
resource = svc.find_resource(kind, api_version, fail=True)
except CoreException as e:
module.fail_json(msg=to_native(e))

existing = svc.retrieve(resource, definition)

if state == "absent":
Expand All @@ -94,7 +104,7 @@ def perform_action(svc, definition: Dict, params: Dict) -> Dict:
result["msg"] = (
"resource 'kind={kind},name={name},namespace={namespace}' "
"filtered by label_selectors.".format(
kind=definition["kind"], name=origin_name, namespace=namespace,
kind=kind, name=origin_name, namespace=namespace,
)
)
return result
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/k8s/waiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def wait(
try:
response = self.client.get(self.resource, **params)
except NotFoundError:
pass
response = None
if self.predicate(response):
break
if response:
Expand Down

0 comments on commit 919b8d0

Please sign in to comment.