-
Notifications
You must be signed in to change notification settings - Fork 38.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Federation] Create a script that dumps Federation pod logs after e2e test failures #43028
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2017 The Kubernetes 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. | ||
|
||
# Call this to dump all Federation pod logs into the folder specified in $1 | ||
# (defaults to _artifacts). | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
# For FEDERATION_NAMESPACE | ||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../.. | ||
source "${KUBE_ROOT}/federation/cluster/common.sh" | ||
|
||
readonly REPORT_DIR="${1:-_artifacts}" | ||
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)) | ||
for pod_name in ${federation_pod_names[@]}; do | ||
# The API server pod has two containers | ||
if [[ "${pod_name}" == *apiserver* ]]; then | ||
dump_apiserver_pod_logs "${pod_name}" | ||
continue | ||
fi | ||
|
||
kubectl logs "${pod_name}" --namespace="${FEDERATION_NAMESPACE}" \ | ||
>"${OUTPUT_DIR}/${pod_name#pod/}.log" | ||
done | ||
} | ||
|
||
# Dumps logs from all containers in an API server pod. | ||
# Arguments: | ||
# - the name of the API server pod, with a pod/ prefix. | ||
function dump_apiserver_pod_logs() { | ||
local -r apiserver_pod_containers=(apiserver etcd) | ||
for container in ${apiserver_pod_containers[@]}; do | ||
kubectl logs "${1}" -c "${container}" --namespace="${FEDERATION_NAMESPACE}" \ | ||
>"${OUTPUT_DIR}/${1#pod/}-${container}.log" | ||
done | ||
} | ||
|
||
# Dumps logs from all containers in the DNS pods. | ||
# 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_containers=(kubedns dnsmasq sidecar) | ||
|
||
for pod_name in ${dns_pod_names[@]}; do | ||
# As of 3/2017, the only pod that matches the kube-dns label is kube-dns, and | ||
# it has three containers. | ||
for container in ${dns_pod_containers[@]}; do | ||
kubectl logs "${pod_name}" -c "${container}" --namespace=kube-system \ | ||
>"${OUTPUT_DIR}/${pod_name#pod/}-${container}.log" | ||
done | ||
done | ||
} | ||
|
||
|
||
echo "Dumping Federation and DNS pod logs to ${REPORT_DIR}" | ||
mkdir -p "${OUTPUT_DIR}" | ||
|
||
dump_federation_pod_logs | ||
dump_dns_pod_logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the following in logs:
Example run: http://prow.k8s.io/log?pod=pull-kubernetes-federation-e2e-gce-1583
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@perotinus could you please take a look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@madhusudancs @nikhiljindal Fixed by #44881.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@perotinus thanks!