From feeeed4d5d90c0f53311a7f820b1f81b171b41e4 Mon Sep 17 00:00:00 2001
From: Pete Birley <pete@port.direct>
Date: Thu, 4 Oct 2018 12:09:31 -0500
Subject: [PATCH] Gate: Remove unused helm chart deployment role and playbook

This PS removes the unused helm chart deployment role and playbook.

Change-Id: I01c58a628589ec35af2557c8cc93ea47fe084089
Signed-off-by: Pete Birley <pete@port.direct>
---
 playbooks/osh-infra-deploy-charts.yaml        | 36 --------
 .../tasks/generate-dynamic-over-rides.yaml    | 19 ----
 .../tasks/helm-setup-dev-environment.yaml     | 39 --------
 roles/deploy-helm-packages/tasks/main.yaml    | 27 ------
 .../tasks/util-chart-group.yaml               | 29 ------
 .../tasks/util-common-helm-chart.yaml         | 92 -------------------
 .../tasks/util-common-helm-test.yaml          | 67 --------------
 .../tasks/util-common-wait-for-pods.yaml      | 50 ----------
 tools/gate/devel/start.sh                     |  4 +-
 9 files changed, 1 insertion(+), 362 deletions(-)
 delete mode 100644 playbooks/osh-infra-deploy-charts.yaml
 delete mode 100644 roles/deploy-helm-packages/tasks/generate-dynamic-over-rides.yaml
 delete mode 100644 roles/deploy-helm-packages/tasks/helm-setup-dev-environment.yaml
 delete mode 100644 roles/deploy-helm-packages/tasks/main.yaml
 delete mode 100644 roles/deploy-helm-packages/tasks/util-chart-group.yaml
 delete mode 100644 roles/deploy-helm-packages/tasks/util-common-helm-chart.yaml
 delete mode 100644 roles/deploy-helm-packages/tasks/util-common-helm-test.yaml
 delete mode 100644 roles/deploy-helm-packages/tasks/util-common-wait-for-pods.yaml

diff --git a/playbooks/osh-infra-deploy-charts.yaml b/playbooks/osh-infra-deploy-charts.yaml
deleted file mode 100644
index 6e0303cd4..000000000
--- a/playbooks/osh-infra-deploy-charts.yaml
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright 2017 The Openstack-Helm Authors.
-#
-# 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: primary
-  vars_files:
-    - vars.yaml
-  vars:
-    work_dir: "{{ zuul.project.src_dir }}/{{ zuul_osh_infra_relative_path | default('') }}"
-  gather_facts: True
-  roles:
-    - build-helm-packages
-  tags:
-    - build-helm-packages
-
-- hosts: primary
-  vars_files:
-    - vars.yaml
-    - ../tools/gate/chart-deploys/default.yaml
-  vars:
-    work_dir: "{{ zuul.project.src_dir }}/{{ zuul_osh_infra_relative_path | default('') }}"
-    logs_dir: "/tmp/logs"
-  roles:
-    - deploy-helm-packages
-  tags:
-    - deploy-helm-packages
diff --git a/roles/deploy-helm-packages/tasks/generate-dynamic-over-rides.yaml b/roles/deploy-helm-packages/tasks/generate-dynamic-over-rides.yaml
deleted file mode 100644
index 7738af531..000000000
--- a/roles/deploy-helm-packages/tasks/generate-dynamic-over-rides.yaml
+++ /dev/null
@@ -1,19 +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.
-
-# This set of tasks creates over-rides that need to be generated dyamicly and
-# injected at runtime.
-
-- name: setup directorys on host
-  file:
-    path: "{{ work_dir }}/tools/gate/local-overrides/"
-    state: directory
diff --git a/roles/deploy-helm-packages/tasks/helm-setup-dev-environment.yaml b/roles/deploy-helm-packages/tasks/helm-setup-dev-environment.yaml
deleted file mode 100644
index b2bfa7d21..000000000
--- a/roles/deploy-helm-packages/tasks/helm-setup-dev-environment.yaml
+++ /dev/null
@@ -1,39 +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.
-
-- block:
-    - name: installing OS-H dev tools
-      include_role:
-        name: deploy-package
-        tasks_from: dist
-      vars:
-        packages:
-          deb:
-            - git
-            - make
-            - curl
-            - ca-certificates
-          rpm:
-            - git
-            - make
-            - curl
-    - name: installing jq
-      include_role:
-        name: deploy-jq
-        tasks_from: main
-
-- name: assemble charts
-  make:
-    chdir: "{{ work_dir }}"
-  register: out
-
-- include: util-setup-dev-environment.yaml
diff --git a/roles/deploy-helm-packages/tasks/main.yaml b/roles/deploy-helm-packages/tasks/main.yaml
deleted file mode 100644
index 779c4008e..000000000
--- a/roles/deploy-helm-packages/tasks/main.yaml
+++ /dev/null
@@ -1,27 +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.
-
-- include: generate-dynamic-over-rides.yaml
-
-- name: "creating directory for helm test logs"
-  file:
-    path: "{{ logs_dir }}/helm-tests"
-    state: directory
-
-- name: "iterating through Helm chart groups"
-  vars:
-    chart_group_name: "{{ helm_chart_group.name }}"
-    chart_group_items: "{{ helm_chart_group.charts }}"
-  include: util-chart-group.yaml
-  loop_control:
-    loop_var: helm_chart_group
-  with_items: "{{ chart_groups }}"
diff --git a/roles/deploy-helm-packages/tasks/util-chart-group.yaml b/roles/deploy-helm-packages/tasks/util-chart-group.yaml
deleted file mode 100644
index a114ff370..000000000
--- a/roles/deploy-helm-packages/tasks/util-chart-group.yaml
+++ /dev/null
@@ -1,29 +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_chart_group.name }}"
-  vars:
-    chart_def: "{{ charts[helm_chart] }}"
-  loop_control:
-    loop_var: helm_chart
-  include: util-common-helm-chart.yaml
-  with_items: "{{ helm_chart_group.charts }}"
-
-- name: "Running wait for pods for the charts in the {{ helm_chart_group.name }} group"
-  when: ('timeout' in helm_chart_group)
-  include: util-common-wait-for-pods.yaml
-  vars:
-    namespace: "{{ charts[helm_chart].namespace }}"
-    timeout: "{{ helm_chart_group.timeout }}"
-  loop_control:
-    loop_var: helm_chart
-  with_items: "{{ helm_chart_group.charts }}"
diff --git a/roles/deploy-helm-packages/tasks/util-common-helm-chart.yaml b/roles/deploy-helm-packages/tasks/util-common-helm-chart.yaml
deleted file mode 100644
index 3ff590d49..000000000
--- a/roles/deploy-helm-packages/tasks/util-common-helm-chart.yaml
+++ /dev/null
@@ -1,92 +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 management common block
-  vars:
-    check_deployed_result: null
-    chart_values_file: null
-    upgrade:
-      pre:
-        delete: null
-
-  block:
-    - name: "create temporary file for {{ chart_def['release'] }}'s values .yaml"
-      tempfile:
-        state: file
-        suffix: .yaml
-      register: chart_values_file
-    - name: "write out values.yaml for {{ chart_def['release'] }}"
-      copy:
-        dest: "{{ chart_values_file.path }}"
-        content: "{% if 'values' in chart_def %}{{ chart_def['values'] | to_nice_yaml }}{% else %}{% endif %}"
-
-    - name: "check if {{ chart_def['release'] }} is deployed"
-      command: helm status "{{ chart_def['release'] }}"
-      register: check_deployed_result
-      ignore_errors: True
-
-    - name: "check if local overrides are present in {{ work_dir }}/tools/gate/local-overrides/{{ chart_def['release'] }}.yaml"
-      stat:
-        path: "{{ work_dir }}/tools/gate/local-overrides/{{ chart_def['release'] }}.yaml"
-      register: local_overrides
-
-    - name: "try to deploy release {{ chart_def['release'] }} in {{ chart_def['namespace'] }} namespace with {{ chart_def['chart_name'] }} chart"
-      when: check_deployed_result is failed
-      command: "helm install {{ work_dir }}/{{ chart_def['chart_name'] }} --namespace {{ chart_def['namespace'] }} --name {{ chart_def['release'] }} --values={{ chart_values_file.path }}{% if local_overrides.stat.exists %} --values {{ work_dir }}/tools/gate/local-overrides/{{ chart_def['release'] }}.yaml{% endif %}"
-      register: out
-    - name: "display info for the helm {{ chart_def['release'] }} release deploy"
-      when: check_deployed_result is failed
-      debug:
-        var: out.stdout_lines
-
-    - name: "pre-upgrade, delete jobs for {{ chart_def['release'] }} release"
-      when:
-        - check_deployed_result is succeeded
-        - "'upgrade' in chart_def"
-        - "'pre' in chart_def['upgrade']"
-        - "'delete' in chart_def['upgrade']['pre']"
-        - "chart_def.upgrade.pre.delete is not none"
-      with_items: "{{ chart_def.upgrade.pre.delete }}"
-      loop_control:
-        loop_var: helm_upgrade_delete_job
-      command: "kubectl delete --namespace {{ chart_def['namespace'] }} job -l application={{ helm_upgrade_delete_job.labels.application }},component={{ helm_upgrade_delete_job.labels.component }} --ignore-not-found=true"
-    - name: "try to upgrade release {{ chart_def['release'] }} in {{ chart_def['namespace'] }} namespace with {{ chart_def['chart_name'] }} chart"
-      when: check_deployed_result is succeeded
-      command: "helm upgrade {{ chart_def['release'] }} {{ work_dir }}/{{ chart_def['chart_name'] }} --values={{ chart_values_file.path }}{% if local_overrides.stat.exists %} --values {{ work_dir }}/tools/gate/local-overrides/{{ chart_def['release'] }}.yaml{% endif %}"
-      register: out
-    - name: "display info for the helm {{ chart_def['release'] }} release upgrade"
-      when: check_deployed_result is succeeded
-      debug:
-        var: out.stdout_lines
-
-    - include: util-common-wait-for-pods.yaml
-      when: ('timeout' in chart_def)
-      vars:
-        namespace: "{{ chart_def['namespace'] }}"
-        timeout: "{{ chart_def['timeout'] }}"
-
-    - include: util-common-helm-test.yaml
-      when:
-        - "'test' in chart_def"
-        - "chart_def.test is not none"
-        - "'enabled' in chart_def['test']"
-        - "chart_def.test.enabled|bool == true"
-      vars:
-        release: "{{ chart_def['release'] }}"
-        namespace: "{{ chart_def['namespace'] }}"
-        test_settings: "{{ chart_def.test }}"
-
-  always:
-    - name: "remove values.yaml for {{ chart_def['release'] }}"
-      file:
-        path: "{{ chart_values_file.path }}"
-        state: absent
diff --git a/roles/deploy-helm-packages/tasks/util-common-helm-test.yaml b/roles/deploy-helm-packages/tasks/util-common-helm-test.yaml
deleted file mode 100644
index e5c078599..000000000
--- a/roles/deploy-helm-packages/tasks/util-common-helm-test.yaml
+++ /dev/null
@@ -1,67 +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 test common block
-  vars:
-    release: null
-    namespace: null
-    test_settings: null
-
-  block:
-    - name: "remove any expired helm test pods for {{ release }}"
-      command: "kubectl delete pod {{ release }}-test -n {{ namespace }}"
-      ignore_errors: True
-
-    - name: "run helm tests for the {{ release }} release"
-      when:
-        - "'timeout' in test_settings"
-        - "'timeout' is none"
-      command: "helm test {{ release }}"
-      register: test_result
-
-    - name: "run helm tests for the {{ release }} release with timeout"
-      when:
-        - "'timeout' in test_settings"
-        - "'timeout' is not none"
-      command: " helm test --timeout {{ test_settings.timeout }} {{ release }}"
-      register: test_result
-
-    - name: "display status for {{ release }} helm tests"
-      debug:
-        var: test_result.stdout_lines
-
-    - name: "gathering logs for helm tests for {{ release }}"
-      when:
-        - test_result is succeeded
-      shell: |-
-              set -e
-              kubectl logs {{ release }}-test -n {{ namespace }} >> {{ logs_dir }}/helm-tests/{{ release }}.txt
-      args:
-        executable: /bin/bash
-      register: test_logs
-
-    - name: "displaying logs for successful helm tests for {{ release }}"
-      when:
-        - test_result is succeeded
-        - "'output' in test_settings"
-        - "test_settings.output|bool == true"
-      debug:
-        var: test_logs.stdout_lines
-  rescue:
-    - name: "gathering logs for failed helm tests for {{ release }}"
-      command: "kubectl logs {{ release }}-test -n {{ namespace }}"
-      register: out
-    - name: "displaying logs for failed helm tests for {{ release }}"
-      debug:
-        var: out.stdout_lines
-    - name: "helm tests for {{ release }} failed, stopping execution"
-      command: exit 1
diff --git a/roles/deploy-helm-packages/tasks/util-common-wait-for-pods.yaml b/roles/deploy-helm-packages/tasks/util-common-wait-for-pods.yaml
deleted file mode 100644
index 19d8785b1..000000000
--- a/roles/deploy-helm-packages/tasks/util-common-wait-for-pods.yaml
+++ /dev/null
@@ -1,50 +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: wait for pods in namespace
-  vars:
-    namespace: null
-    timeout: 600
-    wait_return_code:
-      rc: 1
-  block:
-    - name: "wait for pods in {{ namespace }} namespace to be ready"
-      shell: |-
-              set -e
-              kubectl get pods --namespace="{{ namespace }}" -o json | jq -r \
-                  '.items[].status.phase' | grep Pending > /dev/null && \
-                  PENDING=True || PENDING=False
-
-              query='.items[]|select(.status.phase=="Running")'
-              query="$query|.status.containerStatuses[].ready"
-              kubectl get pods --namespace="{{ namespace }}" -o json | jq -r "$query" | \
-                  grep false > /dev/null && READY="False" || READY="True"
-
-              kubectl get jobs -o json --namespace="{{ namespace }}" | jq -r \
-                  '.items[] | .spec.completions == .status.succeeded' | \
-                  grep false > /dev/null && JOBR="False" || JOBR="True"
-              [ $PENDING == "False" -a $READY == "True" -a $JOBR == "True" ] && \
-                  exit 0 || exit 1
-      args:
-        executable: /bin/bash
-      register: wait_return_code
-      until: wait_return_code.rc == 0
-      retries: "{{ timeout }}"
-      delay: 1
-  rescue:
-    - name: "pods failed to come up in time, getting kubernetes objects status"
-      command: kubectl get --all-namespaces  all -o wide --show-all
-      register: out
-    - name: "pods failed to come up in time, displaying kubernetes objects status"
-      debug: var=out.stdout_lines
-    - name: "pods failed to come up in time, stopping execution"
-      command: exit 1
diff --git a/tools/gate/devel/start.sh b/tools/gate/devel/start.sh
index eda5e45e7..25194aca4 100755
--- a/tools/gate/devel/start.sh
+++ b/tools/gate/devel/start.sh
@@ -75,13 +75,11 @@ if [ "x${DEPLOY}" == "xsetup-host" ]; then
   PLAYBOOKS="osh-infra-deploy-docker"
 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-deploy-docker osh-infra-build osh-infra-deploy-k8s osh-infra-deploy-charts osh-infra-collect-logs"
+  PLAYBOOKS="osh-infra-deploy-docker osh-infra-build osh-infra-deploy-k8s osh-infra-collect-logs"
 else
   echo "Unknown Deploy Option Selected"
   exit 1