Skip to content
Snippets Groups Projects
Unverified Commit 930df78d authored by Max Gautier's avatar Max Gautier
Browse files

CI: Use deployment instead of Pod for agnhost

This is a followup to 2ba28a33 (Revert "Wait for available API token in
a new namespace (#7045)", 2024-10-25).

While checking for the serviceaccount token is not effective, there is
still a race when creating a Pod directly, because the ServiceAccount
itself might not be created yet.
More details at https://github.com/kubernetes/kubernetes/issues/66689.

This cause very frequent flakes in our CI with spurious failures.

Use a Deployment instead ; it will takes cares of creating the Pods and
retrying ; it also let us use kubectl rollout status instead of manually
checking for the pods.
parent 74aee123
No related branches found
No related tags found
No related merge requests found
...@@ -79,11 +79,19 @@ ...@@ -79,11 +79,19 @@
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:
replicas: 2
selector:
matchLabels:
app: agnhost
template:
metadata:
labels:
app: agnhost
spec: spec:
containers: containers:
- name: agnhost - name: agnhost
...@@ -98,35 +106,21 @@ ...@@ -98,35 +106,21 @@
seccompProfile: seccompProfile:
type: RuntimeDefault 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:
- name: Check Deployment is ready
command: "{{ bin_dir }}/kubectl rollout status deploy --namespace test agnhost --timeout=180"
changed_when: false changed_when: false
register: run_pods_log rescue:
until:
# Check that all pods are running
- '(run_pods_log.stdout | from_yaml)["items"] | map(attribute = "status.phase") | unique | list == ["Running"]'
# Check that all pods are ready
- '(run_pods_log.stdout | from_yaml)["items"] | map(attribute = "status.containerStatuses") | map("map", attribute = "ready") | map("min") | min'
retries: 18
delay: 10
failed_when: false
- name: Get pod names - name: Get pod names
command: "{{ bin_dir }}/kubectl get pods -n test -o json" command: "{{ bin_dir }}/kubectl get pods -n test -o json"
changed_when: false changed_when: false
register: pods register: pods
- debug: # noqa name[missing]
msg: "{{ pods.stdout.split('\n') }}"
failed_when: not run_pods_log is success
- name: Get hostnet pods - name: Get hostnet pods
command: "{{ bin_dir }}/kubectl get pods -n test -o command: "{{ bin_dir }}/kubectl get pods -n test -o
jsonpath='{range .items[?(.spec.hostNetwork)]}{.metadata.name} {.status.podIP} {.status.containerStatuses} {end}'" jsonpath='{range .items[?(.spec.hostNetwork)]}{.metadata.name} {.status.podIP} {.status.containerStatuses} {end}'"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment