Skip to content

Commit

Permalink
Extract log dumping into a callable workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
sed-i committed Mar 27, 2024
1 parent acb3ad6 commit e9dfc8c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 36 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/_charm-dump-logs.yaml
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
38 changes: 2 additions & 36 deletions .github/workflows/_charm-tests-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,40 +59,6 @@ jobs:
run: |
for m in $(juju models --format json | jq -r '.models[].name' | grep -v "admin/controller"); do juju debug-log -m $m --replay --ms --no-tail; done
exit 0
- name: Dump pods and their logs
- name: Dump logs
if: failure()
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
exit 0
- name: Dump node information
if: failure()
run: |
kubectl get nodes -v=10
exit 0
- 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 charmcraft logs
if: failure()
uses: actions/upload-artifact@v3
with:
name: charmcraft-logs
path: ~/.local/state/charmcraft/log/*.log
uses: canonical/observability/.github/workflows/_dump-logs.yaml@main

0 comments on commit e9dfc8c

Please sign in to comment.