Wait for available API token in a new namespace (#7045)

Just after creating a namespace, the corresponding token could not be
created and sometimes the pod creation might be failed.
This adds check of the token in the new namespace to make this test
case stable.
This commit is contained in:
Kenichi Omichi 2020-12-19 04:54:24 -08:00 committed by GitHub
parent 9a05037352
commit 275c54e810
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -43,6 +43,16 @@
command: "{{ bin_dir }}/kubectl create namespace test" command: "{{ bin_dir }}/kubectl create namespace test"
changed_when: false changed_when: false
- name: Wait for API token of test namespace
shell: "set -o pipefail && {{ bin_dir }}/kubectl describe serviceaccounts default --namespace test | grep Tokens | awk '{print $2}'"
args:
executable: /bin/bash
changed_when: false
register: default_token
until: default_token.stdout.find('<none>') == -1
retries: 5
delay: 5
- name: Run 2 busybox pods in test ns - name: Run 2 busybox pods in test ns
command: "{{ bin_dir }}/kubectl run {{ item }} --image={{ test_image_repo }}:{{ test_image_tag }} --namespace test --command -- tail -f /dev/null" command: "{{ bin_dir }}/kubectl run {{ item }} --image={{ test_image_repo }}:{{ test_image_tag }} --namespace test --command -- tail -f /dev/null"
changed_when: false changed_when: false