generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 949
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
add juicefs diagnose script and fix alluxio diagnose script #2156
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
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
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
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,154 @@ | ||
#!/usr/bin/env bash | ||
set +x | ||
|
||
print_usage() { | ||
echo "Usage:" | ||
echo " ./diagnose-fluid-juicefs.sh COMMAND [OPTIONS]" | ||
echo "COMMAND:" | ||
echo " help" | ||
echo " Display this help message." | ||
echo " collect" | ||
echo " Collect pods logs of controller and runtime." | ||
echo "OPTIONS:" | ||
echo " -r, --name name" | ||
echo " Set the name of runtime." | ||
echo " -n, --namespace name" | ||
echo " Set the namespace of runtime." | ||
} | ||
|
||
run() { | ||
echo | ||
echo "-----------------run $*------------------" | ||
timeout 10s "$@" | ||
if [ $? != 0 ]; then | ||
echo "failed to collect info: $*" | ||
fi | ||
echo "------------End of ${1}----------------" | ||
} | ||
|
||
helm_get() { | ||
run helm get all -n ${runtime_namespace} "${1}" &>"$diagnose_dir/helm-${1}.yaml" | ||
} | ||
|
||
pod_status() { | ||
local namespace=${1:-"default"} | ||
run kubectl get po -owide -n ${namespace} &>"$diagnose_dir/pods-${namespace}.log" | ||
} | ||
|
||
fluid_pod_logs() { | ||
core_component "${fluid_namespace}" "manager" "control-plane=juicefsruntime-controller" | ||
core_component "${fluid_namespace}" "manager" "control-plane=dataset-controller" | ||
core_component "${fluid_namespace}" "plugins" "app=csi-nodeplugin-fluid" | ||
core_component "${fluid_namespace}" "node-driver-registrar" "app=csi-nodeplugin-fluid" | ||
} | ||
|
||
runtime_pod_logs() { | ||
core_component "${runtime_namespace}" "juicefs-worker" "role=juicefs-worker" "release=${runtime_name}" | ||
core_component "${runtime_namespace}" "juicefs-fuse" "role=juicefs-fuse" "release=${runtime_name}" | ||
} | ||
|
||
core_component() { | ||
# namespace container selectors... | ||
local namespace="$1" | ||
local container="$2" | ||
shift 2 | ||
local selectors="$*" | ||
local constrains | ||
local pods | ||
constrains=$(echo "${selectors}" | tr ' ' ',') | ||
if [[ -n ${constrains} ]]; then | ||
constrains="-l ${constrains}" | ||
fi | ||
mkdir -p "$diagnose_dir/pods-${namespace}" | ||
pods=$(kubectl get po -n ${namespace} "${constrains}" | awk '{print $1}' | grep -v NAME) | ||
for po in ${pods}; do | ||
kubectl logs "${po}" -c "$container" -n ${namespace} &>"$diagnose_dir/pods-${namespace}/${po}-${container}.log" 2>&1 | ||
done | ||
} | ||
|
||
kubectl_resource() { | ||
# runtime, dataset, pv and pvc should have the same name | ||
kubectl describe dataset --namespace ${runtime_namespace} ${runtime_name} &>"${diagnose_dir}/dataset-${runtime_name}.yaml" 2>&1 | ||
kubectl describe juicefsruntime --namespace ${runtime_namespace} ${name} &>"${diagnose_dir}/juicefsruntime-${runtime_name}.yaml" 2>&1 | ||
kubectl describe pv ${runtime_namespace}-${runtime_name} &>"${diagnose_dir}/pv-${runtime_name}.yaml" 2>&1 | ||
kubectl describe pvc ${runtime_name} --namespace ${runtime_namespace} &>"${diagnose_dir}/pvc-${runtime_name}.yaml" 2>&1 | ||
} | ||
|
||
archive() { | ||
tar -zcvf "${current_dir}/diagnose_fluid_${timestamp}.tar.gz" "${diagnose_dir}" | ||
echo "please get diagnose_fluid_${timestamp}.tar.gz for diagnostics" | ||
} | ||
|
||
pd_collect() { | ||
echo "Start collecting, runtime-name=${runtime_name}, runtime-namespace=${runtime_namespace}" | ||
helm_get "${fluid_name}" | ||
helm_get "${runtime_name}" | ||
pod_status "${fluid_namespace}" | ||
pod_status "${runtime_namespace}" | ||
runtime_pod_logs | ||
fluid_pod_logs | ||
kubectl_resource | ||
archive | ||
} | ||
|
||
collect() | ||
{ | ||
# ensure params | ||
fluid_name=${fluid_name:-"fluid"} | ||
fluid_namespace=${fluid_namespace:-"fluid-system"} | ||
runtime_name=${runtime_name:?"the name of runtime must be set"} | ||
runtime_namespace=${runtime_namespace:-"default"} | ||
|
||
current_dir=$(pwd) | ||
timestamp=$(date +%s) | ||
diagnose_dir="/tmp/diagnose_fluid_${timestamp}" | ||
mkdir -p "$diagnose_dir" | ||
|
||
pd_collect | ||
} | ||
|
||
main() { | ||
if [[ $# -eq 0 ]]; then | ||
print_usage | ||
exit 1 | ||
fi | ||
|
||
action="help" | ||
|
||
while [[ $# -gt 0 ]]; do | ||
case $1 in | ||
-h|--help|"-?") | ||
print_usage | ||
exit 0; | ||
;; | ||
collect|help) | ||
action=$1 | ||
;; | ||
-r|--name) | ||
runtime_name=$2 | ||
shift | ||
;; | ||
-n|--namespace) | ||
runtime_namespace=$2 | ||
shift | ||
;; | ||
*) | ||
echo "Error: unsupported option $1" >&2 | ||
print_usage | ||
exit 1 | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
case ${action} in | ||
collect) | ||
collect | ||
;; | ||
help) | ||
print_usage | ||
;; | ||
esac | ||
} | ||
|
||
main "$@" |
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 think it's better to rename diagnose-fluid.sh to diagnose-fluid-alluxio.sh.
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.
done