Skip to content

Commit

Permalink
chore: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg O'Grady committed Nov 13, 2024
1 parent e5b3fe9 commit a526ac4
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/jobs/e2e/collect-e2e-logs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ steps:
echo "Contents of << parameters.env-name-path >>:"
cat << parameters.env-name-path >>
if [ -f << parameters.env-name-path >> ] && [ "$(cat << parameters.env-name-path >> )" != "null" ]; then
DEV_ENV_NAME=$(cat << parameters.env-name-path >> )
else
DEV_ENV_NAME=<< parameters.e2e-env-name >>
fi
DEV_ENV_NAME=$(cat << parameters.env-name-path >> )
else
DEV_ENV_NAME=<< parameters.e2e-env-name >>
fi
# Gather summary state of all pods in the namespace
echo "Gathering Kubernetes state before run for env $DEV_ENV_NAME"
kubectl get pods -n $DEV_ENV_NAME >> "${LOG_DIR:?}/${KUBE_STATE_DIR:?}/pods-summary-state-before-run.log"
Expand All @@ -59,8 +59,8 @@ steps:
background: true
command: |
function capture_logs() {
if [ -f << parameters.env-name-path >> ] && [ "$(cat << parameters.env-name-path >> )" != "null" ]; then
DEV_ENV_NAME=$(cat << parameters.env-name-path >> )
if [ -f << parameters.env-name-path >> ] && [ "$(cat << parameters.env-name-path >>)" != "null" ]; then
DEV_ENV_NAME=$(cat << parameters.env-name-path >>)
else
DEV_ENV_NAME=<< parameters.e2e-env-name >>
fi
Expand All @@ -71,13 +71,13 @@ steps:
for ((i = 0; i < ${#components[@]} - 1; i++)); do
component=${components[$i]}
echo "Capturing logs for component $component"
stern -n "${DEV_ENV_NAME:?}" -l "app.kubernetes.io/name=$component" >>"${LOG_DIR:?}/${COMPONENT_LOG_DIR:?}/$component.log" --since 5m &
stern -n "${DEV_ENV_NAME:?}" -l "app.kubernetes.io/name=$component" --since 5m >>"${LOG_DIR:?}/${COMPONENT_LOG_DIR:?}/$component.log" &
done
# Handle the last component separately to introduce blocking.If all components' log collection is done as non blocking tasks,
# the circleci step will terminate.So having last component as blocking ensures the collect logs step continues executing
last_component=${components[${#components[@]}-1]}
last_component=${components[${#components[@]} - 1]}
echo "Capturing logs for last component $last_component"
stern -n "${DEV_ENV_NAME:?}" -l "app.kubernetes.io/name=$last_component" >>"${LOG_DIR:?}/${COMPONENT_LOG_DIR:?}/$last_component.log" --since 5m
stern -n "${DEV_ENV_NAME:?}" -l "app.kubernetes.io/name=$last_component" --since 5m >>"${LOG_DIR:?}/${COMPONENT_LOG_DIR:?}/$last_component.log"
}
capture_logs
Expand Down Expand Up @@ -118,21 +118,21 @@ steps:
LOG_DIR: *log_dir
KUBE_STATE_DIR: *kube_state_dir
command: |
if [ -f << parameters.env-name-path >> ] && [ "$(cat << parameters.env-name-path >> )" != "null" ]; then
DEV_ENV_NAME=$(cat << parameters.env-name-path >> )
else
DEV_ENV_NAME=<< parameters.e2e-env-name >>
fi
if [ -f << parameters.env-name-path >> ] && [ "$(cat << parameters.env-name-path >>)" != "null" ]; then
DEV_ENV_NAME=$(cat << parameters.env-name-path >>)
else
DEV_ENV_NAME=<< parameters.e2e-env-name >>
fi
# Read components into an array directly from the command output
components=($(vfcli component list -n "${DEV_ENV_NAME:?}" | awk 'NR>3 {print $1}'))
# Gather summary state of all pods in the namespace
kubectl get pods -n $DEV_ENV_NAME >> "${LOG_DIR:?}/${KUBE_STATE_DIR:?}/pods-summary-state-after-run.log"
kubectl get pods -n $DEV_ENV_NAME >>"${LOG_DIR:?}/${KUBE_STATE_DIR:?}/pods-summary-state-after-run.log"
# Gather detailed state of all pods in the namespace.
for $component in $components; do
echo "Capturing logs for component $component"
kubectl describe pod $component -n $DEV_ENV_NAME >> "${LOG_DIR:?}/${KUBE_STATE_DIR:?}/${component}-k8-state.log" &
done
wait
kubectl describe pod $component -n $DEV_ENV_NAME >>"${LOG_DIR:?}/${KUBE_STATE_DIR:?}/${component}-k8-state.log" &
done
wait
- run:
name: Gather Kubernetes events
environment:
Expand Down

0 comments on commit a526ac4

Please sign in to comment.