-
Notifications
You must be signed in to change notification settings - Fork 441
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: print all the previous logs for restarted pods (#4081)
Signed-off-by: zhangzujian <zhangzujian.7@gmail.com>
- Loading branch information
1 parent
f271a54
commit d2e3bf6
Showing
3 changed files
with
88 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
namespace="kube-system" | ||
|
||
exit_code=0 | ||
# check if there are any crashed pods | ||
for pod in `kubectl get pod -n $namespace -l component=network -o name`; do | ||
restartCount=`kubectl get -n $namespace $pod -o jsonpath='{.status.containerStatuses[0].restartCount}'` | ||
# TODO: get restart count for all containers | ||
if [ $restartCount -gt 0 ]; then | ||
exit_code=1 | ||
echo "$pod restarted $restartCount time(s). Logs of the previous instance:" | ||
kubectl logs -p -n $namespace $pod | ||
fi | ||
done | ||
|
||
exit $exit_code |