Skip to content

fix: miss remove temp file in createSnapshot#2900

Merged
crosbymichael merged 1 commit intocontainerd:masterfrom
Ace-Tang:fix_snapshot_remove
Jan 15, 2019
Merged

fix: miss remove temp file in createSnapshot#2900
crosbymichael merged 1 commit intocontainerd:masterfrom
Ace-Tang:fix_snapshot_remove

Conversation

@Ace-Tang
Copy link
Copy Markdown
Contributor

func foo() error {

defer func() {
    if err != nil {
	...
    }
}()
...
}

use defer func to do something when err not nil, if foo() not use
named error, err != nil can not catch all errors, since when err
re-defined in if condition, it is a new variable.

Signed-off-by: Ace-Tang [email protected]

```
func foo() error {

defer func() {
    if err != nil {
	...
    }
}()
...
}
```
use defer func to do something when err not nil, if foo() not use
named error, `err != nil` can not catch all errors, since when err
re-defined in if condition, it is a new variable.

Signed-off-by: Ace-Tang <[email protected]>
@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #2900 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2900      +/-   ##
==========================================
- Coverage   43.89%   43.89%   -0.01%     
==========================================
  Files         101      101              
  Lines       10800    10799       -1     
==========================================
- Hits         4741     4740       -1     
  Misses       5328     5328              
  Partials      731      731
Flag Coverage Δ
#linux 47.49% <100%> (-0.01%) ⬇️
#windows 41.07% <0%> (ø) ⬆️
Impacted Files Coverage Δ
snapshots/overlay/overlay.go 52.52% <100%> (ø) ⬆️
snapshots/native/native.go 43.04% <100%> (-0.26%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 47b328a...7faaa64. Read the comment docs.

return cleanup, nil
}

func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, key, parent string, opts []snapshots.Opt) ([]mount.Mount, error) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you point out the branches which are not getting cleaned up correctly because of this? The block from line 398 seems to have redeclared err.

Copy link
Copy Markdown
Contributor Author

@Ace-Tang Ace-Tang Jan 3, 2019

Choose a reason for hiding this comment

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

Yes, the line 399(https://github.com/containerd/containerd/pull/2900/files#diff-adfa4892be9b7d1d353e8eba2cd335d6L399) and line 406 (https://github.com/containerd/containerd/pull/2900/files#diff-adfa4892be9b7d1d353e8eba2cd335d6L406) has new defined err, but this part code always good.
I found the problem when I implement a new snapshotter qcow2 for kata runtime, I re-use lots of overlay code , in debug process, found many uncleaned tmp snapshot directory like

$ sudo ls /var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots
1  11  14  7  new-888620822

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

My only concern was previously it required a very explicit setting of err to hit the cleanup section, but I don't see a code path which doesn't expect this block to run. So looks good to have that as the default behavior

@dmcgowan
Copy link
Copy Markdown
Member

LGTM

Copy link
Copy Markdown
Member

@fuweid fuweid left a comment

Choose a reason for hiding this comment

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

LGTM

@crosbymichael crosbymichael merged commit 96f306e into containerd:master Jan 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants