Skip to content

rootfs: fix the error handling of the snapshotter.Commit#5196

Merged
estesp merged 1 commit intocontainerd:masterfrom
Iceber:fix-rootfs
Mar 15, 2021
Merged

rootfs: fix the error handling of the snapshotter.Commit#5196
estesp merged 1 commit intocontainerd:masterfrom
Iceber:fix-rootfs

Conversation

@Iceber
Copy link
Copy Markdown
Member

@Iceber Iceber commented Mar 15, 2021

If the snapshotter.Commit return an error, then the snapshotter.Remove should also be called.

containerd/rootfs/init.go

Lines 112 to 117 in 6b410ba

if err := snapshotter.Commit(ctx, initS, td); err != nil {
return "", err
}
return initS, nil
}

defer func() {
if err != nil {
if rerr := snapshotter.Remove(ctx, td); rerr != nil {
log.G(ctx).Errorf("Failed to remove snapshot %s: %v", td, rerr)
}
}
}()

@dmcgowan @dnephin PTAL. Thanks

@k8s-ci-robot
Copy link
Copy Markdown

Hi @Iceber. Thanks for your PR.

I'm waiting for a containerd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Mar 15, 2021

Build succeeded.

@AkihiroSuda
Copy link
Copy Markdown
Member

/ok-to-test

Comment thread rootfs/init.go Outdated
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.

I prefer to use named return var, like

func createInitLayer(ctx context.Context, parent, initName string, initFn func(string) error, snapshotter snapshots.Snapshotter, mounter Mounter) (_ string, retErr error) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, I agree.

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Mar 15, 2021

Build succeeded.

@Iceber Iceber requested a review from fuweid March 15, 2021 08:00
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

Copy link
Copy Markdown
Member

@estesp estesp left a comment

Choose a reason for hiding this comment

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

LGTM

@estesp estesp merged commit 5461fa3 into containerd:master Mar 15, 2021
@Iceber Iceber deleted the fix-rootfs branch March 15, 2021 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants