-
Notifications
You must be signed in to change notification settings - Fork 472
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small comments, otherwise looks good.
Interesting find!
extras/dgoss/dgoss
Outdated
@@ -66,6 +68,8 @@ run(){ | |||
esac | |||
|
|||
$CONTAINER_RUNTIME logs -f "$id" > "$tmp_dir/docker_output.log" 2>&1 & | |||
# There is a chance that the log will not be written, an empty line is added for mitigation. | |||
echo "" >> "$tmp_dir/docker_output.log" 2>&1 & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps touch
makes more sense here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will test and check this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have looked at it. touch
does not help. I think I have found an better and more transparent solution.
extras/dgoss/dgoss
Outdated
@@ -20,6 +20,8 @@ cleanup() { | |||
set +e | |||
{ kill "$log_pid" && wait "$log_pid"; } 2> /dev/null | |||
if [ -n "$CONTAINER_LOG_OUTPUT" ]; then | |||
info "Stopping container and copy log" | |||
$CONTAINER_RUNTIME stop -t 1 "$id" > /dev/null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the -t flag work consistently with podman or docker?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, this solution is elegant and clear.
Checklist
make test-all
(UNIX) passes. CI will also test thisDescription of change
I think this is a bug or a edge case. I used
podman
and always got an empty log file.Partly it is discribed: https://docs.podman.io/en/stable/markdown/podman-logs.1.html#follow-f
I'm not sure if it's related to this or a problem with the flushing of the pipe in the operating system.
If the container is stopped before removal and a second pipe is created, the log is written. The content of the second pipe does not arrive and is therefore presumably swallowed.
If I am set timeout to
0
($CONTAINER_RUNTIME stop -t 0 "$id" > /dev/null
) then the last log entry appears in the log file in the tmp directory, but is apparently written to late and not copied to the target file.