Skip to content

Volume QA, "volume remove" (fixes and tests)#3125

Merged
AkihiroSuda merged 1 commit intocontainerd:mainfrom
apostasie:dev-qa-volume
Jun 20, 2024
Merged

Volume QA, "volume remove" (fixes and tests)#3125
AkihiroSuda merged 1 commit intocontainerd:mainfrom
apostasie:dev-qa-volume

Conversation

@apostasie
Copy link
Copy Markdown
Contributor

This fixes #3124 and a few other discrepancies between docker and nerdctl.

This also expands testing significantly.

Outside of the tests, I will comment inline as to "why" certain changes.

Comment thread pkg/cmd/volume/rm.go

var volumenames []string // nolint: prealloc
for _, name := range volumes {
volume, err := volStore.Get(name, false)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This section serves no purpose, and does make things racy.

Comment thread pkg/cmd/volume/rm.go Outdated
}
removedNames, err := volStore.Remove(volumenames)
// if err is set, this is a hard filesystem error
removedNames, errs, err := volStore.Remove(volumenames)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note that on such a dramatic error (filesystem failure typically), we do not report whether and which volumes were (possibly) successfully removed.
I think it is fine - the only reason this would happen is if os.RemoveAll would err.

Comment thread pkg/cmd/volume/rm.go
if err != nil {
return err
}
// Otherwise, output on stdout whatever was successful
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This and following is to match docker behavior on multi remove:

  • first output the list of successfully removed volumes
  • then output the errors
  • exit 1 if there was any error

}

if err := lockutil.WithDirLock(vs.dir, fn); err != nil {
if err := lockutil.WithDirLock(vs.dir, fn); err != nil && !errors.Is(err, os.ErrExist) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This to match docker behavior.
Repeat "create" of the same volume should not error.

@apostasie apostasie marked this pull request as draft June 20, 2024 03:28
@apostasie apostasie marked this pull request as ready for review June 20, 2024 04:07
Comment thread pkg/mountutil/mountutilmock/volumestore.mock.go
@AkihiroSuda AkihiroSuda added this to the v2.0.0 milestone Jun 20, 2024
@apostasie
Copy link
Copy Markdown
Contributor Author

@AkihiroSuda CI is green and linter is happy.

Comment thread pkg/cmd/volume/rm.go Outdated
Comment thread pkg/mountutil/mountutilmock/volumestore.mock.go Outdated
Comment thread pkg/mountutil/volumestore/volumestore.go Outdated
Signed-off-by: apostasie <spam_blackhole@farcloser.world>
@apostasie
Copy link
Copy Markdown
Contributor Author

@AkihiroSuda your suggestion integrated in and pushed.

I am logging of now.

See you later.

Copy link
Copy Markdown
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Thanks

@AkihiroSuda AkihiroSuda merged commit 6430226 into containerd:main Jun 20, 2024
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.

docker vs. nerdctl: volume behavior differences

2 participants