Skip to content

Commit

Permalink
Behavior has changed with query/lookup which I believe is due to: ans…
Browse files Browse the repository at this point in the history
…ible-collections/kubernetes.core#147

Get these tests to work again.

part of: kiali/kiali#4417
  • Loading branch information
jmazzitelli committed Oct 8, 2021
1 parent 290f3b0 commit ea3e6e6
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 65 deletions.
7 changes: 3 additions & 4 deletions molecule/accessible-namespaces-test/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,11 @@
that:
- kiali_configmap.api.namespaces.label_selector == "kiali.io/member-of={{ istio.control_plane_namespace }}"

# TODO kubernetes.core.k8s behaves oddly - query doesn't return a list, but should; lookup returns a list but shouldn't.
# For now, just use lookup since it returns the list which is what we want
- name: Make sure the new label exists, but didn't overwrite any existing labels
vars:
namespacesWithCustomLabel: "{{ lookup('kubernetes.core.k8s', kind='Namespace', label_selector='customLabel=test') }}"
namespacesWithKialiLabel: "{{ lookup('kubernetes.core.k8s', kind='Namespace', label_selector=kiali_configmap.api.namespaces.label_selector) }}"
# Use query - it is the only way to ensure a list is returned; for some reason, lookup/wantList=true is not working
namespacesWithCustomLabel: "{{ query('kubernetes.core.k8s', kind='Namespace', label_selector='customLabel=test') }}"
namespacesWithKialiLabel: "{{ query('kubernetes.core.k8s', kind='Namespace', label_selector=kiali_configmap.api.namespaces.label_selector) }}"
assert:
that:
- namespacesWithCustomLabel | length == 1
Expand Down
2 changes: 1 addition & 1 deletion molecule/common/purge-prometheus-data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace: "{{ k8s_item.metadata.namespace }}"
name: "{{ k8s_item.metadata.name }}"
with_items:
- "{{ lookup('kubernetes.core.k8s', namespace=istio.control_plane_namespace, kind='Pod', label_selector='app=prometheus', api_version='v1') }}" # TODO this assumes faulty behavior - may need to change in the future. See: https://github.com/ansible-collections/kubernetes.core/issues/147
- "{{ query('kubernetes.core.k8s', namespace=istio.control_plane_namespace, kind='Pod', label_selector='app=prometheus', api_version='v1') }}"
loop_control:
loop_var: k8s_item

Expand Down
Loading

0 comments on commit ea3e6e6

Please sign in to comment.