Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dgoss): edgecase where no log is written #997

Merged
merged 4 commits into from
Nov 21, 2024
Merged
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
10 changes: 9 additions & 1 deletion extras/dgoss/dgoss
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ error() {

cleanup() {
set +e
# There is a chance that the log will not be written completely.
# Exit the container and retrieve the last line of logs to ensure
# that all logs have been read.
info "Stopping container"
$CONTAINER_RUNTIME stop --time 1 "$id" > /dev/null 2>&1
$CONTAINER_RUNTIME logs --tail 1 "$id" > /dev/null 2>&1

{ kill "$log_pid" && wait "$log_pid"; } 2> /dev/null
if [ -n "$CONTAINER_LOG_OUTPUT" ]; then
info "Copying log"
cp "$tmp_dir/docker_output.log" "$CONTAINER_LOG_OUTPUT"
fi
[ "$DEBUG" ] || rm -rf "$tmp_dir"
if [[ $id ]];then
if [[ $id ]]; then
info "Deleting container"
$CONTAINER_RUNTIME rm -vf "$id" > /dev/null
fi
Expand Down