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

bugfix: use same memory in ringbuffer #2268

Merged
merged 1 commit into from
Sep 21, 2018
Merged

bugfix: use same memory in ringbuffer #2268

merged 1 commit into from
Sep 21, 2018

Conversation

fuweid
Copy link
Contributor

@fuweid fuweid commented Sep 21, 2018

Signed-off-by: Wei Fu fuweid89@gmail.com

Ⅰ. Describe what this PR did

ContainerIO' backend will read data into ringbuffer. But the data blocks
use the same memory so that the comming data will override the previous
one.

Ⅱ. Does this pull request fix one issue?

When the input is too long, ContainerIO will separate one line into two data blocks. But the blocks shares the same memory, the new one will override the old one, like

# vagrant @ ubuntu-xenial in ~/go/src/github.com/alibaba/pouch/test on git:bugfix_conflict_data_in_ringbuffer o [14:51:15]
$ sudo pouch run -d busybox:1.28 sleep 10000
08921f5002032b14763eceb90ad4bbbfb25a352e819c9c0ba1aaab54bb68b5bf

# vagrant @ ubuntu-xenial in ~/go/src/github.com/alibaba/pouch/test on git:bugfix_conflict_data_in_ringbuffer o [14:51:21]
$ sudo pouch exec -i 08921f5002032b14763eceb90ad4bbbfb25a352e819c9c0ba1aaab54bb68b5bf sh
ksjfjdsfjklsdjkfljsdkljfklsjfjsdjfjskjfksfjdksjfjsjdfjksjfkjskdjfkjsdkfjksdjfkjskdjfksdjkfjsdkfjksdjfkjsdkfjksdjfkjsdkfjsdfjsk
sh: ksjfjdsfjklsdjkfljsdkljfklsjfjsdjfjskjfksfjdksjfjsjdfjksjfkjskdjfkjsdkfjksdjfkjskdjfksdjkfjsdkfjksdjfkjsdkfjksdjfkjsdkfjsdfjsk: not found
dkfjksjfsdkfjksjdkjfkjsdkfjkjdkjfkdsjffjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
sh: jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj: not found
sh: jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj: not found
exit

Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)

Added

Ⅳ. Describe how to verify it

input >128 chars

# vagrant @ ubuntu-xenial in ~/go/src/github.com/alibaba/pouch on git:bugfix_conflict_data_in_ringbuffer o [14:55:15]
$ sudo pouch exec -i 08921f5002032b14763eceb90ad4bbbfb25a352e819c9c0ba1aaab54bb68b5bf sh
dkfjksjfsdkfjksjdkjfkjsdkfjkjdkjfkdsjffjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
sh: dkfjksjfsdkfjksjdkjfkjsdkfjkjdkjfkdsjffjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj: not found
exit

Ⅴ. Special notes for reviews

I hate the pattern...

@codecov
Copy link

codecov bot commented Sep 21, 2018

Codecov Report

Merging #2268 into master will decrease coverage by 7.9%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2268      +/-   ##
==========================================
- Coverage   66.72%   58.81%   -7.91%     
==========================================
  Files         208      208              
  Lines       16926    17340     +414     
==========================================
- Hits        11294    10199    -1095     
- Misses       4267     5638    +1371     
- Partials     1365     1503     +138
Flag Coverage Δ
#criv1alpha1test 32.67% <100%> (+0.17%) ⬆️
#criv1alpha2test 36.15% <100%> (+0.18%) ⬆️
#integrationtest 39.55% <100%> (-0.04%) ⬇️
#nodee2etest 33.71% <0%> (+0.31%) ⬆️
#unittest ?
Impacted Files Coverage Δ
daemon/containerio/container_io.go 75.95% <100%> (+0.26%) ⬆️
apis/opts/sysctl.go 0% <0%> (-100%) ⬇️
apis/opts/shm_size.go 0% <0%> (-100%) ⬇️
apis/opts/memory.go 0% <0%> (-100%) ⬇️
apis/opts/memory_swap.go 0% <0%> (-100%) ⬇️
cri/stream/errors.go 0% <0%> (-100%) ⬇️
apis/opts/diskquota.go 0% <0%> (-87.5%) ⬇️
pkg/multierror/def.go 15.38% <0%> (-84.62%) ⬇️
apis/opts/portbindings.go 0% <0%> (-80.96%) ⬇️
apis/opts/restart_policy.go 0% <0%> (-78.13%) ⬇️
... and 69 more

@pouchrobot pouchrobot added kind/bug This is bug report for project size/M labels Sep 21, 2018
ContainerIO' backend will read data into ringbuffer. But the data blocks
use the same memory so that the comming data will override the previous
one. Need to copy data before push into ringbuffer.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
// If we don't copy the data and the previous data isn't consumed by
// ringbuf pop action, the incoming data will override the previous data
// in the ringbuf.
copyData := make([]byte, n)
Copy link
Contributor

Choose a reason for hiding this comment

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

From the comment, Copy make data not be override, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

Copy link
Contributor

Choose a reason for hiding this comment

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

More qeustion, as I do not know all ringbuf logic. The data will always append if pop not assume?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes. if the size reaches the capacity, ringbuffer will drop the old one.

@Ace-Tang
Copy link
Contributor

LGTM

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Sep 21, 2018
@YaoZengzeng
Copy link
Contributor

LGTM as well

@allencloud allencloud merged commit 7addef1 into AliyunContainerService:master Sep 21, 2018
@fuweid fuweid deleted the bugfix_conflict_data_in_ringbuffer branch September 25, 2018 02:00
@fuweid fuweid restored the bugfix_conflict_data_in_ringbuffer branch October 8, 2018 08:47
@fuweid fuweid deleted the bugfix_conflict_data_in_ringbuffer branch October 8, 2018 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug This is bug report for project LGTM one maintainer or community participant agrees to merge the pull reuqest. size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants