cmd/dist, cmd/ctr: move image store access to GRPC
With this changeset, image store access is now moved to completely accessible over GRPC. No clients manipulate the image store database directly and the GRPC client is fully featured. The metadata database is now managed by the daemon and access coordinated via services. Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
parent
1ea809dc2a
commit
8c74da3983
10 changed files with 69 additions and 98 deletions
|
@ -277,27 +277,18 @@ var runCommand = cli.Command{
|
|||
return err
|
||||
}
|
||||
|
||||
db, err := getDB(context, false)
|
||||
imageStore, err := getImageStore(context)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed opening database")
|
||||
return errors.Wrap(err, "failed resolving image store")
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
tx, err := db.Begin(false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
|
||||
ref := context.Args().First()
|
||||
|
||||
image, err := images.Get(tx, ref)
|
||||
image, err := imageStore.Get(ctx, ref)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "could not resolve %q", ref)
|
||||
}
|
||||
// let's close out our db and tx so we don't hold the lock whilst running.
|
||||
tx.Rollback()
|
||||
db.Close()
|
||||
|
||||
diffIDs, err := image.RootFS(ctx, provider)
|
||||
if err != nil {
|
||||
|
|
|
@ -14,14 +14,15 @@ import (
|
|||
|
||||
gocontext "context"
|
||||
|
||||
"github.com/boltdb/bolt"
|
||||
contentapi "github.com/containerd/containerd/api/services/content"
|
||||
"github.com/containerd/containerd/api/services/execution"
|
||||
imagesapi "github.com/containerd/containerd/api/services/images"
|
||||
rootfsapi "github.com/containerd/containerd/api/services/rootfs"
|
||||
"github.com/containerd/containerd/api/types/container"
|
||||
"github.com/containerd/containerd/content"
|
||||
"github.com/containerd/containerd/images"
|
||||
contentservice "github.com/containerd/containerd/services/content"
|
||||
imagesservice "github.com/containerd/containerd/services/images"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/tonistiigi/fifo"
|
||||
"github.com/urfave/cli"
|
||||
|
@ -134,25 +135,12 @@ func getRootFSService(context *cli.Context) (rootfsapi.RootFSClient, error) {
|
|||
return rootfsapi.NewRootFSClient(conn), nil
|
||||
}
|
||||
|
||||
func getDB(ctx *cli.Context, readonly bool) (*bolt.DB, error) {
|
||||
// TODO(stevvooe): For now, we operate directly on the database. We will
|
||||
// replace this with a GRPC service when the details are more concrete.
|
||||
path := filepath.Join(ctx.GlobalString("root"), "meta.db")
|
||||
|
||||
db, err := bolt.Open(path, 0644, &bolt.Options{
|
||||
ReadOnly: readonly,
|
||||
})
|
||||
func getImageStore(clicontext *cli.Context) (images.Store, error) {
|
||||
conn, err := getGRPCConnection(clicontext)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !readonly {
|
||||
if err := images.InitDB(db); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return db, nil
|
||||
return imagesservice.NewStoreFromClient(imagesapi.NewImagesClient(conn)), nil
|
||||
}
|
||||
|
||||
func getTempDir(id string) (string, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue