-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract log dumping into a callable workflow
- Loading branch information
Showing
2 changed files
with
55 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Dump logs | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
dump-logs: | ||
name: Dump logs | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Dump debug log | ||
if: failure() | ||
run: | | ||
for ctl in $(juju controllers --format json | jq -r '.controllers | keys[]'); do for mdl in $(juju models --format json | jq -r '.models[].name' | grep -v "admin/controller"); do juju debug-log -m $ctl:$mdl --replay --ms --no-tail; done; done || true | ||
exit 0 | ||
shell: bash | ||
- name: Dump pods and their logs | ||
if: failure() | ||
shell: bash | ||
run: | | ||
juju status --relations --storage | ||
kubectl get pods \ | ||
-A \ | ||
-o=jsonpath='{range.items[*]}{.metadata.namespace} {.metadata.name}{"\n"}' \ | ||
--sort-by=.metadata.namespace \ | ||
| grep -v "^\s*$" \ | ||
| while read namespace pod; do \ | ||
kubectl -n $namespace describe pod $pod; \ | ||
kubectl -n $namespace logs $pod \ | ||
--all-containers=true \ | ||
--tail=100; \ | ||
done | ||
- name: Dump deployments | ||
if: failure() | ||
run: | | ||
kubectl describe deployments -A | ||
exit 0 | ||
- name: Dump replicasets | ||
if: failure() | ||
run: | | ||
kubectl describe replicasets -A | ||
exit 0 | ||
- name: Dump node information | ||
if: failure() | ||
run: | | ||
kubectl get nodes -v=10 | ||
exit 0 | ||
- name: Dump charmcraft logs | ||
if: failure() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: charmcraft-logs | ||
path: ~/.local/state/charmcraft/log/*.log |
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