Merge pull request #44881 from perotinus/nofedpodstolog

Automatic merge from submit-queue (batch tested with PRs 41287, 41636, 44881, 44826)

[Federation] Only attempt to log information about pods in federation/cluster/log-dump.sh if those pods exist.

Fixes an issue where the script fails, because bash considers an empty array an unbound variable.
**Release note**:
```release-note
NONE
```
This commit is contained in:
Kubernetes Submit Queue 2017-04-25 17:56:43 -07:00 committed by GitHub
commit 2d808b5925

View File

@ -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