mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2025-12-14 13:54:37 +03:00
Merge pull request #11793 from VannTen/cleanup/ci_testcases_better_callback
Use debug stdout callback in ci rather than manual debug
This commit is contained in:
@@ -10,6 +10,7 @@ variables:
|
|||||||
FAILFASTCI_NAMESPACE: 'kargo-ci'
|
FAILFASTCI_NAMESPACE: 'kargo-ci'
|
||||||
GITLAB_REPOSITORY: 'kargo-ci/kubernetes-sigs-kubespray'
|
GITLAB_REPOSITORY: 'kargo-ci/kubernetes-sigs-kubespray'
|
||||||
ANSIBLE_FORCE_COLOR: "true"
|
ANSIBLE_FORCE_COLOR: "true"
|
||||||
|
ANSIBLE_STDOUT_CALLBACK: "debug"
|
||||||
MAGIC: "ci check this"
|
MAGIC: "ci check this"
|
||||||
GS_ACCESS_KEY_ID: $GS_KEY
|
GS_ACCESS_KEY_ID: $GS_KEY
|
||||||
GS_SECRET_ACCESS_KEY: $GS_SECRET
|
GS_SECRET_ACCESS_KEY: $GS_SECRET
|
||||||
|
|||||||
@@ -13,9 +13,6 @@
|
|||||||
delay: 5
|
delay: 5
|
||||||
until: apiserver_response is success
|
until: apiserver_response is success
|
||||||
|
|
||||||
- debug: # noqa name[missing]
|
|
||||||
msg: "{{ apiserver_response.json }}"
|
|
||||||
|
|
||||||
- name: Check API servers version
|
- name: Check API servers version
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
|
|||||||
@@ -1,18 +1,10 @@
|
|||||||
---
|
---
|
||||||
- name: Testcases checking nodes
|
- name: Testcases checking nodes
|
||||||
hosts: kube_control_plane[0]
|
hosts: kube_control_plane[0]
|
||||||
|
vars:
|
||||||
|
bin_dir: /usr/local/bin
|
||||||
tasks:
|
tasks:
|
||||||
|
|
||||||
- name: Force binaries directory for Flatcar Container Linux by Kinvolk
|
|
||||||
set_fact:
|
|
||||||
bin_dir: "/opt/bin"
|
|
||||||
when: ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
|
||||||
|
|
||||||
- name: Force binaries directory for other hosts
|
|
||||||
set_fact:
|
|
||||||
bin_dir: "/usr/local/bin"
|
|
||||||
when: not ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
|
||||||
|
|
||||||
- import_role: # noqa name[missing]
|
- import_role: # noqa name[missing]
|
||||||
name: cluster-dump
|
name: cluster-dump
|
||||||
|
|
||||||
@@ -21,9 +13,6 @@
|
|||||||
changed_when: false
|
changed_when: false
|
||||||
register: get_nodes
|
register: get_nodes
|
||||||
|
|
||||||
- debug: # noqa name[missing]
|
|
||||||
msg: "{{ get_nodes.stdout.split('\n') }}"
|
|
||||||
|
|
||||||
- name: Check that all nodes are running and ready
|
- name: Check that all nodes are running and ready
|
||||||
command: "{{ bin_dir }}/kubectl get nodes --no-headers -o yaml"
|
command: "{{ bin_dir }}/kubectl get nodes --no-headers -o yaml"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|||||||
@@ -1,28 +1,16 @@
|
|||||||
---
|
---
|
||||||
- name: Testcases checking pods
|
- name: Testcases checking pods
|
||||||
hosts: kube_control_plane[0]
|
hosts: kube_control_plane[0]
|
||||||
|
vars:
|
||||||
|
bin_dir: /usr/local/bin
|
||||||
tasks:
|
tasks:
|
||||||
|
|
||||||
- name: Force binaries directory for Flatcar Container Linux by Kinvolk
|
|
||||||
set_fact:
|
|
||||||
bin_dir: "/opt/bin"
|
|
||||||
when: ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
|
||||||
|
|
||||||
- name: Force binaries directory for other hosts
|
|
||||||
set_fact:
|
|
||||||
bin_dir: "/usr/local/bin"
|
|
||||||
when: not ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
|
||||||
|
|
||||||
- import_role: # noqa name[missing]
|
- import_role: # noqa name[missing]
|
||||||
name: cluster-dump
|
name: cluster-dump
|
||||||
|
|
||||||
- name: Check kubectl output
|
- name: Check kubectl output
|
||||||
command: "{{ bin_dir }}/kubectl get pods --all-namespaces -owide"
|
command: "{{ bin_dir }}/kubectl get pods --all-namespaces -owide"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
register: get_pods
|
|
||||||
|
|
||||||
- debug: # noqa name[missing]
|
|
||||||
msg: "{{ get_pods.stdout.split('\n') }}"
|
|
||||||
|
|
||||||
- name: Check that all pods are running and ready
|
- name: Check that all pods are running and ready
|
||||||
command: "{{ bin_dir }}/kubectl get pods --all-namespaces --no-headers -o yaml"
|
command: "{{ bin_dir }}/kubectl get pods --all-namespaces --no-headers -o yaml"
|
||||||
@@ -35,13 +23,7 @@
|
|||||||
- '(run_pods_log.stdout | from_yaml)["items"] | map(attribute = "status.containerStatuses") | map("map", attribute = "ready") | map("min") | min'
|
- '(run_pods_log.stdout | from_yaml)["items"] | map(attribute = "status.containerStatuses") | map("map", attribute = "ready") | map("min") | min'
|
||||||
retries: 30
|
retries: 30
|
||||||
delay: 10
|
delay: 10
|
||||||
failed_when: false
|
|
||||||
|
|
||||||
- name: Check kubectl output
|
- name: Check kubectl output
|
||||||
command: "{{ bin_dir }}/kubectl get pods --all-namespaces -owide"
|
command: "{{ bin_dir }}/kubectl get pods --all-namespaces -owide"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
register: get_pods
|
|
||||||
|
|
||||||
- debug: # noqa name[missing]
|
|
||||||
msg: "{{ get_pods.stdout.split('\n') }}"
|
|
||||||
failed_when: not run_pods_log is success
|
|
||||||
|
|||||||
@@ -4,17 +4,9 @@
|
|||||||
vars:
|
vars:
|
||||||
test_image_repo: registry.k8s.io/e2e-test-images/agnhost
|
test_image_repo: registry.k8s.io/e2e-test-images/agnhost
|
||||||
test_image_tag: "2.40"
|
test_image_tag: "2.40"
|
||||||
|
bin_dir: "/usr/local/bin"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Force binaries directory for Flatcar Container Linux by Kinvolk
|
|
||||||
set_fact:
|
|
||||||
bin_dir: "/opt/bin"
|
|
||||||
when: ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
|
||||||
|
|
||||||
- name: Force binaries directory for other hosts
|
|
||||||
set_fact:
|
|
||||||
bin_dir: "/usr/local/bin"
|
|
||||||
when: not ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
|
||||||
|
|
||||||
- name: Check kubelet serving certificates approved with kubelet_csr_approver
|
- name: Check kubelet serving certificates approved with kubelet_csr_approver
|
||||||
when:
|
when:
|
||||||
@@ -29,9 +21,6 @@
|
|||||||
register: csr_json
|
register: csr_json
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- debug: # noqa name[missing]
|
|
||||||
var: csrs
|
|
||||||
|
|
||||||
- name: Check there are csrs
|
- name: Check there are csrs
|
||||||
assert:
|
assert:
|
||||||
that: csrs | length > 0
|
that: csrs | length > 0
|
||||||
@@ -67,17 +56,13 @@
|
|||||||
when: get_csr.stdout_lines | length > 0
|
when: get_csr.stdout_lines | length > 0
|
||||||
changed_when: certificate_approve.stdout
|
changed_when: certificate_approve.stdout
|
||||||
|
|
||||||
- debug: # noqa name[missing]
|
|
||||||
msg: "{{ certificate_approve.stdout.split('\n') }}"
|
|
||||||
|
|
||||||
|
|
||||||
- name: Create test namespace
|
- name: Create test namespace
|
||||||
command: "{{ bin_dir }}/kubectl create namespace test"
|
command: "{{ bin_dir }}/kubectl create namespace test"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Run 2 agnhost pods in test ns
|
- name: Run 2 agnhost pods in test ns
|
||||||
command:
|
command:
|
||||||
cmd: "{{ bin_dir }}/kubectl apply -f -"
|
cmd: "{{ bin_dir }}/kubectl apply --namespace test -f -"
|
||||||
stdin: |
|
stdin: |
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
@@ -107,52 +92,35 @@
|
|||||||
type: RuntimeDefault
|
type: RuntimeDefault
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- import_role: # noqa name[missing]
|
|
||||||
name: cluster-dump
|
|
||||||
|
|
||||||
- name: Check that all pods are running and ready
|
- name: Check that all pods are running and ready
|
||||||
|
vars:
|
||||||
|
pods: "{{ (pods_json.stdout | from_json)['items'] }}"
|
||||||
block:
|
block:
|
||||||
- name: Check Deployment is ready
|
- name: Check Deployment is ready
|
||||||
command: "{{ bin_dir }}/kubectl rollout status deploy --namespace test agnhost --timeout=180"
|
command: "{{ bin_dir }}/kubectl rollout status deploy --namespace test agnhost --timeout=180s"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
rescue:
|
|
||||||
- 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_json
|
||||||
|
|
||||||
- name: Get running pods
|
|
||||||
command: "{{ bin_dir }}/kubectl get pods -n test -o
|
|
||||||
jsonpath='{range .items[?(.status.phase==\"Running\")]}{.metadata.name} {.status.podIP} {.status.containerStatuses} {end}'"
|
|
||||||
changed_when: false
|
|
||||||
register: running_pods
|
|
||||||
|
|
||||||
- name: Check kubectl output
|
|
||||||
command: "{{ bin_dir }}/kubectl get pods --all-namespaces -owide"
|
|
||||||
changed_when: false
|
|
||||||
register: get_pods
|
|
||||||
|
|
||||||
- debug: # noqa name[missing]
|
|
||||||
msg: "{{ get_pods.stdout.split('\n') }}"
|
|
||||||
|
|
||||||
- name: Set networking facts
|
|
||||||
set_fact:
|
|
||||||
kube_pods_subnet: 10.233.64.0/18
|
|
||||||
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 }}"
|
|
||||||
pods_running: |
|
|
||||||
{% set list = running_pods.stdout.split(" ") %}
|
|
||||||
{{ list }}
|
|
||||||
|
|
||||||
- name: Check pods IP are in correct network
|
- name: Check pods IP are in correct network
|
||||||
assert:
|
assert:
|
||||||
that: item | ansible.utils.ipaddr(kube_pods_subnet)
|
that: pods
|
||||||
when:
|
| selectattr('status.phase', '==', 'Running')
|
||||||
- item in pods_running
|
| selectattr('status.podIP', 'ansible.utils.in_network', kube_pods_subnet)
|
||||||
with_items: "{{ pod_ips }}"
|
| length == 2
|
||||||
|
|
||||||
- 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].metadata.name }} -- curl {{ item[1].status.podIP }}:8080"
|
||||||
with_nested:
|
with_nested:
|
||||||
- "{{ pod_names }}"
|
- "{{ pods }}"
|
||||||
- "{{ pod_ips }}"
|
- "{{ pods }}"
|
||||||
|
rescue:
|
||||||
|
- name: List pods cluster-wide
|
||||||
|
command: "{{ bin_dir }}/kubectl get pods --all-namespaces -owide"
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- import_role: # noqa name[missing]
|
||||||
|
name: cluster-dump
|
||||||
|
- fail: # noqa name[missing]
|
||||||
|
|||||||
@@ -19,18 +19,9 @@
|
|||||||
agent_report_interval: 10
|
agent_report_interval: 10
|
||||||
netcheck_namespace: default
|
netcheck_namespace: default
|
||||||
netchecker_port: 31081
|
netchecker_port: 31081
|
||||||
|
bin_dir: "/usr/local/bin"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Force binaries directory for Container Linux by CoreOS and Flatcar
|
|
||||||
set_fact:
|
|
||||||
bin_dir: "/opt/bin"
|
|
||||||
when: ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
|
||||||
|
|
||||||
- name: Force binaries directory on other hosts
|
|
||||||
set_fact:
|
|
||||||
bin_dir: "/usr/local/bin"
|
|
||||||
when: not ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
|
||||||
|
|
||||||
- import_role: # noqa name[missing]
|
- import_role: # noqa name[missing]
|
||||||
name: cluster-dump
|
name: cluster-dump
|
||||||
|
|
||||||
@@ -54,55 +45,42 @@
|
|||||||
- netchecker-agent-hostnet
|
- netchecker-agent-hostnet
|
||||||
when: not pods_json is success
|
when: not pods_json is success
|
||||||
|
|
||||||
- debug: # noqa name[missing]
|
- name: Perform netchecker tests
|
||||||
var: nca_pod.stdout_lines
|
run_once: true
|
||||||
when: inventory_hostname == groups['kube_control_plane'][0]
|
delegate_to: "{{ groups['kube_control_plane'][0] }}"
|
||||||
|
block:
|
||||||
- name: Get netchecker agents
|
- name: Get netchecker agents
|
||||||
uri:
|
uri:
|
||||||
url: "http://{{ ansible_default_ipv4.address }}:{{ netchecker_port }}/api/v1/agents/"
|
url: "http://{{ ansible_default_ipv4.address }}:{{ netchecker_port }}/api/v1/agents/"
|
||||||
return_content: true
|
return_content: true
|
||||||
run_once: true
|
headers:
|
||||||
delegate_to: "{{ groups['kube_control_plane'][0] }}"
|
Accept: application/json
|
||||||
register: agents
|
register: agents
|
||||||
retries: 18
|
retries: 18
|
||||||
delay: "{{ agent_report_interval }}"
|
delay: "{{ agent_report_interval }}"
|
||||||
until: agents.content | length > 0 and
|
until:
|
||||||
agents.content[0] == '{' and
|
- agents is success
|
||||||
agents.content | from_json | length >= groups['k8s_cluster'] | intersect(ansible_play_hosts) | length * 2
|
- (agents.content | from_json | length) == (groups['k8s_cluster'] | length * 2)
|
||||||
failed_when: false
|
|
||||||
|
|
||||||
- name: Check netchecker status
|
- name: Check netchecker status
|
||||||
uri:
|
uri:
|
||||||
url: "http://{{ ansible_default_ipv4.address }}:{{ netchecker_port }}/api/v1/connectivity_check"
|
url: "http://{{ ansible_default_ipv4.address }}:{{ netchecker_port }}/api/v1/connectivity_check"
|
||||||
status_code: 200
|
|
||||||
return_content: true
|
return_content: true
|
||||||
delegate_to: "{{ groups['kube_control_plane'][0] }}"
|
headers:
|
||||||
run_once: true
|
Accept: application/json
|
||||||
register: connectivity_check
|
register: connectivity_check
|
||||||
retries: 3
|
retries: 3
|
||||||
delay: "{{ agent_report_interval }}"
|
delay: "{{ agent_report_interval }}"
|
||||||
until: connectivity_check.content | length > 0 and
|
until:
|
||||||
connectivity_check.content[0] == '{'
|
- connectivity_check is success
|
||||||
failed_when: false
|
- connectivity_check.content | from_json
|
||||||
when:
|
|
||||||
- agents.content != '{}'
|
|
||||||
|
|
||||||
- debug: # noqa name[missing]
|
|
||||||
var: pods_json
|
|
||||||
run_once: true
|
|
||||||
|
|
||||||
|
rescue:
|
||||||
- name: Get kube-proxy logs
|
- name: Get kube-proxy logs
|
||||||
command: "{{ bin_dir }}/kubectl -n kube-system logs -l k8s-app=kube-proxy"
|
command: "{{ bin_dir }}/kubectl -n kube-system logs -l k8s-app=kube-proxy"
|
||||||
when:
|
|
||||||
- inventory_hostname == groups['kube_control_plane'][0]
|
|
||||||
- not connectivity_check is success
|
|
||||||
|
|
||||||
- name: Get logs from other apps
|
- name: Get logs from other apps
|
||||||
command: "{{ bin_dir }}/kubectl -n kube-system logs -l k8s-app={{ item }} --all-containers"
|
command: "{{ bin_dir }}/kubectl -n kube-system logs -l k8s-app={{ item }} --all-containers"
|
||||||
when:
|
|
||||||
- inventory_hostname == groups['kube_control_plane'][0]
|
|
||||||
- not connectivity_check is success
|
|
||||||
with_items:
|
with_items:
|
||||||
- kube-router
|
- kube-router
|
||||||
- flannel
|
- flannel
|
||||||
@@ -110,41 +88,14 @@
|
|||||||
- calico-node
|
- calico-node
|
||||||
- cilium
|
- cilium
|
||||||
|
|
||||||
- name: Parse agents list
|
- name: Netchecker tests failed
|
||||||
set_fact:
|
fail:
|
||||||
agents_check_result: "{{ agents.content | from_json }}"
|
msg: "netchecker tests failed"
|
||||||
delegate_to: "{{ groups['kube_control_plane'][0] }}"
|
|
||||||
run_once: true
|
|
||||||
when:
|
|
||||||
- agents is success
|
|
||||||
- agents.content is defined
|
|
||||||
- agents.content[0] == '{'
|
|
||||||
|
|
||||||
- debug: # noqa name[missing]
|
|
||||||
var: agents_check_result
|
|
||||||
delegate_to: "{{ groups['kube_control_plane'][0] }}"
|
|
||||||
run_once: true
|
|
||||||
when:
|
|
||||||
- agents_check_result is defined
|
|
||||||
|
|
||||||
- name: Parse connectivity check
|
|
||||||
set_fact:
|
|
||||||
connectivity_check_result: "{{ connectivity_check.content | from_json }}"
|
|
||||||
delegate_to: "{{ groups['kube_control_plane'][0] }}"
|
|
||||||
run_once: true
|
|
||||||
when:
|
|
||||||
- connectivity_check is success
|
|
||||||
- connectivity_check.content is defined
|
|
||||||
- connectivity_check.content[0] == '{'
|
|
||||||
|
|
||||||
- debug: # noqa name[missing]
|
|
||||||
var: connectivity_check_result
|
|
||||||
delegate_to: "{{ groups['kube_control_plane'][0] }}"
|
|
||||||
run_once: true
|
|
||||||
when:
|
|
||||||
- connectivity_check_result is defined
|
|
||||||
|
|
||||||
- name: Check connectivity with all netchecker agents
|
- name: Check connectivity with all netchecker agents
|
||||||
|
vars:
|
||||||
|
connectivity_check_result: "{{ connectivity_check.content | from_json }}"
|
||||||
|
agents_check_result: "{{ agents.content | from_json }}"
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- agents_check_result is defined
|
- agents_check_result is defined
|
||||||
@@ -193,8 +144,9 @@
|
|||||||
- name: samplepod
|
- name: samplepod
|
||||||
command: ["/bin/bash", "-c", "sleep 2000000000000"]
|
command: ["/bin/bash", "-c", "sleep 2000000000000"]
|
||||||
image: dougbtv/centos-network
|
image: dougbtv/centos-network
|
||||||
|
delegate_to: groups['kube_control_plane'][0]
|
||||||
|
run_once: true
|
||||||
when:
|
when:
|
||||||
- inventory_hostname == groups['kube_control_plane'][0]
|
|
||||||
- kube_network_plugin_multus | default(false) | bool
|
- kube_network_plugin_multus | default(false) | bool
|
||||||
|
|
||||||
- name: Check secondary macvlan interface
|
- name: Check secondary macvlan interface
|
||||||
@@ -203,6 +155,7 @@
|
|||||||
until: output.rc == 0
|
until: output.rc == 0
|
||||||
retries: 90
|
retries: 90
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
delegate_to: groups['kube_control_plane'][0]
|
||||||
|
run_once: true
|
||||||
when:
|
when:
|
||||||
- inventory_hostname == groups['kube_control_plane'][0]
|
|
||||||
- kube_network_plugin_multus | default(false) | bool
|
- kube_network_plugin_multus | default(false) | bool
|
||||||
|
|||||||
Reference in New Issue
Block a user