diff --git a/src/jobs/e2e/collect-e2e-logs.yml b/src/jobs/e2e/collect-e2e-logs.yml index 8542b053..b4503776 100644 --- a/src/jobs/e2e/collect-e2e-logs.yml +++ b/src/jobs/e2e/collect-e2e-logs.yml @@ -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" @@ -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 @@ -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 @@ -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: