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

Storage can remove ErrNotAContainer as well #11787

Merged
merged 1 commit into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libpod/runtime_cstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (r *Runtime) removeStorageContainer(idOrName string, force bool) error {
}

if err := r.store.DeleteContainer(ctr.ID); err != nil {
if errors.Cause(err) == storage.ErrContainerUnknown {
if errors.Cause(err) == storage.ErrNotAContainer || errors.Cause(err) == storage.ErrContainerUnknown {
// Container again gone, no error
logrus.Infof("Storage for container %s already removed", ctr.ID)
return nil
Expand Down
8 changes: 6 additions & 2 deletions libpod/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,12 @@ func (r *storageService) DeleteContainer(idOrName string) error {
}
err = r.store.DeleteContainer(container.ID)
if err != nil {
logrus.Debugf("Failed to delete container %q: %v", container.ID, err)
return err
if errors.Cause(err) == storage.ErrNotAContainer || errors.Cause(err) == storage.ErrContainerUnknown {
Copy link
Member

Choose a reason for hiding this comment

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

What does ErrNotAContainer mean? Is the ID present in c/storage, but not as a container? That points to a potential bug to me - why is that exact 256-bit random ID still in use?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think at times, we attempt to remove a layer as opposed to a container, and call DeleteContainer with the id.

Copy link
Member

Choose a reason for hiding this comment

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

@mheon Looking at the code https://github.com/containers/storage/blob/65e6ab3cdc1ea69c8a55039dc668ee3844255a92/store.go#L2449-L2532 it means that the container id does not exists, it does not mean that the id exists as image or layer.

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough.

logrus.Infof("Storage for container %s already removed", container.ID)
} else {
logrus.Debugf("Failed to delete container %q: %v", container.ID, err)
return err
}
}
return nil
}
Expand Down