mirror of
https://github.com/clearlinux/docker.git
synced 2026-08-20 20:56:42 +00:00
Delete corresponding Devices when deleting Images
If an image is deleted and there is a corresponding device for that image we also delete the image.
This commit is contained in:
committed by
Tianon Gravi
parent
30890c7763
commit
99393cf3cf
+13
@@ -291,6 +291,19 @@ func (runtime *Runtime) Destroy(container *Container) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (runtime *Runtime) DeleteImage(id string) error {
|
||||
err := runtime.graph.Delete(id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if runtime.GetMountMethod() == MountMethodDeviceMapper && runtime.deviceSet.HasDevice(id) {
|
||||
if err := runtime.deviceSet.RemoveDevice(id); err != nil {
|
||||
return fmt.Errorf("Unable to remove device for %v: %v", id, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (runtime *Runtime) restore() error {
|
||||
wheel := "-\\|/"
|
||||
if os.Getenv("DEBUG") == "" && os.Getenv("TEST") == "" {
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ func cleanup(runtime *Runtime) error {
|
||||
}
|
||||
for _, image := range images {
|
||||
if image.ID != unitTestImageID {
|
||||
runtime.graph.Delete(image.ID)
|
||||
runtime.DeleteImage(image.ID)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -1025,7 +1025,7 @@ func (srv *Server) deleteImageAndChildren(id string, imgs *[]APIRmi) error {
|
||||
if err := srv.runtime.repositories.DeleteAll(id); err != nil {
|
||||
return err
|
||||
}
|
||||
err := srv.runtime.graph.Delete(id)
|
||||
err := srv.runtime.DeleteImage(id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1099,7 +1099,7 @@ func (srv *Server) ImageDelete(name string, autoPrune bool) ([]APIRmi, error) {
|
||||
return nil, fmt.Errorf("No such image: %s", name)
|
||||
}
|
||||
if !autoPrune {
|
||||
if err := srv.runtime.graph.Delete(img.ID); err != nil {
|
||||
if err := srv.runtime.DeleteImage(img.ID); err != nil {
|
||||
return nil, fmt.Errorf("Error deleting image %s: %s", name, err)
|
||||
}
|
||||
return nil, nil
|
||||
|
||||
Reference in New Issue
Block a user