Avoid using lower-level storage APIs
Switch from using the lower-level storage APIs (accessing LayerStore, ImageStore, and ContainerStore types directly) in favor of the higher-level ones that take care of synchronization and locking for us. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
This commit is contained in:
parent
065960386f
commit
2e50006f1c
5 changed files with 31 additions and 95 deletions
|
@ -134,42 +134,20 @@ func storeInfo(c *cli.Context) (string, map[string]interface{}, error) {
|
|||
info := map[string]interface{}{}
|
||||
info["GraphRoot"] = store.GraphRoot()
|
||||
info["GraphDriverName"] = store.GraphDriverName()
|
||||
if is, err := store.ImageStore(); err != nil {
|
||||
images, err := store.Images()
|
||||
if err != nil {
|
||||
info["ImageStore"] = infoErr(err)
|
||||
} else {
|
||||
images, err := is.Images()
|
||||
if err != nil {
|
||||
info["ImageStore"] = infoErr(err)
|
||||
} else {
|
||||
info["ImageStore"] = map[string]interface{}{
|
||||
"number": len(images),
|
||||
}
|
||||
info["ImageStore"] = map[string]interface{}{
|
||||
"number": len(images),
|
||||
}
|
||||
}
|
||||
/* Oh this is in master on containers/storage, rebase later
|
||||
if is, err := store.ROImageStores(); err != nil {
|
||||
info["ROImageStore"] = infoErr(err)
|
||||
} else {
|
||||
images, err := is.Images()
|
||||
if err != nil {
|
||||
info["ROImageStore"] = infoErr(err)
|
||||
} else {
|
||||
info["ROImageStore"] = map[string]interface{}{
|
||||
"number": len(images),
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
if cs, err := store.ContainerStore(); err != nil {
|
||||
containers, err := store.Containers()
|
||||
if err != nil {
|
||||
info["ContainerStore"] = infoErr(err)
|
||||
} else {
|
||||
containers, err := cs.Containers()
|
||||
if err != nil {
|
||||
info["ContainerStore"] = infoErr(err)
|
||||
} else {
|
||||
info["ContainerStore"] = map[string]interface{}{
|
||||
"number": len(containers),
|
||||
}
|
||||
info["ContainerStore"] = map[string]interface{}{
|
||||
"number": len(containers),
|
||||
}
|
||||
}
|
||||
return "store", info, nil
|
||||
|
|
|
@ -96,12 +96,7 @@ func rmiCmd(c *cli.Context) error {
|
|||
// TODO: replace this with something in libkpod
|
||||
func runningContainers(image *storage.Image, store storage.Store) ([]string, error) {
|
||||
ctrIDs := []string{}
|
||||
ctrStore, err := store.ContainerStore()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
containers, err := ctrStore.Containers()
|
||||
containers, err := store.Containers()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -115,12 +110,8 @@ func runningContainers(image *storage.Image, store storage.Store) ([]string, err
|
|||
|
||||
// TODO: replace this with something in libkpod
|
||||
func removeContainers(ctrIDs []string, store storage.Store) error {
|
||||
ctrStore, err := store.ContainerStore()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, ctrID := range ctrIDs {
|
||||
if err = ctrStore.Delete(ctrID); err != nil {
|
||||
if err := store.DeleteContainer(ctrID); err != nil {
|
||||
return errors.Wrapf(err, "could not remove container %q", ctrID)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue