Skip to content

Commit

Permalink
retry tail on crashed pods
Browse files Browse the repository at this point in the history
Hack / proof of concept fix for johanhaleby#67.

Wrap the follow of an individual pod in a "while true" loop to keep monitoring a pod after it crashes and restarts.

Probably breaks horribly if you try and use kubetail without follow.
  • Loading branch information
bryanlarsen committed Sep 28, 2018
1 parent 9ccb7c2 commit f4e7120
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kubetail
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ for pod in ${matching_pods[@]}; do
colored_line="${color_start}[${display_name}] \$line ${color_end}"
fi

kubectl_cmd="${KUBECTL_BIN} ${context:+--context=${context}} logs ${pod} ${container} -f=${follow} --since=${since} --tail=${tail} ${namespace_arg} ${cluster}"
kubectl_cmd="while true ; do ${KUBECTL_BIN} ${context:+--context=${context}} logs ${pod} ${container} -f=${follow} --since=${since} --tail=${tail} ${namespace_arg} ${cluster} ; sleep 1 ; done"
colorify_lines_cmd="while read line; do echo \"$colored_line\" | tail -n +1; done"
if [ "z" == "z$jq_selector" ]; then
logs_commands+=("${kubectl_cmd} ${timestamps} | ${colorify_lines_cmd}");
Expand Down

0 comments on commit f4e7120

Please sign in to comment.