Skip to content

Instantly share code, notes, and snippets.

@martinkennelly
Last active September 18, 2021 13:33
Show Gist options
  • Save martinkennelly/eafccda6d9c86c60a4575f3b11b26e85 to your computer and use it in GitHub Desktop.
Save martinkennelly/eafccda6d9c86c60a4575f3b11b26e85 to your computer and use it in GitHub Desktop.
#!/bin/bash
# output all ovn-kubernetes components logs to file from a must-gather output
# set --location flag to must-gather output location
set -eo pipefail
location=""
while true; do
case "$1" in
-l|--location)
location="$2"
break;;
--)
break;;
*)
printf "unknown option %s\nset --location flag to path of must-gather output\n" "$1"
exit 1;
esac
done
if ! command -v omg &>/dev/null; then
echo "omg not found. installing..."
pip3 install o-must-gather --user
fi
omg use "${location}"
WORK_DIR="$(mktemp -d -t omg-ovn-k-XXXXX)"
echo "work directory $WORK_DIR"
omg get pods -n openshift-ovn-kubernetes | awk '{print $1}' | while read line ; do
if [[ "$line" =~ "master" ]]; then
for component in "ovnkube-master" "northd" "kube-rbac-proxy" "nbdb" "sbdb" "ovn-dbchecker"; do
omg logs "$line" -n openshift-ovn-kubernetes -c $component > "$WORK_DIR/$line-$component.log"
done
continue
fi
if [[ "$line" =~ "node" ]]; then
for component in "ovn-controller" "ovn-acl-logging" "kube-rbac-proxy" "ovnkube-node"; do
omg logs "$line" -n openshift-ovn-kubernetes -c $component > "$WORK_DIR/$line-$component.log"
done
fi
done
echo "done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment