From 36618411fdf0ac6b809b121d06c640a53a46ddf8 Mon Sep 17 00:00:00 2001 From: Scott Dodson Date: Thu, 18 Apr 2019 17:23:17 -0400 Subject: [PATCH] Add call to installer-gather.sh on failure Don't remove existing artifact gathering just yet. Depends on openshift/installer#1561 --- .../cluster-launch-installer-e2e.yaml | 9 ++++++ ...luster-launch-installer-openstack-e2e.yaml | 9 ++++++ .../cluster-launch-installer-src.yaml | 9 ++++++ .../cluster-launch-e2e-40.yaml | 32 +++++++++++++++++++ 4 files changed, 59 insertions(+) diff --git a/ci-operator/templates/openshift/installer/cluster-launch-installer-e2e.yaml b/ci-operator/templates/openshift/installer/cluster-launch-installer-e2e.yaml index 272aa2f76b95..4f62d3c82afe 100644 --- a/ci-operator/templates/openshift/installer/cluster-launch-installer-e2e.yaml +++ b/ci-operator/templates/openshift/installer/cluster-launch-installer-e2e.yaml @@ -349,6 +349,15 @@ objects: --key /tmp/artifacts/installer/tls/journal-gatewayd.key \ --url "https://${bootstrap_ip}:19531/entries?_SYSTEMD_UNIT=${service}.service" done + if ! whoami &> /dev/null; then + if [ -w /etc/passwd ]; then + echo "${USER_NAME:-default}:x:$(id -u):0:${USER_NAME:-default} user:${HOME}:/sbin/nologin" >> /etc/passwd + fi + fi + eval $(ssh-agent) + ssh-add /etc/openshift-installer/ssh-privatekey + ssh -A -o PreferredAuthentications=publickey -o StrictHostKeyChecking=false -o UserKnownHostsFile=/dev/null core@${bootstrap_ip} /bin/bash -x /usr/local/bin/installer-gather.sh + scp -o PreferredAuthentications=publickey -o StrictHostKeyChecking=false -o UserKnownHostsFile=/dev/null core@${bootstrap_ip}:log-bundle.tar.gz /tmp/artifacts/installer/bootstrap-logs.tar.gz fi else echo "No terraform statefile found. Skipping collection of bootstrap logs." diff --git a/ci-operator/templates/openshift/installer/cluster-launch-installer-openstack-e2e.yaml b/ci-operator/templates/openshift/installer/cluster-launch-installer-openstack-e2e.yaml index 751b2f3652ad..147bb3183ee7 100644 --- a/ci-operator/templates/openshift/installer/cluster-launch-installer-openstack-e2e.yaml +++ b/ci-operator/templates/openshift/installer/cluster-launch-installer-openstack-e2e.yaml @@ -385,6 +385,15 @@ objects: --key /tmp/artifacts/installer/tls/journal-gatewayd.key \ --url "https://${bootstrap_ip}:19531/entries?_SYSTEMD_UNIT=${service}.service" done + if ! whoami &> /dev/null; then + if [ -w /etc/passwd ]; then + echo "${USER_NAME:-default}:x:$(id -u):0:${USER_NAME:-default} user:${HOME}:/sbin/nologin" >> /etc/passwd + fi + fi + eval $(ssh-agent) + ssh-add /etc/openshift-installer/ssh-privatekey + ssh -A -o PreferredAuthentications=publickey -o StrictHostKeyChecking=false -o UserKnownHostsFile=/dev/null core@${bootstrap_ip} /bin/bash -x /usr/local/bin/installer-gather.sh + scp -o PreferredAuthentications=publickey -o StrictHostKeyChecking=false -o UserKnownHostsFile=/dev/null core@${bootstrap_ip}:log-bundle.tar.gz /tmp/artifacts/installer/bootstrap-logs.tar.gz fi else echo "No terraform statefile found. Skipping collection of bootstrap logs." diff --git a/ci-operator/templates/openshift/installer/cluster-launch-installer-src.yaml b/ci-operator/templates/openshift/installer/cluster-launch-installer-src.yaml index aba081e5c1d3..25e4ded629c2 100644 --- a/ci-operator/templates/openshift/installer/cluster-launch-installer-src.yaml +++ b/ci-operator/templates/openshift/installer/cluster-launch-installer-src.yaml @@ -367,6 +367,15 @@ objects: --key /tmp/artifacts/installer/tls/journal-gatewayd.key \ --url "https://${bootstrap_ip}:19531/entries?_SYSTEMD_UNIT=${service}.service" done + if ! whoami &> /dev/null; then + if [ -w /etc/passwd ]; then + echo "${USER_NAME:-default}:x:$(id -u):0:${USER_NAME:-default} user:${HOME}:/sbin/nologin" >> /etc/passwd + fi + fi + eval $(ssh-agent) + ssh-add /etc/openshift-installer/ssh-privatekey + ssh -A -o PreferredAuthentications=publickey -o StrictHostKeyChecking=false -o UserKnownHostsFile=/dev/null core@${bootstrap_ip} /bin/bash -x /usr/local/bin/installer-gather.sh + scp -o PreferredAuthentications=publickey -o StrictHostKeyChecking=false -o UserKnownHostsFile=/dev/null core@${bootstrap_ip}:log-bundle.tar.gz /tmp/artifacts/installer/bootstrap-logs.tar.gz fi else echo "No terraform statefile found. Skipping collection of bootstrap logs." diff --git a/ci-operator/templates/openshift/openshift-ansible/cluster-launch-e2e-40.yaml b/ci-operator/templates/openshift/openshift-ansible/cluster-launch-e2e-40.yaml index 658cbc41ee73..acd3341b57ac 100644 --- a/ci-operator/templates/openshift/openshift-ansible/cluster-launch-e2e-40.yaml +++ b/ci-operator/templates/openshift/openshift-ansible/cluster-launch-e2e-40.yaml @@ -387,6 +387,38 @@ objects: export PATH=$PATH:/tmp/shared echo "Gathering artifacts ..." + if [ -f /tmp/artifacts/installer/terraform.tfstate ]; then + # we don't have jq, so the python equivalent of + # jq '.modules[].resources."aws_instance.bootstrap".primary.attributes."public_ip" | select(.)' + bootstrap_ip=$(python -c \ + 'import sys, json; d=reduce(lambda x,y: dict(x.items() + y.items()), map(lambda x: x["resources"], json.load(sys.stdin)["modules"])); k="aws_instance.bootstrap"; print d[k]["primary"]["attributes"]["public_ip"] if k in d else ""' \ + < /tmp/artifacts/installer/terraform.tfstate + ) + + if [ -n "${bootstrap_ip}" ]; then + for service in bootkube openshift kubelet crio + do + queue "/tmp/artifacts/bootstrap/${service}.service" curl \ + --insecure \ + --silent \ + --connect-timeout 5 \ + --retry 3 \ + --cert /tmp/artifacts/installer/tls/journal-gatewayd.crt \ + --key /tmp/artifacts/installer/tls/journal-gatewayd.key \ + --url "https://${bootstrap_ip}:19531/entries?_SYSTEMD_UNIT=${service}.service" + done + if ! whoami &> /dev/null; then + if [ -w /etc/passwd ]; then + echo "${USER_NAME:-default}:x:$(id -u):0:${USER_NAME:-default} user:${HOME}:/sbin/nologin" >> /etc/passwd + fi + fi + eval $(ssh-agent) + ssh-add /etc/openshift-installer/ssh-privatekey + ssh -A -o PreferredAuthentications=publickey -o StrictHostKeyChecking=false -o UserKnownHostsFile=/dev/null core@${bootstrap_ip} /bin/bash -x /usr/local/bin/installer-gather.sh + scp -o PreferredAuthentications=publickey -o StrictHostKeyChecking=false -o UserKnownHostsFile=/dev/null core@${bootstrap_ip}:log-bundle.tar.gz /tmp/artifacts/installer/bootstrap-logs.tar.gz + fi + fi + mkdir -p /tmp/artifacts/pods /tmp/artifacts/nodes /tmp/artifacts/metrics oc --insecure-skip-tls-verify --request-timeout=5s get nodes -o jsonpath --template '{range .items[*]}{.metadata.name}{"\n"}{end}' > /tmp/nodes