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 conmon attach socket buffer size #11503

Merged
merged 1 commit into from
Sep 9, 2021
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: 3 additions & 1 deletion libpod/oci_conmon_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ import (
const (
// This is Conmon's STDIO_BUF_SIZE. I don't believe we have access to it
// directly from the Go code, so const it here
bufferSize = conmonConfig.BufSize
// Important: The conmon attach socket uses an extra byte at the beginning of each
// message to specify the STREAM so we have to increase the buffer size by one
bufferSize = conmonConfig.BufSize + 1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to also use this constant in oci_attach_linux.go line 225?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but it is not worth to repush for this change, thanks for catching this.

)

// ConmonOCIRuntime is an OCI runtime managed by Conmon.
Expand Down
28 changes: 28 additions & 0 deletions test/system/075-exec.bats
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,32 @@ load helpers
run_podman rm $cid
}

# #11496: podman-remote loses output
@test "podman exec/run - missing output" {
local bigfile=${PODMAN_TMPDIR}/bigfile
local newfile=${PODMAN_TMPDIR}/newfile
# create a big file, bigger than the 8K buffer size
base64 /dev/urandom | head -c 20K > $bigfile

run_podman run --rm -v $bigfile:/tmp/test:Z $IMAGE cat /tmp/test
printf "%s" "$output" > $newfile
# use cmp to compare the files, this is very helpful since it will
# tell us the first wrong byte in case this fails
run cmp $bigfile $newfile
is "$output" "" "run output is identical with the file"

run_podman run -d --stop-timeout 0 -v $bigfile:/tmp/test:Z $IMAGE sleep inf
cid="$output"

run_podman exec $cid cat /tmp/test
printf "%s" "$output" > $newfile
# use cmp to compare the files, this is very helpful since it will
# tell us the first wrong byte in case this fails
run cmp $bigfile $newfile
is "$output" "" "exec output is identical with the file"

# Clean up
run_podman rm -f $cid
}

# vim: filetype=sh