Honor wait_timeout in k8s_info for missing resource (#360)

* Honor wait in k8s_info for missing resource

The wait logic in the k8s_info module immediately returns when no
resources are found, regardless whether a wait_timeout has been
specified. This expands the logic to wait when a name has been provided.
The case this is specifically meant to address is when querying for a
resource that is indirectly created by another resource, for example, a
pod created by a deployment or an operator.

The existing logic in every other case should remain as it was before.
This means if a query might return more than one resource--all pods with
some label, for example--the module will return immediately if no pods
are found, even if a wait_timeout has been provided.

* Add changelog fragment
This commit is contained in:
Mike Graves
2021-02-16 12:19:22 -05:00
committed by GitHub
parent 80b914021f
commit 9f7b6fb3ff
3 changed files with 68 additions and 21 deletions

View File

@@ -182,6 +182,24 @@
- not dne_api.resources
- not dne_api.api_found
- name: Start timer
set_fact:
start: "{{ lookup('pipe', 'date +%s') }}"
- name: Wait for non-existent pod to be created
k8s_info:
kind: Pod
name: does-not-exist
namespace: "{{ wait_namespace }}"
wait: yes
wait_timeout: 45
register: result
- name: Check that module waited
assert:
that:
- "{{ lookup('pipe', 'date +%s') }} - {{ start }} > 30"
always:
- name: Remove namespace
k8s: