zuul-operator/playbooks/zuul-operator-functional/post.yaml
Jan Gutter c74b147fe7
CI Fixes and dependency updates
These are mostly CI fixes:

* Use podman+cri-o based minikube:
  * This is still considered experimental, but seems to be
    more supported than the 'none' driver.
* Fix an issue where ssh to the emulated static node fails:
  * PAM needed to be disabled for openssh
  * openssh needs more permissions to run - cri-o based minikube
    is more strict
* Rebase test container to Fedora 40
* Update the ingress definition to current API version
* Update zookeeper from 3.5.5 to 3.8.4:
  * required for nodepool 9.0.0+
* Update the percona operator from 1.11 to 1.14:
  * required for kubernetes 1.24+
* Update test node to Ubuntu Jammy from Ubuntu Bionic
* Update minikube to 1.33.1
* Added some more explicit logging to the k8s state, this
  could be split off into a role in future.

Depends-On: https://review.opendev.org/c/zuul/zuul-jobs/+/924970

Change-Id: I7bf27750073fa807069af6f85f2689173b278abe
2024-08-15 10:25:39 +01:00

92 lines
3.6 KiB
YAML

- hosts: all
vars:
crictl_command: "sudo podman exec -it minikube crictl"
zuul_log_dir: "{{ ansible_user_dir }}/zuul-output/logs"
roles:
- collect-container-logs
post_tasks:
- name: Describe resources
shell: |
LOG_DIR={{ zuul_log_dir }}/cluster-resources
mkdir -p ${LOG_DIR}
kubectl get secrets --all-namespaces -o wide >> ${LOG_DIR}/secrets.txt
while read -r line; do
[ "$line" == "secrets" ] && continue
kubectl get "$line" --all-namespaces -o yaml >> ${LOG_DIR}/${line}.yaml
kubectl describe "$line" --all-namespaces >> ${LOG_DIR}/${line}.describe.txt
done < <(kubectl api-resources -o name)
args:
executable: /bin/bash
failed_when: no
- name: Collect system registry configs
shell: |
set -x
CONTAINER_SYSTEM_LOGS={{ zuul_log_dir }}/container-system
mkdir -p ${CONTAINER_SYSTEM_LOGS}
cp /etc/hosts ${CONTAINER_SYSTEM_LOGS}/etc-hosts
cp /etc/containers/registries.conf ${CONTAINER_SYSTEM_LOGS}/etc-containers-registries.conf
failed_when: no
- name: Collect minikube registry conf
shell: |
set -x
CONTAINER_MINIKUBE_LOGS={{ zuul_log_dir }}/container-minikube
mkdir -p ${CONTAINER_MINIKUBE_LOGS}
minikube cp minikube:/etc/hosts ${CONTAINER_MINIKUBE_LOGS}/etc-hosts
minikube cp minikube:/etc/containers/registries.conf ${CONTAINER_MINIKUBE_LOGS}/etc-containers-registries.conf
failed_when: no
- name: Get logs from minikube and the operator
shell: |
minikube logs > {{ zuul_log_dir }}/minikube.txt
kubectl logs -l name=zuul-operator --tail=-1 > {{ zuul_log_dir }}/logs/zuul-operator-logs.txt
sudo podman inspect minikube > {{ zuul_log_dir }}/minikube-container.txt
environment:
MINIKUBE_HOME: "{{ ansible_user_dir }}"
failed_when: false
- name: Get kubelet and crio logs inside podman container
shell: |
set -x
KUBELET_LOG_DIR={{ zuul_log_dir }}/kubelet
CRIO_LOG_DIR={{ zuul_log_dir }}/minikube-crio
CONTAINERS_LOG_DIR={{ zuul_log_dir }}/containers
mkdir -p ${KUBELET_LOG_DIR}
mkdir -p ${CRIO_LOG_DIR}
mkdir -p ${CONTAINERS_LOG_DIR}
JOURNALCTL_CMD="sudo podman exec -it minikube journalctl"
${JOURNALCTL_CMD} -u kubelet.service >> ${KUBELET_LOG_DIR}/kubelet.txt
${JOURNALCTL_CMD} -u crio.service >> ${CRIO_LOG_DIR}/crio.txt
failed_when: false
- name: Get all containers
command: "{{ crictl_command }} ps -a -o json"
register: crictl_ps
- name: Loop through containers and collect logs
shell: >-
{{ crictl_command }} logs -t {{ container_id }} >
{{ zuul_log_dir }}/containers/{{ container_log_name }}
failed_when: no
vars:
crictl_containers: >-
{{ crictl_ps.stdout | from_json | json_query('containers') | list }}
container_id: >-
{{ container | json_query('id') }}
pod_name: >-
{{ container | json_query('labels."io.kubernetes.pod.name"') }}
pod_namespace: >-
{{ container | json_query('labels."io.kubernetes.pod.namespace"') }}
container_name: >-
{{ container | json_query('labels."io.kubernetes.container.name"') }}
container_log_name: >-
{{ pod_namespace }}--{{ pod_name }}--{{ container_name }}.txt
loop: "{{ crictl_containers }}"
loop_control:
loop_var: container
- name: Delete empty container logs
command: "find {{ zuul_log_dir }} -type f -empty -delete"
ignore_errors: yes