Don't wait on *List resources for info module (#253)

Don't wait on *List resources for info module

SUMMARY

We can't use the same wait logic on *List resources because they lack
the same metadata that other resources have. We should ensure that we
are waiting on the items in the list, but not the list itself. Waiting
on the list itself results in unexpected behavior.
This fixes the waiting logic when waiting on a list to wait until the
list being queried contains one or more items, or the wait timeout has
been reached. Each item in the list can then be waited on with the usual
wait logic.

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: None <None>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: None <None>
This commit is contained in:
Mike Graves
2021-11-08 13:12:25 -05:00
committed by GitHub
parent 91b80b1d1d
commit bf26f5a3be
4 changed files with 61 additions and 15 deletions

View File

@@ -199,6 +199,38 @@
that:
- "{{ lookup('pipe', 'date +%s') }} - {{ start }} > 30"
- name: Create simple pod
k8s:
definition:
apiVersion: v1
kind: Pod
metadata:
name: wait-pod-1
namespace: "{{ wait_namespace }}"
spec:
containers:
- image: busybox
name: busybox
command:
- /bin/sh
- -c
- while true; do sleep 5; done
- name: Wait for multiple non-existent pods to be created
k8s_info:
kind: Pod
namespace: "{{ wait_namespace }}"
label_selectors:
- thislabel=doesnotexist
wait: yes
wait_timeout: 10
register: result
- name: Assert no pods were found
assert:
that:
- not result.resources
vars:
k8s_pod_name: pod-info-1