From 6c3786aef30e741296de3cb0b329cd9fd97d8ccf Mon Sep 17 00:00:00 2001 From: portdirect <pete@port.direct> Date: Thu, 28 Dec 2017 14:47:10 -0500 Subject: [PATCH] Gate: simplify helm release log gathering This PS simplifys the helm release log gathering, to collect logs from all charts released into the cluster, and also adds a `logs` sub-target to the dev-deploy target in the Makefile. Change-Id: I016a5e08163eaccf13331db6faa45fab1e9cf4f2 --- tools/gate/devel/start.sh | 2 + .../helm-release-status/tasks/main.yaml | 38 +++++++++++-------- .../tasks/util-chart-group-releases.yaml | 20 ---------- .../tasks/util-common-release-status.yaml | 23 ----------- 4 files changed, 24 insertions(+), 59 deletions(-) delete mode 100644 tools/gate/playbooks/helm-release-status/tasks/util-chart-group-releases.yaml delete mode 100644 tools/gate/playbooks/helm-release-status/tasks/util-common-release-status.yaml diff --git a/tools/gate/devel/start.sh b/tools/gate/devel/start.sh index 7e4261aa9..e989cbc7d 100755 --- a/tools/gate/devel/start.sh +++ b/tools/gate/devel/start.sh @@ -68,6 +68,8 @@ elif [ "x${DEPLOY}" == "xk8s" ]; then PLAYBOOKS="osh-infra-build osh-infra-deploy-k8s" elif [ "x${DEPLOY}" == "xcharts" ]; then PLAYBOOKS="osh-infra-deploy-charts" +elif [ "x${DEPLOY}" == "xlogs" ]; then + PLAYBOOKS="osh-infra-collect-logs" elif [ "x${DEPLOY}" == "xfull" ]; then ansible_install PLAYBOOKS="osh-infra-docker osh-infra-build osh-infra-deploy-k8s osh-infra-deploy-charts osh-infra-collect-logs" diff --git a/tools/gate/playbooks/helm-release-status/tasks/main.yaml b/tools/gate/playbooks/helm-release-status/tasks/main.yaml index 00fa514c9..8c07cdf9d 100644 --- a/tools/gate/playbooks/helm-release-status/tasks/main.yaml +++ b/tools/gate/playbooks/helm-release-status/tasks/main.yaml @@ -12,27 +12,33 @@ - name: "creating directory for helm release status" file: - path: "{{ logs_dir }}/helm-releases" + path: "{{ logs_dir }}/helm" state: directory -- name: "Gathering release status in chart groups" +- name: "retrieve all deployed charts" + shell: |- + set -e + helm ls --short + args: + executable: /bin/bash + register: helm_releases + +- name: "Gather get release status for helm charts" + shell: |- + set -e + helm status {{ helm_released }} >> {{ logs_dir }}/helm/{{ helm_release }}.txt + args: + executable: /bin/bash + ignore_errors: True vars: - chart_group_name: "{{ helm_chart_group.name }}" - include: util-chart-group-releases.yaml + helm_release: "{{ helm_released }}" loop_control: - loop_var: helm_chart_group - with_items: "{{ chart_groups }}" + loop_var: helm_released + with_items: "{{ helm_releases.stdout_lines }}" -- name: "Downloads helm release statuses to executor" +- name: "Downloads logs to executor" synchronize: - src: "{{ logs_dir }}/helm-releases" + src: "{{ logs_dir }}/helm" dest: "{{ zuul.executor.log_root }}/{{ inventory_hostname }}" mode: pull - ignore_errors: yes - -- name: "Download helm release test logs to executor" - synchronize: - src: "{{ logs_dir }}/helm-tests" - dest: "{{ zuul.executor.log_root }}/{{ inventory_hostname }}" - mode: pull - ignore_errors: yes + ignore_errors: True diff --git a/tools/gate/playbooks/helm-release-status/tasks/util-chart-group-releases.yaml b/tools/gate/playbooks/helm-release-status/tasks/util-chart-group-releases.yaml deleted file mode 100644 index 7fddb3180..000000000 --- a/tools/gate/playbooks/helm-release-status/tasks/util-chart-group-releases.yaml +++ /dev/null @@ -1,20 +0,0 @@ -# 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: "Gathering release status for {{ helm_chart_group.name }} chart group" - vars: - release: "{{ charts[helm_chart].release }}" - namespace: "{{ charts[helm_chart].namespace }}" - loop_control: - loop_var: helm_chart - include: util-common-release-status.yaml - with_items: "{{ helm_chart_group.charts }}" diff --git a/tools/gate/playbooks/helm-release-status/tasks/util-common-release-status.yaml b/tools/gate/playbooks/helm-release-status/tasks/util-common-release-status.yaml deleted file mode 100644 index 42fade4b7..000000000 --- a/tools/gate/playbooks/helm-release-status/tasks/util-common-release-status.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# 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: Helm release status common block - vars: - release: null - namespace: null - block: - - name: "describing the {{ release }} release" - shell: |- - helm status "{{ release }}" > "{{ logs_dir }}"/helm-releases/"{{ release }}".yaml - args: - executable: /bin/bash - ignore_errors: True