diff --git a/playbooks/airship-collect-container-logs.yaml b/playbooks/airship-collect-container-logs.yaml new file mode 100644 index 000000000..1d8fa6b14 --- /dev/null +++ b/playbooks/airship-collect-container-logs.yaml @@ -0,0 +1,15 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- hosts: all + roles: + - airship-gather-container-logs diff --git a/roles/airship-gather-container-logs/defaults/main.yaml b/roles/airship-gather-container-logs/defaults/main.yaml new file mode 100644 index 000000000..cf2c0d5f6 --- /dev/null +++ b/roles/airship-gather-container-logs/defaults/main.yaml @@ -0,0 +1,15 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Should match what is set in zuul/zuul-jobs: +# roles/fetch-output/defaults/main.yaml +zuul_output_dir: "{{ ansible_user_dir }}/zuul-output" diff --git a/roles/airship-gather-container-logs/tasks/main.yaml b/roles/airship-gather-container-logs/tasks/main.yaml new file mode 100644 index 000000000..81acc8884 --- /dev/null +++ b/roles/airship-gather-container-logs/tasks/main.yaml @@ -0,0 +1,36 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: set runtime logs dir + set_fact: + zuul_artifact_dir: "{{ zuul_output_dir }}/artifacts" + +- name: ensure directory for runtime logs exists + file: + state: directory + path: "{{ zuul_artifact_dir }}" + +- name: dump docker logs + shell: |- + journalctl --unit "docker" --no-pager > "{{ zuul_artifact_dir }}/docker.log" + when: ansible_facts.services['docker'] is defined + args: + executable: /bin/bash + become: true + +- name: dump containerd logs + shell: |- + journalctl --unit "containerd" --no-pager > "{{ zuul_artifact_dir }}/containerd.log" + when: ansible_facts.services['containerd'] is defined + args: + executable: /bin/bash + become: true diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index d923fa37f..82c32a915 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -42,6 +42,7 @@ name: airship-airshipctl-build-image nodeset: airship-airshipctl-single-node run: playbooks/airship-airshipctl-build-images.yaml + post-run: playbooks/airship-collect-container-logs.yaml irrelevant-files: - ^.*\.md$ - ^docs/.*$ @@ -50,6 +51,7 @@ name: airship-airshipctl-functional-existing-k8s pre-run: playbooks/airship-airshipctl-deploy-existing-k8s.yaml run: playbooks/airship-airshipctl-functional-existing-k8s.yaml + post-run: playbooks/airship-collect-container-logs.yaml nodeset: airship-airshipctl-single-node - job: @@ -73,7 +75,9 @@ pre-run: - playbooks/airship-airshipctl-deploy-docker.yaml - playbooks/airship-airshipctl-build-gate.yaml - post-run: playbooks/airship-collect-logs.yaml + post-run: + - playbooks/airship-collect-logs.yaml + - playbooks/airship-collect-container-logs.yaml run: playbooks/airship-airshipctl-test-runner.yaml nodeset: airship-airshipctl-single-32GB-bionic-node vars: