Skip to content

Commit

Permalink
gen3 logs snapshot: also get initContainers logs (#2478)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulineribeyre authored Feb 20, 2024
1 parent 1f8632f commit fe5b550
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions gen3/lib/logs/snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ gen3_logs_snapshot_container() {
# Snapshot all the pods
#
gen3_logs_snapshot_all() {
# For each pod for which we can list the containers, get the pod name and get its list of containers
# (container names + initContainers names). Diplay them as lines of "<pod name> <container name>".
g3kubectl get pods -o json | \
jq -r '.items | map(select(.status.phase != "Pending" and .status.phase != "Unknown")) | map( {pod: .metadata.name, containers: .spec.containers | map(.name) } ) | map( .pod as $pod | .containers | map( { pod: $pod, cont: .})[]) | map(select(.cont != "pause" and .cont != "jupyterhub"))[] | .pod + " " + .cont' | \
jq -r '.items | map(select(.status.phase != "Pending" and .status.phase != "Unknown")) | map( {pod: .metadata.name, containers: [(.spec.containers | select(.!=null) | map(.name)), (.spec.initContainers | select(.!=null) | map(.name)) | add ] } ) | map( .pod as $pod | .containers | map( { pod: $pod, cont: .})[]) | map(select(.cont != "pause" and .cont != "jupyterhub"))[] | .pod + " " + .cont' | \
while read -r line; do
gen3_logs_snapshot_container $line
done
}

0 comments on commit fe5b550

Please sign in to comment.