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: populate volume error #2087

Merged

Conversation

shaloulcy
Copy link
Contributor

Signed-off-by: Eric Li lcy041536@gmail.com

Ⅰ. Describe what this PR did

fix populate volume error

Ⅱ. Does this pull request fix one issue?

fixed #2084

Ⅲ. Describe how you did it

copy directory through tar and untar

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@@ -0,0 +1,120 @@
package archive
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add unit-test for this package, thanks a lot!

func tarFromDir(src string, writer io.Writer) error {
// ensure the src actually exists before trying to tar it
if _, err := os.Stat(src); err != nil {
return fmt.Errorf("Unable to tar files - %v", err.Error())
Copy link
Collaborator

Choose a reason for hiding this comment

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

fmt.Errorf("failed to stat source file %s: %v", src, err)?

@codecov-io
Copy link

codecov-io commented Aug 14, 2018

Codecov Report

Merging #2087 into master will decrease coverage by 0.06%.
The diff coverage is 55.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2087      +/-   ##
==========================================
- Coverage   65.35%   65.29%   -0.07%     
==========================================
  Files         207      208       +1     
  Lines       16226    16292      +66     
==========================================
+ Hits        10605    10638      +33     
- Misses       4311     4330      +19     
- Partials     1310     1324      +14
Flag Coverage Δ
#criv1alpha1test 33.26% <0%> (-0.23%) ⬇️
#criv1alpha2test 33.94% <0%> (-0.16%) ⬇️
#integrationtest 40.04% <41.42%> (-0.03%) ⬇️
#unittest 24.02% <54.28%> (+0.14%) ⬆️
Impacted Files Coverage Δ
daemon/mgr/container_storage.go 49.23% <50%> (-0.26%) ⬇️
pkg/archive/archive.go 51.85% <51.85%> (ø)
pkg/utils/utils.go 84.3% <71.42%> (-1.15%) ⬇️
ctrd/image.go 77.19% <0%> (-1.76%) ⬇️
cri/v1alpha1/cri.go 64.04% <0%> (-0.18%) ⬇️
daemon/logger/jsonfile/utils.go 73.17% <0%> (+1.62%) ⬆️


// copy file data into tar writer
if _, err := io.Copy(tw, f); err != nil {
return err
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think before return err, we need to close the file, since it is already open. Otherwise there will be fd leak.

}

if _, err := io.Copy(f, tr); err != nil {
return err
Copy link
Collaborator

Choose a reason for hiding this comment

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

same issue.
I think before return err, we need to close the file, since it is already open. Otherwise there will be fd leak.

@shaloulcy shaloulcy force-pushed the bugfix_for_populate_volume branch from 166350f to 74bc39b Compare August 14, 2018 03:17
@shaloulcy
Copy link
Contributor Author

I have update the codes, PTAL

@allencloud allencloud dismissed their stale review August 14, 2018 05:53

change request has been covered

@shaloulcy shaloulcy force-pushed the bugfix_for_populate_volume branch from 74bc39b to 63e2be2 Compare August 14, 2018 09:32
@pouchrobot pouchrobot added size/XL and removed size/L labels Aug 14, 2018
Signed-off-by: Eric Li <lcy041536@gmail.com>
@shaloulcy shaloulcy force-pushed the bugfix_for_populate_volume branch from 63e2be2 to c2186ef Compare August 14, 2018 11:42
@allencloud
Copy link
Collaborator

LGTM

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Aug 14, 2018
@allencloud allencloud merged commit 25a45e1 into AliyunContainerService:master Aug 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
areas/storage LGTM one maintainer or community participant agrees to merge the pull reuqest. size/XL volume
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug] failed to populate volumes: exit status 1
5 participants