From 7e15b924e76ee33dd17385b329d2ad69ca313af1 Mon Sep 17 00:00:00 2001 From: Jonathan MacMillan Date: Mon, 24 Apr 2017 14:12:03 -0700 Subject: [PATCH] [Federation] Only attempt to log information about pods in federation/cluster/log-dump.sh if those pods exist. --- federation/cluster/log-dump.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/federation/cluster/log-dump.sh b/federation/cluster/log-dump.sh index 3b5a669921a..45e0e2a176f 100755 --- a/federation/cluster/log-dump.sh +++ b/federation/cluster/log-dump.sh @@ -30,7 +30,12 @@ OUTPUT_DIR="${REPORT_DIR}/federation" # Dumps logs for all pods in a federation. function dump_federation_pod_logs() { - local -r federation_pod_names=($(kubectl get pods -l 'app=federated-cluster' --namespace=${FEDERATION_NAMESPACE} -o name)) + local -r federation_pod_names_string="$(kubectl get pods -l 'app=federated-cluster' --namespace=${FEDERATION_NAMESPACE} -o name)" + if [[ -z "${federation_pod_names_string}" ]]; then + return + fi + + local -r federation_pod_names=(${federation_pod_names_string}) for pod_name in ${federation_pod_names[@]}; do # The API server pod has two containers if [[ "${pod_name}" == *apiserver* ]]; then @@ -58,7 +63,12 @@ function dump_apiserver_pod_logs() { # TODO: This currently only grabs DNS pod logs from the host cluster. It should # grab those logs from all clusters in the federation. function dump_dns_pod_logs() { - local -r dns_pod_names=($(kubectl get pods -l 'k8s-app=kube-dns' --namespace=kube-system -o name)) + local -r dns_pod_names_string="$(kubectl get pods -l 'k8s-app=kube-dns' --namespace=kube-system -o name)" + if [[ -z "${dns_pod_names_string}" ]]; then + return + fi + + local -r dns_pod_names=(${dns_pod_names_string}) local -r dns_pod_containers=(kubedns dnsmasq sidecar) for pod_name in ${dns_pod_names[@]}; do