Merge pull request #11792 from VannTen/flake/race_sa_creation

Fix flakey test + cleanup in testcases/030-checknetwork
This commit is contained in:
Kubernetes Prow Robot
2024-12-17 03:26:52 +01:00
committed by GitHub

View File

@@ -79,60 +79,47 @@
command: command:
cmd: "{{ bin_dir }}/kubectl apply -f -" cmd: "{{ bin_dir }}/kubectl apply -f -"
stdin: | stdin: |
apiVersion: v1 apiVersion: apps/v1
kind: Pod kind: Deployment
metadata: metadata:
name: {{ item }} name: agnhost
namespace: test
spec: spec:
containers: replicas: 2
- name: agnhost selector:
image: {{ test_image_repo }}:{{ test_image_tag }} matchLabels:
command: ['/agnhost', 'netexec', '--http-port=8080'] app: agnhost
securityContext: template:
allowPrivilegeEscalation: false metadata:
capabilities: labels:
drop: ['ALL'] app: agnhost
runAsUser: 1000 spec:
runAsNonRoot: true containers:
seccompProfile: - name: agnhost
type: RuntimeDefault image: {{ test_image_repo }}:{{ test_image_tag }}
command: ['/agnhost', 'netexec', '--http-port=8080']
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ['ALL']
runAsUser: 1000
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
changed_when: false changed_when: false
loop:
- agnhost1
- agnhost2
- import_role: # noqa name[missing] - import_role: # noqa name[missing]
name: cluster-dump name: cluster-dump
- name: Check that all pods are running and ready - name: Check that all pods are running and ready
command: "{{ bin_dir }}/kubectl get pods --namespace test --no-headers -o yaml" block:
changed_when: false - name: Check Deployment is ready
register: run_pods_log command: "{{ bin_dir }}/kubectl rollout status deploy --namespace test agnhost --timeout=180"
until: changed_when: false
# Check that all pods are running rescue:
- '(run_pods_log.stdout | from_yaml)["items"] | map(attribute = "status.phase") | unique | list == ["Running"]' - name: Get pod names
# Check that all pods are ready command: "{{ bin_dir }}/kubectl get pods -n test -o json"
- '(run_pods_log.stdout | from_yaml)["items"] | map(attribute = "status.containerStatuses") | map("map", attribute = "ready") | map("min") | min' changed_when: false
retries: 18 register: pods
delay: 10
failed_when: false
- name: Get pod names
command: "{{ bin_dir }}/kubectl get pods -n test -o json"
changed_when: false
register: pods
- debug: # noqa name[missing]
msg: "{{ pods.stdout.split('\n') }}"
failed_when: not run_pods_log is success
- name: Get hostnet pods
command: "{{ bin_dir }}/kubectl get pods -n test -o
jsonpath='{range .items[?(.spec.hostNetwork)]}{.metadata.name} {.status.podIP} {.status.containerStatuses} {end}'"
changed_when: false
register: hostnet_pods
ignore_errors: true # noqa ignore-errors
- name: Get running pods - name: Get running pods
command: "{{ bin_dir }}/kubectl get pods -n test -o command: "{{ bin_dir }}/kubectl get pods -n test -o
@@ -153,9 +140,6 @@
kube_pods_subnet: 10.233.64.0/18 kube_pods_subnet: 10.233.64.0/18
pod_names: "{{ (pods.stdout | from_json)['items'] | map(attribute='metadata.name') | list }}" pod_names: "{{ (pods.stdout | from_json)['items'] | map(attribute='metadata.name') | list }}"
pod_ips: "{{ (pods.stdout | from_json)['items'] | selectattr('status.podIP', 'defined') | map(attribute='status.podIP') | list }}" pod_ips: "{{ (pods.stdout | from_json)['items'] | selectattr('status.podIP', 'defined') | map(attribute='status.podIP') | list }}"
pods_hostnet: |
{% set list = hostnet_pods.stdout.split(" ") %}
{{ list }}
pods_running: | pods_running: |
{% set list = running_pods.stdout.split(" ") %} {% set list = running_pods.stdout.split(" ") %}
{{ list }} {{ list }}
@@ -164,24 +148,11 @@
assert: assert:
that: item | ansible.utils.ipaddr(kube_pods_subnet) that: item | ansible.utils.ipaddr(kube_pods_subnet)
when: when:
- not item in pods_hostnet
- item in pods_running - item in pods_running
with_items: "{{ pod_ips }}" with_items: "{{ pod_ips }}"
- name: Curl between pods is working - name: Curl between pods is working
command: "{{ bin_dir }}/kubectl -n test exec {{ item[0] }} -- curl {{ item[1] }}:8080" command: "{{ bin_dir }}/kubectl -n test exec {{ item[0] }} -- curl {{ item[1] }}:8080"
when:
- not item[0] in pods_hostnet
- not item[1] in pods_hostnet
with_nested:
- "{{ pod_names }}"
- "{{ pod_ips }}"
- name: Curl between hostnet pods is working
command: "{{ bin_dir }}/kubectl -n test exec {{ item[0] }} -- curl {{ item[1] }}:8080"
when:
- item[0] in pods_hostnet
- item[1] in pods_hostnet
with_nested: with_nested:
- "{{ pod_names }}" - "{{ pod_names }}"
- "{{ pod_ips }}" - "{{ pod_ips }}"