Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docker/mongodb-agent/setup-agent-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ SCRIPTS_DIR="/opt/scripts"
# readiness always returns failure
setup_dummy_probes() {
echo "Setting up dummy probe scripts..."
cp /usr/local/bin/dummy-probe.sh "$SCRIPTS_DIR/probe.sh"
cp /usr/local/bin/dummy-readinessprobe "$SCRIPTS_DIR/readinessprobe"
cp --remove-destination /usr/local/bin/dummy-probe.sh "$SCRIPTS_DIR/probe.sh"
cp --remove-destination /usr/local/bin/dummy-readinessprobe "$SCRIPTS_DIR/readinessprobe"
echo "Dummy probe scripts ready"
}

Expand Down
29 changes: 13 additions & 16 deletions scripts/evergreen/e2e/dump_diagnostic_information.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,29 +126,26 @@ dump_pod_logs() {
kubectl cp "${namespace}/${pod}:/var/log/mongodb-mms-automation/automation-agent.log" "logs/${prefix}${pod}-agent.log" &> /dev/null
kubectl cp "${namespace}/${pod}:/var/log/mongodb-mms-automation/monitoring-agent-verbose.log" "logs/${prefix}${pod}-monitoring-agent-verbose.log" &> /dev/null
kubectl cp "${namespace}/${pod}:/var/log/mongodb-mms-automation/monitoring-agent.log" "logs/${prefix}${pod}-monitoring-agent.log" &> /dev/null
kubectl logs -n "${namespace}" "${pod}" -c "mongodb-agent-monitoring" > "logs/${prefix}${pod}-monitoring-agent-stdout.log" || true
kubectl logs -n "${namespace}" "${pod}" -c "mongod" > "logs/${prefix}${pod}-mongod-container.log" || true
kubectl logs -n "${namespace}" "${pod}" -c "mongodb-agent" > "logs/${prefix}${pod}-mongodb-agent-container.log" || true
kubectl cp "${namespace}/${pod}:/var/log/mongodb-mms-automation/mongodb.log" "logs/${prefix}${pod}-mongodb.log" &> /dev/null || true

# note that this file may get empty if the logs have already grew too much - seems it's better to have it explicitly empty then just omit
kubectl logs -n "${namespace}" "${pod}" | jq -c -r 'select( .logType == "agent-launcher-script") | .contents' 2> /dev/null > "logs/${prefix}${pod}-launcher.log"
else
# for all other pods we want each log per container from kubectl
for container in $(kubectl get pods -n "${namespace}" "${pod}" -o jsonpath='{.spec.containers[*].name}'); do
echo "Writing log file for pod ${pod} - container ${container} to logs/${pod}-${container}.log"
kubectl logs -n "${namespace}" "${pod}" -c "${container}" > "logs/${pod}-${container}.log"
fi

# Check if the container has restarted by examining its restart count
restartCount=$(kubectl get pod -n "${namespace}" "${pod}" -o jsonpath="{.status.containerStatuses[?(@.name=='${container}')].restartCount}")
for container in $(kubectl get pods -n "${namespace}" "${pod}" -o jsonpath='{.spec.containers[*].name}'); do
echo "Writing log file for pod ${pod} - container ${container} to logs/${pod}-${container}.log"
kubectl logs -n "${namespace}" "${pod}" -c "${container}" > "logs/${pod}-${container}.log"

if [ "${restartCount}" -gt 0 ]; then
echo "Writing log file for restarted ${pod} - container ${container} to logs/${pod}-${container}-previous.log"
kubectl logs --previous -n "${namespace}" "${pod}" -c "${container}" > "logs/${pod}-${container}-previous.log" || true
fi
# Check if the container has restarted by examining its restart count
restartCount=$(kubectl get pod -n "${namespace}" "${pod}" -o jsonpath="{.status.containerStatuses[?(@.name=='${container}')].restartCount}")

if [ "${restartCount}" -gt 0 ]; then
echo "Writing log file for restarted ${pod} - container ${container} to logs/${pod}-${container}-previous.log"
kubectl logs --previous -n "${namespace}" "${pod}" -c "${container}" > "logs/${pod}-${container}-previous.log" || true
fi

done

done
fi

if kubectl exec "${pod}" -n "${namespace}" -- ls /var/log/mongodb-mms-automation/automation-agent-stderr.log &>/dev/null; then
kubectl cp "${namespace}/${pod}:/var/log/mongodb-mms-automation/automation-agent-stderr.log" "logs/${prefix}${pod}-agent-stderr.log" &> /dev/null
Expand Down