Update containerd to d1435e6e4d.
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
2
vendor/github.com/containerd/containerd/README.md
generated
vendored
2
vendor/github.com/containerd/containerd/README.md
generated
vendored
@@ -1,4 +1,4 @@
|
||||

|
||||

|
||||
|
||||
[](https://godoc.org/github.com/containerd/containerd)
|
||||
[](https://travis-ci.org/containerd/containerd)
|
||||
|
||||
2
vendor/github.com/containerd/containerd/archive/tar.go
generated
vendored
2
vendor/github.com/containerd/containerd/archive/tar.go
generated
vendored
@@ -199,7 +199,7 @@ func applyNaive(ctx context.Context, root string, tr *tar.Reader, options ApplyO
|
||||
basename := filepath.Base(hdr.Name)
|
||||
aufsHardlinks[basename] = hdr
|
||||
if aufsTempdir == "" {
|
||||
if aufsTempdir, err = ioutil.TempDir("", "dockerplnk"); err != nil {
|
||||
if aufsTempdir, err = ioutil.TempDir(os.Getenv("XDG_RUNTIME_DIR"), "dockerplnk"); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
defer os.RemoveAll(aufsTempdir)
|
||||
|
||||
42
vendor/github.com/containerd/containerd/cio/io.go
generated
vendored
42
vendor/github.com/containerd/containerd/cio/io.go
generated
vendored
@@ -21,6 +21,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
"github.com/containerd/containerd/defaults"
|
||||
@@ -213,3 +214,44 @@ type DirectIO struct {
|
||||
}
|
||||
|
||||
var _ IO = &DirectIO{}
|
||||
|
||||
// LogFile creates a file on disk that logs the task's STDOUT,STDERR.
|
||||
// If the log file already exists, the logs will be appended to the file.
|
||||
func LogFile(path string) Creator {
|
||||
return func(_ string) (IO, error) {
|
||||
if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
f, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
f.Close()
|
||||
return &logIO{
|
||||
config: Config{
|
||||
Stdout: path,
|
||||
Stderr: path,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
type logIO struct {
|
||||
config Config
|
||||
}
|
||||
|
||||
func (l *logIO) Config() Config {
|
||||
return l.config
|
||||
}
|
||||
|
||||
func (l *logIO) Cancel() {
|
||||
|
||||
}
|
||||
|
||||
func (l *logIO) Wait() {
|
||||
|
||||
}
|
||||
|
||||
func (l *logIO) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
10
vendor/github.com/containerd/containerd/cio/io_unix.go
generated
vendored
10
vendor/github.com/containerd/containerd/cio/io_unix.go
generated
vendored
@@ -141,8 +141,18 @@ func openFifos(ctx context.Context, fifos *FIFOSet) (pipes, error) {
|
||||
// NewDirectIO returns an IO implementation that exposes the IO streams as io.ReadCloser
|
||||
// and io.WriteCloser.
|
||||
func NewDirectIO(ctx context.Context, fifos *FIFOSet) (*DirectIO, error) {
|
||||
return newDirectIO(ctx, fifos, false)
|
||||
}
|
||||
|
||||
// NewDirectIOWithTerminal returns an IO implementation that exposes the streams with terminal enabled
|
||||
func NewDirectIOWithTerminal(ctx context.Context, fifos *FIFOSet) (*DirectIO, error) {
|
||||
return newDirectIO(ctx, fifos, true)
|
||||
}
|
||||
|
||||
func newDirectIO(ctx context.Context, fifos *FIFOSet, terminal bool) (*DirectIO, error) {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
pipes, err := openFifos(ctx, fifos)
|
||||
fifos.Config.Terminal = terminal
|
||||
return &DirectIO{
|
||||
pipes: pipes,
|
||||
cio: cio{
|
||||
|
||||
151
vendor/github.com/containerd/containerd/client.go
generated
vendored
151
vendor/github.com/containerd/containerd/client.go
generated
vendored
@@ -19,7 +19,6 @@ package containerd
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"runtime"
|
||||
"strconv"
|
||||
@@ -339,38 +338,43 @@ func (c *Client) Pull(ctx context.Context, ref string, opts ...RemoteOpt) (Image
|
||||
}
|
||||
}
|
||||
|
||||
imgrec := images.Image{
|
||||
Name: name,
|
||||
Target: desc,
|
||||
Labels: pullCtx.Labels,
|
||||
img := &image{
|
||||
client: c,
|
||||
i: images.Image{
|
||||
Name: name,
|
||||
Target: desc,
|
||||
Labels: pullCtx.Labels,
|
||||
},
|
||||
}
|
||||
|
||||
if pullCtx.Unpack {
|
||||
if err := img.Unpack(ctx, pullCtx.Snapshotter); err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to unpack image on snapshotter %s", pullCtx.Snapshotter)
|
||||
}
|
||||
}
|
||||
|
||||
is := c.ImageService()
|
||||
if created, err := is.Create(ctx, imgrec); err != nil {
|
||||
if !errdefs.IsAlreadyExists(err) {
|
||||
return nil, err
|
||||
}
|
||||
for {
|
||||
if created, err := is.Create(ctx, img.i); err != nil {
|
||||
if !errdefs.IsAlreadyExists(err) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
updated, err := is.Update(ctx, imgrec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
updated, err := is.Update(ctx, img.i)
|
||||
if err != nil {
|
||||
// if image was removed, try create again
|
||||
if errdefs.IsNotFound(err) {
|
||||
continue
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
imgrec = updated
|
||||
} else {
|
||||
imgrec = created
|
||||
}
|
||||
|
||||
img := &image{
|
||||
client: c,
|
||||
i: imgrec,
|
||||
}
|
||||
if pullCtx.Unpack {
|
||||
if err := img.Unpack(ctx, pullCtx.Snapshotter); err != nil {
|
||||
errors.Wrapf(err, "failed to unpack image on snapshotter %s", pullCtx.Snapshotter)
|
||||
img.i = updated
|
||||
} else {
|
||||
img.i = created
|
||||
}
|
||||
return img, nil
|
||||
}
|
||||
return img, nil
|
||||
}
|
||||
|
||||
// Push uploads the provided content to a remote resource
|
||||
@@ -551,98 +555,3 @@ func (c *Client) Version(ctx context.Context) (Version, error) {
|
||||
Revision: response.Revision,
|
||||
}, nil
|
||||
}
|
||||
|
||||
type importOpts struct {
|
||||
}
|
||||
|
||||
// ImportOpt allows the caller to specify import specific options
|
||||
type ImportOpt func(c *importOpts) error
|
||||
|
||||
func resolveImportOpt(opts ...ImportOpt) (importOpts, error) {
|
||||
var iopts importOpts
|
||||
for _, o := range opts {
|
||||
if err := o(&iopts); err != nil {
|
||||
return iopts, err
|
||||
}
|
||||
}
|
||||
return iopts, nil
|
||||
}
|
||||
|
||||
// Import imports an image from a Tar stream using reader.
|
||||
// Caller needs to specify importer. Future version may use oci.v1 as the default.
|
||||
// Note that unreferrenced blobs may be imported to the content store as well.
|
||||
func (c *Client) Import(ctx context.Context, importer images.Importer, reader io.Reader, opts ...ImportOpt) ([]Image, error) {
|
||||
_, err := resolveImportOpt(opts...) // unused now
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx, done, err := c.WithLease(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer done(ctx)
|
||||
|
||||
imgrecs, err := importer.Import(ctx, c.ContentStore(), reader)
|
||||
if err != nil {
|
||||
// is.Update() is not called on error
|
||||
return nil, err
|
||||
}
|
||||
|
||||
is := c.ImageService()
|
||||
var images []Image
|
||||
for _, imgrec := range imgrecs {
|
||||
if updated, err := is.Update(ctx, imgrec, "target"); err != nil {
|
||||
if !errdefs.IsNotFound(err) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
created, err := is.Create(ctx, imgrec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
imgrec = created
|
||||
} else {
|
||||
imgrec = updated
|
||||
}
|
||||
|
||||
images = append(images, &image{
|
||||
client: c,
|
||||
i: imgrec,
|
||||
})
|
||||
}
|
||||
return images, nil
|
||||
}
|
||||
|
||||
type exportOpts struct {
|
||||
}
|
||||
|
||||
// ExportOpt allows the caller to specify export-specific options
|
||||
type ExportOpt func(c *exportOpts) error
|
||||
|
||||
func resolveExportOpt(opts ...ExportOpt) (exportOpts, error) {
|
||||
var eopts exportOpts
|
||||
for _, o := range opts {
|
||||
if err := o(&eopts); err != nil {
|
||||
return eopts, err
|
||||
}
|
||||
}
|
||||
return eopts, nil
|
||||
}
|
||||
|
||||
// Export exports an image to a Tar stream.
|
||||
// OCI format is used by default.
|
||||
// It is up to caller to put "org.opencontainers.image.ref.name" annotation to desc.
|
||||
// TODO(AkihiroSuda): support exporting multiple descriptors at once to a single archive stream.
|
||||
func (c *Client) Export(ctx context.Context, exporter images.Exporter, desc ocispec.Descriptor, opts ...ExportOpt) (io.ReadCloser, error) {
|
||||
_, err := resolveExportOpt(opts...) // unused now
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pr, pw := io.Pipe()
|
||||
go func() {
|
||||
pw.CloseWithError(exporter.Export(ctx, c.ContentStore(), desc, pw))
|
||||
}()
|
||||
return pr, nil
|
||||
}
|
||||
|
||||
5
vendor/github.com/containerd/containerd/cmd/containerd/command/main.go
generated
vendored
5
vendor/github.com/containerd/containerd/cmd/containerd/command/main.go
generated
vendored
@@ -17,7 +17,7 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"context"
|
||||
gocontext "context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
golog "log"
|
||||
@@ -35,7 +35,6 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
gocontext "golang.org/x/net/context"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
)
|
||||
|
||||
@@ -168,7 +167,7 @@ func App() *cli.App {
|
||||
return app
|
||||
}
|
||||
|
||||
func serve(ctx context.Context, l net.Listener, serveFunc func(net.Listener) error) {
|
||||
func serve(ctx gocontext.Context, l net.Listener, serveFunc func(net.Listener) error) {
|
||||
path := l.Addr().String()
|
||||
log.G(ctx).WithField("address", path).Info("serving...")
|
||||
go func() {
|
||||
|
||||
2
vendor/github.com/containerd/containerd/cmd/ctr/commands/content/content.go
generated
vendored
2
vendor/github.com/containerd/containerd/cmd/ctr/commands/content/content.go
generated
vendored
@@ -506,7 +506,7 @@ var (
|
||||
)
|
||||
|
||||
func edit(rd io.Reader) (io.ReadCloser, error) {
|
||||
tmp, err := ioutil.TempFile("", "edit-")
|
||||
tmp, err := ioutil.TempFile(os.Getenv("XDG_RUNTIME_DIR"), "edit-")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
16
vendor/github.com/containerd/containerd/cmd/ctr/commands/content/fetch.go
generated
vendored
16
vendor/github.com/containerd/containerd/cmd/ctr/commands/content/fetch.go
generated
vendored
@@ -61,19 +61,19 @@ Most of this is experimental and there are few leaps to make this work.`,
|
||||
var (
|
||||
ref = clicontext.Args().First()
|
||||
)
|
||||
_, err := Fetch(ref, clicontext)
|
||||
client, ctx, cancel, err := commands.NewClient(clicontext)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer cancel()
|
||||
|
||||
_, err = Fetch(ctx, client, ref, clicontext)
|
||||
return err
|
||||
},
|
||||
}
|
||||
|
||||
// Fetch loads all resources into the content store and returns the image
|
||||
func Fetch(ref string, cliContext *cli.Context) (containerd.Image, error) {
|
||||
client, ctx, cancel, err := commands.NewClient(cliContext)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer cancel()
|
||||
|
||||
func Fetch(ctx context.Context, client *containerd.Client, ref string, cliContext *cli.Context) (containerd.Image, error) {
|
||||
resolver, err := commands.GetResolver(ctx, cliContext)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
48
vendor/github.com/containerd/containerd/cmd/ctr/commands/events/events.go
generated
vendored
48
vendor/github.com/containerd/containerd/cmd/ctr/commands/events/events.go
generated
vendored
@@ -42,38 +42,36 @@ var Command = cli.Command{
|
||||
defer cancel()
|
||||
eventsClient := client.EventService()
|
||||
eventsCh, errCh := eventsClient.Subscribe(ctx, context.Args()...)
|
||||
for {
|
||||
open := true
|
||||
for open {
|
||||
var e *events.Envelope
|
||||
select {
|
||||
case evt, closed := <-eventsCh:
|
||||
if closed {
|
||||
return nil
|
||||
}
|
||||
e = evt
|
||||
case err := <-errCh:
|
||||
case e = <-eventsCh:
|
||||
case err, open = <-errCh:
|
||||
return err
|
||||
}
|
||||
|
||||
var out []byte
|
||||
if e.Event != nil {
|
||||
v, err := typeurl.UnmarshalAny(e.Event)
|
||||
if err != nil {
|
||||
if e != nil {
|
||||
var out []byte
|
||||
if e.Event != nil {
|
||||
v, err := typeurl.UnmarshalAny(e.Event)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
out, err = json.Marshal(v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if _, err := fmt.Println(
|
||||
e.Timestamp,
|
||||
e.Namespace,
|
||||
e.Topic,
|
||||
string(out),
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
out, err = json.Marshal(v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if _, err := fmt.Println(
|
||||
e.Timestamp,
|
||||
e.Namespace,
|
||||
e.Topic,
|
||||
string(out),
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
14
vendor/github.com/containerd/containerd/cmd/ctr/commands/images/pull.go
generated
vendored
14
vendor/github.com/containerd/containerd/cmd/ctr/commands/images/pull.go
generated
vendored
@@ -57,10 +57,20 @@ command. As part of this process, we do the following:
|
||||
if ref == "" {
|
||||
return fmt.Errorf("please provide an image reference to pull")
|
||||
}
|
||||
ctx, cancel := commands.AppContext(context)
|
||||
|
||||
client, ctx, cancel, err := commands.NewClient(context)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer cancel()
|
||||
|
||||
img, err := content.Fetch(ref, context)
|
||||
ctx, done, err := client.WithLease(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer done(ctx)
|
||||
|
||||
img, err := content.Fetch(ctx, client, ref, context)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
3
vendor/github.com/containerd/containerd/cmd/ctr/commands/shim/shim.go
generated
vendored
3
vendor/github.com/containerd/containerd/cmd/ctr/commands/shim/shim.go
generated
vendored
@@ -19,12 +19,11 @@
|
||||
package shim
|
||||
|
||||
import (
|
||||
gocontext "context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
|
||||
gocontext "context"
|
||||
|
||||
"github.com/containerd/console"
|
||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||
shim "github.com/containerd/containerd/linux/shim/v1"
|
||||
|
||||
11
vendor/github.com/containerd/containerd/cmd/ctr/commands/snapshots/snapshots.go
generated
vendored
11
vendor/github.com/containerd/containerd/cmd/ctr/commands/snapshots/snapshots.go
generated
vendored
@@ -304,7 +304,11 @@ var prepareCommand = cli.Command{
|
||||
defer cancel()
|
||||
|
||||
snapshotter := client.SnapshotService(context.GlobalString("snapshotter"))
|
||||
mounts, err := snapshotter.Prepare(ctx, key, parent)
|
||||
labels := map[string]string{
|
||||
"containerd.io/gc.root": time.Now().UTC().Format(time.RFC3339),
|
||||
}
|
||||
|
||||
mounts, err := snapshotter.Prepare(ctx, key, parent, snapshots.WithLabels(labels))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -404,7 +408,10 @@ var commitCommand = cli.Command{
|
||||
}
|
||||
defer cancel()
|
||||
snapshotter := client.SnapshotService(context.GlobalString("snapshotter"))
|
||||
return snapshotter.Commit(ctx, key, active)
|
||||
labels := map[string]string{
|
||||
"containerd.io/gc.root": time.Now().UTC().Format(time.RFC3339),
|
||||
}
|
||||
return snapshotter.Commit(ctx, key, active, snapshots.WithLabels(labels))
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
2
vendor/github.com/containerd/containerd/cmd/ctr/commands/tasks/list.go
generated
vendored
2
vendor/github.com/containerd/containerd/cmd/ctr/commands/tasks/list.go
generated
vendored
@@ -34,7 +34,7 @@ var listCommand = cli.Command{
|
||||
Flags: []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "quiet, q",
|
||||
Usage: "print only the task id & pid",
|
||||
Usage: "print only the task id",
|
||||
},
|
||||
},
|
||||
Action: func(context *cli.Context) error {
|
||||
|
||||
31
vendor/github.com/containerd/containerd/cmd/ctr/commands/tasks/tasks_unix.go
generated
vendored
31
vendor/github.com/containerd/containerd/cmd/ctr/commands/tasks/tasks_unix.go
generated
vendored
@@ -69,25 +69,24 @@ func HandleConsoleResize(ctx gocontext.Context, task resizer, con console.Consol
|
||||
// NewTask creates a new task
|
||||
func NewTask(ctx gocontext.Context, client *containerd.Client, container containerd.Container, checkpoint string, tty, nullIO bool, ioOpts []cio.Opt, opts ...containerd.NewTaskOpts) (containerd.Task, error) {
|
||||
stdio := cio.NewCreator(append([]cio.Opt{cio.WithStdio}, ioOpts...)...)
|
||||
if checkpoint == "" {
|
||||
ioCreator := stdio
|
||||
if checkpoint != "" {
|
||||
im, err := client.GetImage(ctx, checkpoint)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
opts = append(opts, containerd.WithTaskCheckpoint(im))
|
||||
}
|
||||
ioCreator := stdio
|
||||
if tty {
|
||||
ioCreator = cio.NewCreator(append([]cio.Opt{cio.WithStdio, cio.WithTerminal}, ioOpts...)...)
|
||||
}
|
||||
if nullIO {
|
||||
if tty {
|
||||
ioCreator = cio.NewCreator(append([]cio.Opt{cio.WithStdio, cio.WithTerminal}, ioOpts...)...)
|
||||
return nil, errors.New("tty and null-io cannot be used together")
|
||||
}
|
||||
if nullIO {
|
||||
if tty {
|
||||
return nil, errors.New("tty and null-io cannot be used together")
|
||||
}
|
||||
ioCreator = cio.NullIO
|
||||
}
|
||||
return container.NewTask(ctx, ioCreator, opts...)
|
||||
ioCreator = cio.NullIO
|
||||
}
|
||||
im, err := client.GetImage(ctx, checkpoint)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
opts = append(opts, containerd.WithTaskCheckpoint(im))
|
||||
return container.NewTask(ctx, stdio, opts...)
|
||||
return container.NewTask(ctx, ioCreator, opts...)
|
||||
}
|
||||
|
||||
func getNewTaskOpts(context *cli.Context) []containerd.NewTaskOpts {
|
||||
|
||||
8
vendor/github.com/containerd/containerd/container.go
generated
vendored
8
vendor/github.com/containerd/containerd/container.go
generated
vendored
@@ -28,9 +28,9 @@ import (
|
||||
"github.com/containerd/containerd/cio"
|
||||
"github.com/containerd/containerd/containers"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/oci"
|
||||
"github.com/containerd/typeurl"
|
||||
prototypes "github.com/gogo/protobuf/types"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
@@ -45,7 +45,7 @@ type Container interface {
|
||||
// NewTask creates a new task based on the container metadata
|
||||
NewTask(context.Context, cio.Creator, ...NewTaskOpts) (Task, error)
|
||||
// Spec returns the OCI runtime specification
|
||||
Spec(context.Context) (*specs.Spec, error)
|
||||
Spec(context.Context) (*oci.Spec, error)
|
||||
// Task returns the current task for the container
|
||||
//
|
||||
// If cio.Attach options are passed the client will reattach to the IO for the running
|
||||
@@ -126,12 +126,12 @@ func (c *container) SetLabels(ctx context.Context, labels map[string]string) (ma
|
||||
}
|
||||
|
||||
// Spec returns the current OCI specification for the container
|
||||
func (c *container) Spec(ctx context.Context) (*specs.Spec, error) {
|
||||
func (c *container) Spec(ctx context.Context) (*oci.Spec, error) {
|
||||
r, err := c.get(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var s specs.Spec
|
||||
var s oci.Spec
|
||||
if err := json.Unmarshal(r.Spec.Value, &s); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
3
vendor/github.com/containerd/containerd/container_opts.go
generated
vendored
3
vendor/github.com/containerd/containerd/container_opts.go
generated
vendored
@@ -26,7 +26,6 @@ import (
|
||||
"github.com/containerd/typeurl"
|
||||
"github.com/gogo/protobuf/types"
|
||||
"github.com/opencontainers/image-spec/identity"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
@@ -196,7 +195,7 @@ func WithNewSpec(opts ...oci.SpecOpts) NewContainerOpts {
|
||||
}
|
||||
|
||||
// WithSpec sets the provided spec on the container
|
||||
func WithSpec(s *specs.Spec, opts ...oci.SpecOpts) NewContainerOpts {
|
||||
func WithSpec(s *oci.Spec, opts ...oci.SpecOpts) NewContainerOpts {
|
||||
return func(ctx context.Context, client *Client, c *containers.Container) error {
|
||||
for _, o := range opts {
|
||||
if err := o(ctx, client, c, s); err != nil {
|
||||
|
||||
2
vendor/github.com/containerd/containerd/contrib/apparmor/apparmor.go
generated
vendored
2
vendor/github.com/containerd/containerd/contrib/apparmor/apparmor.go
generated
vendored
@@ -53,7 +53,7 @@ func WithDefaultProfile(name string) oci.SpecOpts {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
f, err := ioutil.TempFile("", p.Name)
|
||||
f, err := ioutil.TempFile(os.Getenv("XDG_RUNTIME_DIR"), p.Name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
3
vendor/github.com/containerd/containerd/grpc.go
generated
vendored
3
vendor/github.com/containerd/containerd/grpc.go
generated
vendored
@@ -17,8 +17,9 @@
|
||||
package containerd
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
|
||||
121
vendor/github.com/containerd/containerd/import.go
generated
vendored
Normal file
121
vendor/github.com/containerd/containerd/import.go
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
Copyright The containerd Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package containerd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/images"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
type importOpts struct {
|
||||
}
|
||||
|
||||
// ImportOpt allows the caller to specify import specific options
|
||||
type ImportOpt func(c *importOpts) error
|
||||
|
||||
func resolveImportOpt(opts ...ImportOpt) (importOpts, error) {
|
||||
var iopts importOpts
|
||||
for _, o := range opts {
|
||||
if err := o(&iopts); err != nil {
|
||||
return iopts, err
|
||||
}
|
||||
}
|
||||
return iopts, nil
|
||||
}
|
||||
|
||||
// Import imports an image from a Tar stream using reader.
|
||||
// Caller needs to specify importer. Future version may use oci.v1 as the default.
|
||||
// Note that unreferrenced blobs may be imported to the content store as well.
|
||||
func (c *Client) Import(ctx context.Context, importer images.Importer, reader io.Reader, opts ...ImportOpt) ([]Image, error) {
|
||||
_, err := resolveImportOpt(opts...) // unused now
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx, done, err := c.WithLease(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer done(ctx)
|
||||
|
||||
imgrecs, err := importer.Import(ctx, c.ContentStore(), reader)
|
||||
if err != nil {
|
||||
// is.Update() is not called on error
|
||||
return nil, err
|
||||
}
|
||||
|
||||
is := c.ImageService()
|
||||
var images []Image
|
||||
for _, imgrec := range imgrecs {
|
||||
if updated, err := is.Update(ctx, imgrec, "target"); err != nil {
|
||||
if !errdefs.IsNotFound(err) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
created, err := is.Create(ctx, imgrec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
imgrec = created
|
||||
} else {
|
||||
imgrec = updated
|
||||
}
|
||||
|
||||
images = append(images, &image{
|
||||
client: c,
|
||||
i: imgrec,
|
||||
})
|
||||
}
|
||||
return images, nil
|
||||
}
|
||||
|
||||
type exportOpts struct {
|
||||
}
|
||||
|
||||
// ExportOpt allows the caller to specify export-specific options
|
||||
type ExportOpt func(c *exportOpts) error
|
||||
|
||||
func resolveExportOpt(opts ...ExportOpt) (exportOpts, error) {
|
||||
var eopts exportOpts
|
||||
for _, o := range opts {
|
||||
if err := o(&eopts); err != nil {
|
||||
return eopts, err
|
||||
}
|
||||
}
|
||||
return eopts, nil
|
||||
}
|
||||
|
||||
// Export exports an image to a Tar stream.
|
||||
// OCI format is used by default.
|
||||
// It is up to caller to put "org.opencontainers.image.ref.name" annotation to desc.
|
||||
// TODO(AkihiroSuda): support exporting multiple descriptors at once to a single archive stream.
|
||||
func (c *Client) Export(ctx context.Context, exporter images.Exporter, desc ocispec.Descriptor, opts ...ExportOpt) (io.ReadCloser, error) {
|
||||
_, err := resolveExportOpt(opts...) // unused now
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pr, pw := io.Pipe()
|
||||
go func() {
|
||||
pw.CloseWithError(exporter.Export(ctx, c.ContentStore(), desc, pw))
|
||||
}()
|
||||
return pr, nil
|
||||
}
|
||||
3
vendor/github.com/containerd/containerd/leases/grpc.go
generated
vendored
3
vendor/github.com/containerd/containerd/leases/grpc.go
generated
vendored
@@ -17,7 +17,8 @@
|
||||
package leases
|
||||
|
||||
import (
|
||||
"golang.org/x/net/context"
|
||||
"context"
|
||||
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
|
||||
28
vendor/github.com/containerd/containerd/linux/proc/init_state.go
generated
vendored
28
vendor/github.com/containerd/containerd/linux/proc/init_state.go
generated
vendored
@@ -194,10 +194,23 @@ func (s *createdCheckpointState) Start(ctx context.Context) error {
|
||||
s.p.mu.Lock()
|
||||
defer s.p.mu.Unlock()
|
||||
p := s.p
|
||||
sio := p.stdio
|
||||
|
||||
var (
|
||||
err error
|
||||
socket *runc.Socket
|
||||
)
|
||||
if sio.Terminal {
|
||||
if socket, err = runc.NewTempConsoleSocket(); err != nil {
|
||||
return errors.Wrap(err, "failed to create OCI runtime console socket")
|
||||
}
|
||||
defer socket.Close()
|
||||
s.opts.ConsoleSocket = socket
|
||||
}
|
||||
|
||||
if _, err := s.p.runtime.Restore(ctx, p.id, p.bundle, s.opts); err != nil {
|
||||
return p.runtimeError(err, "OCI runtime restore failed")
|
||||
}
|
||||
sio := p.stdio
|
||||
if sio.Stdin != "" {
|
||||
sc, err := fifo.OpenFifo(ctx, sio.Stdin, syscall.O_WRONLY|syscall.O_NONBLOCK, 0)
|
||||
if err != nil {
|
||||
@@ -207,7 +220,17 @@ func (s *createdCheckpointState) Start(ctx context.Context) error {
|
||||
p.closers = append(p.closers, sc)
|
||||
}
|
||||
var copyWaitGroup sync.WaitGroup
|
||||
if !sio.IsNull() {
|
||||
if socket != nil {
|
||||
console, err := socket.ReceiveMaster()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to retrieve console master")
|
||||
}
|
||||
console, err = p.platform.CopyConsole(ctx, console, sio.Stdin, sio.Stdout, sio.Stderr, &p.wg, ©WaitGroup)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to start console copy")
|
||||
}
|
||||
p.console = console
|
||||
} else if !sio.IsNull() {
|
||||
if err := copyPipes(ctx, p.io, sio.Stdin, sio.Stdout, sio.Stderr, &p.wg, ©WaitGroup); err != nil {
|
||||
return errors.Wrap(err, "failed to start io pipe copy")
|
||||
}
|
||||
@@ -219,7 +242,6 @@ func (s *createdCheckpointState) Start(ctx context.Context) error {
|
||||
return errors.Wrap(err, "failed to retrieve OCI runtime container pid")
|
||||
}
|
||||
p.pid = pid
|
||||
|
||||
return s.transition("running")
|
||||
}
|
||||
|
||||
|
||||
3
vendor/github.com/containerd/containerd/linux/runtime.go
generated
vendored
3
vendor/github.com/containerd/containerd/linux/runtime.go
generated
vendored
@@ -79,7 +79,7 @@ func init() {
|
||||
})
|
||||
}
|
||||
|
||||
var _ = (runtime.Runtime)(&Runtime{})
|
||||
var _ = (runtime.PlatformRuntime)(&Runtime{})
|
||||
|
||||
// Config options for the runtime
|
||||
type Config struct {
|
||||
@@ -510,6 +510,7 @@ func (r *Runtime) getRuntime(ctx context.Context, ns, id string) (*runc.Runc, er
|
||||
LogFormat: runc.JSON,
|
||||
PdeathSignal: unix.SIGKILL,
|
||||
Root: filepath.Join(root, ns),
|
||||
Debug: r.config.ShimDebug,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package reaper
|
||||
package shim
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
3
vendor/github.com/containerd/containerd/linux/shim/service.go
generated
vendored
3
vendor/github.com/containerd/containerd/linux/shim/service.go
generated
vendored
@@ -34,7 +34,6 @@ import (
|
||||
shimapi "github.com/containerd/containerd/linux/shim/v1"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
"github.com/containerd/containerd/reaper"
|
||||
"github.com/containerd/containerd/runtime"
|
||||
runc "github.com/containerd/go-runc"
|
||||
"github.com/containerd/typeurl"
|
||||
@@ -81,7 +80,7 @@ func NewService(config Config, publisher events.Publisher) (*Service, error) {
|
||||
context: ctx,
|
||||
processes: make(map[string]proc.Process),
|
||||
events: make(chan interface{}, 128),
|
||||
ec: reaper.Default.Subscribe(),
|
||||
ec: Default.Subscribe(),
|
||||
}
|
||||
go s.processExits()
|
||||
if err := s.initPlatform(); err != nil {
|
||||
|
||||
6
vendor/github.com/containerd/containerd/metadata/buckets.go
generated
vendored
6
vendor/github.com/containerd/containerd/metadata/buckets.go
generated
vendored
@@ -135,11 +135,7 @@ func getImagesBucket(tx *bolt.Tx, namespace string) *bolt.Bucket {
|
||||
}
|
||||
|
||||
func createContainersBucket(tx *bolt.Tx, namespace string) (*bolt.Bucket, error) {
|
||||
bkt, err := createBucketIfNotExists(tx, bucketKeyVersion, []byte(namespace), bucketKeyObjectContainers)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return bkt, nil
|
||||
return createBucketIfNotExists(tx, bucketKeyVersion, []byte(namespace), bucketKeyObjectContainers)
|
||||
}
|
||||
|
||||
func getContainersBucket(tx *bolt.Tx, namespace string) *bolt.Bucket {
|
||||
|
||||
3
vendor/github.com/containerd/containerd/metrics/cgroups/cgroups.go
generated
vendored
3
vendor/github.com/containerd/containerd/metrics/cgroups/cgroups.go
generated
vendored
@@ -19,6 +19,8 @@
|
||||
package cgroups
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/containerd/cgroups"
|
||||
eventstypes "github.com/containerd/containerd/api/events"
|
||||
"github.com/containerd/containerd/events"
|
||||
@@ -30,7 +32,6 @@ import (
|
||||
"github.com/containerd/containerd/runtime"
|
||||
metrics "github.com/docker/go-metrics"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// Config for the cgroups monitor
|
||||
|
||||
109
vendor/github.com/containerd/containerd/mount/mountinfo_linux.go
generated
vendored
109
vendor/github.com/containerd/containerd/mount/mountinfo_linux.go
generated
vendored
@@ -23,27 +23,10 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
/* 36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 - ext3 /dev/root rw,errors=continue
|
||||
(1)(2)(3) (4) (5) (6) (7) (8) (9) (10) (11)
|
||||
|
||||
(1) mount ID: unique identifier of the mount (may be reused after umount)
|
||||
(2) parent ID: ID of parent (or of self for the top of the mount tree)
|
||||
(3) major:minor: value of st_dev for files on filesystem
|
||||
(4) root: root of the mount within the filesystem
|
||||
(5) mount point: mount point relative to the process's root
|
||||
(6) mount options: per mount options
|
||||
(7) optional fields: zero or more fields of the form "tag[:value]"
|
||||
(8) separator: marks the end of the optional fields
|
||||
(9) filesystem type: name of filesystem of the form "type[.subtype]"
|
||||
(10) mount source: filesystem specific information or "none"
|
||||
(11) super options: per super block options*/
|
||||
mountinfoFormat = "%d %d %d:%d %s %s %s %s"
|
||||
)
|
||||
|
||||
// Self retrieves a list of mounts for the current running process.
|
||||
func Self() ([]Info, error) {
|
||||
f, err := os.Open("/proc/self/mountinfo")
|
||||
@@ -56,41 +39,83 @@ func Self() ([]Info, error) {
|
||||
}
|
||||
|
||||
func parseInfoFile(r io.Reader) ([]Info, error) {
|
||||
var (
|
||||
s = bufio.NewScanner(r)
|
||||
out = []Info{}
|
||||
)
|
||||
s := bufio.NewScanner(r)
|
||||
out := []Info{}
|
||||
|
||||
for s.Scan() {
|
||||
if err := s.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var (
|
||||
p = Info{}
|
||||
text = s.Text()
|
||||
optionalFields string
|
||||
)
|
||||
/*
|
||||
36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 - ext3 /dev/root rw,errors=continue
|
||||
(1)(2)(3) (4) (5) (6) (7) (8) (9) (10) (11)
|
||||
(1) mount ID: unique identifier of the mount (may be reused after umount)
|
||||
(2) parent ID: ID of parent (or of self for the top of the mount tree)
|
||||
(3) major:minor: value of st_dev for files on filesystem
|
||||
(4) root: root of the mount within the filesystem
|
||||
(5) mount point: mount point relative to the process's root
|
||||
(6) mount options: per mount options
|
||||
(7) optional fields: zero or more fields of the form "tag[:value]"
|
||||
(8) separator: marks the end of the optional fields
|
||||
(9) filesystem type: name of filesystem of the form "type[.subtype]"
|
||||
(10) mount source: filesystem specific information or "none"
|
||||
(11) super options: per super block options
|
||||
*/
|
||||
|
||||
if _, err := fmt.Sscanf(text, mountinfoFormat,
|
||||
&p.ID, &p.Parent, &p.Major, &p.Minor,
|
||||
&p.Root, &p.Mountpoint, &p.Options, &optionalFields); err != nil {
|
||||
return nil, fmt.Errorf("Scanning '%s' failed: %s", text, err)
|
||||
text := s.Text()
|
||||
fields := strings.Split(text, " ")
|
||||
numFields := len(fields)
|
||||
if numFields < 10 {
|
||||
// should be at least 10 fields
|
||||
return nil, fmt.Errorf("Parsing '%s' failed: not enough fields (%d)", text, numFields)
|
||||
}
|
||||
// Safe as mountinfo encodes mountpoints with spaces as \040.
|
||||
index := strings.Index(text, " - ")
|
||||
postSeparatorFields := strings.Fields(text[index+3:])
|
||||
if len(postSeparatorFields) < 3 {
|
||||
return nil, fmt.Errorf("Error found less than 3 fields post '-' in %q", text)
|
||||
p := Info{}
|
||||
// ignore any numbers parsing errors, as there should not be any
|
||||
p.ID, _ = strconv.Atoi(fields[0])
|
||||
p.Parent, _ = strconv.Atoi(fields[1])
|
||||
mm := strings.Split(fields[2], ":")
|
||||
if len(mm) != 2 {
|
||||
return nil, fmt.Errorf("Parsing '%s' failed: unexpected minor:major pair %s", text, mm)
|
||||
}
|
||||
p.Major, _ = strconv.Atoi(mm[0])
|
||||
p.Minor, _ = strconv.Atoi(mm[1])
|
||||
|
||||
if optionalFields != "-" {
|
||||
p.Optional = optionalFields
|
||||
}
|
||||
p.Root = fields[3]
|
||||
p.Mountpoint = fields[4]
|
||||
p.Options = fields[5]
|
||||
|
||||
// one or more optional fields, when a separator (-)
|
||||
i := 6
|
||||
for ; i < numFields && fields[i] != "-"; i++ {
|
||||
switch i {
|
||||
case 6:
|
||||
p.Optional = fields[6]
|
||||
default:
|
||||
/* NOTE there might be more optional fields before the separator
|
||||
such as fields[7]...fields[N] (where N < separatorIndex),
|
||||
although as of Linux kernel 4.15 the only known ones are
|
||||
mount propagation flags in fields[6]. The correct
|
||||
behavior is to ignore any unknown optional fields.
|
||||
*/
|
||||
}
|
||||
}
|
||||
if i == numFields {
|
||||
return nil, fmt.Errorf("Parsing '%s' failed: missing separator ('-')", text)
|
||||
}
|
||||
// There should be 3 fields after the separator...
|
||||
if i+4 > numFields {
|
||||
return nil, fmt.Errorf("Parsing '%s' failed: not enough fields after a separator", text)
|
||||
}
|
||||
// ... but in Linux <= 3.9 mounting a cifs with spaces in a share name
|
||||
// (like "//serv/My Documents") _may_ end up having a space in the last field
|
||||
// of mountinfo (like "unc=//serv/My Documents"). Since kernel 3.10-rc1, cifs
|
||||
// option unc= is ignored, so a space should not appear. In here we ignore
|
||||
// those "extra" fields caused by extra spaces.
|
||||
p.FSType = fields[i+1]
|
||||
p.Source = fields[i+2]
|
||||
p.VFSOptions = fields[i+3]
|
||||
|
||||
p.FSType = postSeparatorFields[0]
|
||||
p.Source = postSeparatorFields[1]
|
||||
p.VFSOptions = strings.Join(postSeparatorFields[2:], " ")
|
||||
out = append(out, p)
|
||||
}
|
||||
return out, nil
|
||||
|
||||
9
vendor/github.com/containerd/containerd/mount/temp.go
generated
vendored
9
vendor/github.com/containerd/containerd/mount/temp.go
generated
vendored
@@ -25,7 +25,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var tempMountLocation = os.TempDir()
|
||||
var tempMountLocation = getTempDir()
|
||||
|
||||
// WithTempMount mounts the provided mounts to a temp dir, and pass the temp dir to f.
|
||||
// The mounts are valid during the call to the f.
|
||||
@@ -64,3 +64,10 @@ func WithTempMount(ctx context.Context, mounts []Mount, f func(root string) erro
|
||||
}
|
||||
return errors.Wrapf(f(root), "mount callback failed on %s", root)
|
||||
}
|
||||
|
||||
func getTempDir() string {
|
||||
if xdg := os.Getenv("XDG_RUNTIME_DIR"); xdg != "" {
|
||||
return xdg
|
||||
}
|
||||
return os.TempDir()
|
||||
}
|
||||
|
||||
3
vendor/github.com/containerd/containerd/namespaces/grpc.go
generated
vendored
3
vendor/github.com/containerd/containerd/namespaces/grpc.go
generated
vendored
@@ -17,7 +17,8 @@
|
||||
package namespaces
|
||||
|
||||
import (
|
||||
"golang.org/x/net/context"
|
||||
"context"
|
||||
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
|
||||
6
vendor/github.com/containerd/containerd/oci/spec.go
generated
vendored
6
vendor/github.com/containerd/containerd/oci/spec.go
generated
vendored
@@ -23,9 +23,13 @@ import (
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
)
|
||||
|
||||
// Spec is a type alias to the OCI runtime spec to allow third part SpecOpts
|
||||
// to be created without the "issues" with go vendoring and package imports
|
||||
type Spec = specs.Spec
|
||||
|
||||
// GenerateSpec will generate a default spec from the provided image
|
||||
// for use as a containerd container
|
||||
func GenerateSpec(ctx context.Context, client Client, c *containers.Container, opts ...SpecOpts) (*specs.Spec, error) {
|
||||
func GenerateSpec(ctx context.Context, client Client, c *containers.Container, opts ...SpecOpts) (*Spec, error) {
|
||||
s, err := createDefaultSpec(ctx, c.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
16
vendor/github.com/containerd/containerd/oci/spec_opts.go
generated
vendored
16
vendor/github.com/containerd/containerd/oci/spec_opts.go
generated
vendored
@@ -25,11 +25,11 @@ import (
|
||||
)
|
||||
|
||||
// SpecOpts sets spec specific information to a newly generated OCI spec
|
||||
type SpecOpts func(context.Context, Client, *containers.Container, *specs.Spec) error
|
||||
type SpecOpts func(context.Context, Client, *containers.Container, *Spec) error
|
||||
|
||||
// Compose converts a sequence of spec operations into a single operation
|
||||
func Compose(opts ...SpecOpts) SpecOpts {
|
||||
return func(ctx context.Context, client Client, c *containers.Container, s *specs.Spec) error {
|
||||
return func(ctx context.Context, client Client, c *containers.Container, s *Spec) error {
|
||||
for _, o := range opts {
|
||||
if err := o(ctx, client, c, s); err != nil {
|
||||
return err
|
||||
@@ -40,7 +40,7 @@ func Compose(opts ...SpecOpts) SpecOpts {
|
||||
}
|
||||
|
||||
// setProcess sets Process to empty if unset
|
||||
func setProcess(s *specs.Spec) {
|
||||
func setProcess(s *Spec) {
|
||||
if s.Process == nil {
|
||||
s.Process = &specs.Process{}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ func setProcess(s *specs.Spec) {
|
||||
|
||||
// WithProcessArgs replaces the args on the generated spec
|
||||
func WithProcessArgs(args ...string) SpecOpts {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
setProcess(s)
|
||||
s.Process.Args = args
|
||||
return nil
|
||||
@@ -57,7 +57,7 @@ func WithProcessArgs(args ...string) SpecOpts {
|
||||
|
||||
// WithProcessCwd replaces the current working directory on the generated spec
|
||||
func WithProcessCwd(cwd string) SpecOpts {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
setProcess(s)
|
||||
s.Process.Cwd = cwd
|
||||
return nil
|
||||
@@ -66,7 +66,7 @@ func WithProcessCwd(cwd string) SpecOpts {
|
||||
|
||||
// WithHostname sets the container's hostname
|
||||
func WithHostname(name string) SpecOpts {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
s.Hostname = name
|
||||
return nil
|
||||
}
|
||||
@@ -74,7 +74,7 @@ func WithHostname(name string) SpecOpts {
|
||||
|
||||
// WithEnv appends environment variables
|
||||
func WithEnv(environmentVariables []string) SpecOpts {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
if len(environmentVariables) > 0 {
|
||||
setProcess(s)
|
||||
s.Process.Env = replaceOrAppendEnvValues(s.Process.Env, environmentVariables)
|
||||
@@ -85,7 +85,7 @@ func WithEnv(environmentVariables []string) SpecOpts {
|
||||
|
||||
// WithMounts appends mounts
|
||||
func WithMounts(mounts []specs.Mount) SpecOpts {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
s.Mounts = append(s.Mounts, mounts...)
|
||||
return nil
|
||||
}
|
||||
|
||||
56
vendor/github.com/containerd/containerd/oci/spec_opts_unix.go
generated
vendored
56
vendor/github.com/containerd/containerd/oci/spec_opts_unix.go
generated
vendored
@@ -42,7 +42,7 @@ import (
|
||||
|
||||
// WithTTY sets the information on the spec as well as the environment variables for
|
||||
// using a TTY
|
||||
func WithTTY(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
func WithTTY(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
setProcess(s)
|
||||
s.Process.Terminal = true
|
||||
s.Process.Env = append(s.Process.Env, "TERM=xterm")
|
||||
@@ -50,21 +50,21 @@ func WithTTY(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec
|
||||
}
|
||||
|
||||
// setRoot sets Root to empty if unset
|
||||
func setRoot(s *specs.Spec) {
|
||||
func setRoot(s *Spec) {
|
||||
if s.Root == nil {
|
||||
s.Root = &specs.Root{}
|
||||
}
|
||||
}
|
||||
|
||||
// setLinux sets Linux to empty if unset
|
||||
func setLinux(s *specs.Spec) {
|
||||
func setLinux(s *Spec) {
|
||||
if s.Linux == nil {
|
||||
s.Linux = &specs.Linux{}
|
||||
}
|
||||
}
|
||||
|
||||
// setCapabilities sets Linux Capabilities to empty if unset
|
||||
func setCapabilities(s *specs.Spec) {
|
||||
func setCapabilities(s *Spec) {
|
||||
setProcess(s)
|
||||
if s.Process.Capabilities == nil {
|
||||
s.Process.Capabilities = &specs.LinuxCapabilities{}
|
||||
@@ -73,7 +73,7 @@ func setCapabilities(s *specs.Spec) {
|
||||
|
||||
// WithHostNamespace allows a task to run inside the host's linux namespace
|
||||
func WithHostNamespace(ns specs.LinuxNamespaceType) SpecOpts {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
setLinux(s)
|
||||
for i, n := range s.Linux.Namespaces {
|
||||
if n.Type == ns {
|
||||
@@ -88,7 +88,7 @@ func WithHostNamespace(ns specs.LinuxNamespaceType) SpecOpts {
|
||||
// WithLinuxNamespace uses the passed in namespace for the spec. If a namespace of the same type already exists in the
|
||||
// spec, the existing namespace is replaced by the one provided.
|
||||
func WithLinuxNamespace(ns specs.LinuxNamespace) SpecOpts {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
setLinux(s)
|
||||
for i, n := range s.Linux.Namespaces {
|
||||
if n.Type == ns.Type {
|
||||
@@ -106,7 +106,7 @@ func WithLinuxNamespace(ns specs.LinuxNamespace) SpecOpts {
|
||||
|
||||
// WithImageConfig configures the spec to from the configuration of an Image
|
||||
func WithImageConfig(image Image) SpecOpts {
|
||||
return func(ctx context.Context, client Client, c *containers.Container, s *specs.Spec) error {
|
||||
return func(ctx context.Context, client Client, c *containers.Container, s *Spec) error {
|
||||
ic, err := image.Config(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -148,7 +148,7 @@ func WithImageConfig(image Image) SpecOpts {
|
||||
|
||||
// WithRootFSPath specifies unmanaged rootfs path.
|
||||
func WithRootFSPath(path string) SpecOpts {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
setRoot(s)
|
||||
s.Root.Path = path
|
||||
// Entrypoint is not set here (it's up to caller)
|
||||
@@ -158,7 +158,7 @@ func WithRootFSPath(path string) SpecOpts {
|
||||
|
||||
// WithRootFSReadonly sets specs.Root.Readonly to true
|
||||
func WithRootFSReadonly() SpecOpts {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
setRoot(s)
|
||||
s.Root.Readonly = true
|
||||
return nil
|
||||
@@ -166,14 +166,14 @@ func WithRootFSReadonly() SpecOpts {
|
||||
}
|
||||
|
||||
// WithNoNewPrivileges sets no_new_privileges on the process for the container
|
||||
func WithNoNewPrivileges(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
func WithNoNewPrivileges(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
setProcess(s)
|
||||
s.Process.NoNewPrivileges = true
|
||||
return nil
|
||||
}
|
||||
|
||||
// WithHostHostsFile bind-mounts the host's /etc/hosts into the container as readonly
|
||||
func WithHostHostsFile(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
func WithHostHostsFile(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
s.Mounts = append(s.Mounts, specs.Mount{
|
||||
Destination: "/etc/hosts",
|
||||
Type: "bind",
|
||||
@@ -184,7 +184,7 @@ func WithHostHostsFile(_ context.Context, _ Client, _ *containers.Container, s *
|
||||
}
|
||||
|
||||
// WithHostResolvconf bind-mounts the host's /etc/resolv.conf into the container as readonly
|
||||
func WithHostResolvconf(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
func WithHostResolvconf(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
s.Mounts = append(s.Mounts, specs.Mount{
|
||||
Destination: "/etc/resolv.conf",
|
||||
Type: "bind",
|
||||
@@ -195,7 +195,7 @@ func WithHostResolvconf(_ context.Context, _ Client, _ *containers.Container, s
|
||||
}
|
||||
|
||||
// WithHostLocaltime bind-mounts the host's /etc/localtime into the container as readonly
|
||||
func WithHostLocaltime(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
func WithHostLocaltime(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
s.Mounts = append(s.Mounts, specs.Mount{
|
||||
Destination: "/etc/localtime",
|
||||
Type: "bind",
|
||||
@@ -208,7 +208,7 @@ func WithHostLocaltime(_ context.Context, _ Client, _ *containers.Container, s *
|
||||
// WithUserNamespace sets the uid and gid mappings for the task
|
||||
// this can be called multiple times to add more mappings to the generated spec
|
||||
func WithUserNamespace(container, host, size uint32) SpecOpts {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
var hasUserns bool
|
||||
setLinux(s)
|
||||
for _, ns := range s.Linux.Namespaces {
|
||||
@@ -235,7 +235,7 @@ func WithUserNamespace(container, host, size uint32) SpecOpts {
|
||||
|
||||
// WithCgroup sets the container's cgroup path
|
||||
func WithCgroup(path string) SpecOpts {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
setLinux(s)
|
||||
s.Linux.CgroupsPath = path
|
||||
return nil
|
||||
@@ -245,7 +245,7 @@ func WithCgroup(path string) SpecOpts {
|
||||
// WithNamespacedCgroup uses the namespace set on the context to create a
|
||||
// root directory for containers in the cgroup with the id as the subcgroup
|
||||
func WithNamespacedCgroup() SpecOpts {
|
||||
return func(ctx context.Context, _ Client, c *containers.Container, s *specs.Spec) error {
|
||||
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
|
||||
namespace, err := namespaces.NamespaceRequired(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -260,7 +260,7 @@ func WithNamespacedCgroup() SpecOpts {
|
||||
// It accepts a valid user string in OCI Image Spec v1.0.0:
|
||||
// user, uid, user:group, uid:gid, uid:group, user:gid
|
||||
func WithUser(userstr string) SpecOpts {
|
||||
return func(ctx context.Context, client Client, c *containers.Container, s *specs.Spec) error {
|
||||
return func(ctx context.Context, client Client, c *containers.Container, s *Spec) error {
|
||||
setProcess(s)
|
||||
parts := strings.Split(userstr, ":")
|
||||
switch len(parts) {
|
||||
@@ -338,7 +338,7 @@ func WithUser(userstr string) SpecOpts {
|
||||
|
||||
// WithUIDGID allows the UID and GID for the Process to be set
|
||||
func WithUIDGID(uid, gid uint32) SpecOpts {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
setProcess(s)
|
||||
s.Process.User.UID = uid
|
||||
s.Process.User.GID = gid
|
||||
@@ -351,7 +351,7 @@ func WithUIDGID(uid, gid uint32) SpecOpts {
|
||||
// or uid is not found in /etc/passwd, it sets gid to be the same with
|
||||
// uid, and not returns error.
|
||||
func WithUserID(uid uint32) SpecOpts {
|
||||
return func(ctx context.Context, client Client, c *containers.Container, s *specs.Spec) (err error) {
|
||||
return func(ctx context.Context, client Client, c *containers.Container, s *Spec) (err error) {
|
||||
setProcess(s)
|
||||
if c.Snapshotter == "" && c.SnapshotKey == "" {
|
||||
if !isRootfsAbs(s.Root.Path) {
|
||||
@@ -404,7 +404,7 @@ func WithUserID(uid uint32) SpecOpts {
|
||||
// does not exist, or the username is not found in /etc/passwd,
|
||||
// it returns error.
|
||||
func WithUsername(username string) SpecOpts {
|
||||
return func(ctx context.Context, client Client, c *containers.Container, s *specs.Spec) (err error) {
|
||||
return func(ctx context.Context, client Client, c *containers.Container, s *Spec) (err error) {
|
||||
setProcess(s)
|
||||
if c.Snapshotter == "" && c.SnapshotKey == "" {
|
||||
if !isRootfsAbs(s.Root.Path) {
|
||||
@@ -445,7 +445,7 @@ func WithUsername(username string) SpecOpts {
|
||||
|
||||
// WithCapabilities sets Linux capabilities on the process
|
||||
func WithCapabilities(caps []string) SpecOpts {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
setCapabilities(s)
|
||||
|
||||
s.Process.Capabilities.Bounding = caps
|
||||
@@ -518,7 +518,7 @@ func isRootfsAbs(root string) bool {
|
||||
|
||||
// WithMaskedPaths sets the masked paths option
|
||||
func WithMaskedPaths(paths []string) SpecOpts {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
setLinux(s)
|
||||
s.Linux.MaskedPaths = paths
|
||||
return nil
|
||||
@@ -527,7 +527,7 @@ func WithMaskedPaths(paths []string) SpecOpts {
|
||||
|
||||
// WithReadonlyPaths sets the read only paths option
|
||||
func WithReadonlyPaths(paths []string) SpecOpts {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
setLinux(s)
|
||||
s.Linux.ReadonlyPaths = paths
|
||||
return nil
|
||||
@@ -535,7 +535,7 @@ func WithReadonlyPaths(paths []string) SpecOpts {
|
||||
}
|
||||
|
||||
// WithWriteableSysfs makes any sysfs mounts writeable
|
||||
func WithWriteableSysfs(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
func WithWriteableSysfs(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
for i, m := range s.Mounts {
|
||||
if m.Type == "sysfs" {
|
||||
var options []string
|
||||
@@ -552,7 +552,7 @@ func WithWriteableSysfs(_ context.Context, _ Client, _ *containers.Container, s
|
||||
}
|
||||
|
||||
// WithWriteableCgroupfs makes any cgroup mounts writeable
|
||||
func WithWriteableCgroupfs(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
func WithWriteableCgroupfs(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
for i, m := range s.Mounts {
|
||||
if m.Type == "cgroup" {
|
||||
var options []string
|
||||
@@ -570,7 +570,7 @@ func WithWriteableCgroupfs(_ context.Context, _ Client, _ *containers.Container,
|
||||
|
||||
// WithSelinuxLabel sets the process SELinux label
|
||||
func WithSelinuxLabel(label string) SpecOpts {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
setProcess(s)
|
||||
s.Process.SelinuxLabel = label
|
||||
return nil
|
||||
@@ -579,7 +579,7 @@ func WithSelinuxLabel(label string) SpecOpts {
|
||||
|
||||
// WithApparmorProfile sets the Apparmor profile for the process
|
||||
func WithApparmorProfile(profile string) SpecOpts {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
setProcess(s)
|
||||
s.Process.ApparmorProfile = profile
|
||||
return nil
|
||||
@@ -587,7 +587,7 @@ func WithApparmorProfile(profile string) SpecOpts {
|
||||
}
|
||||
|
||||
// WithSeccompUnconfined clears the seccomp profile
|
||||
func WithSeccompUnconfined(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
func WithSeccompUnconfined(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
setLinux(s)
|
||||
s.Linux.Seccomp = nil
|
||||
return nil
|
||||
|
||||
6
vendor/github.com/containerd/containerd/oci/spec_opts_windows.go
generated
vendored
6
vendor/github.com/containerd/containerd/oci/spec_opts_windows.go
generated
vendored
@@ -32,7 +32,7 @@ import (
|
||||
|
||||
// WithImageConfig configures the spec to from the configuration of an Image
|
||||
func WithImageConfig(image Image) SpecOpts {
|
||||
return func(ctx context.Context, client Client, _ *containers.Container, s *specs.Spec) error {
|
||||
return func(ctx context.Context, client Client, _ *containers.Container, s *Spec) error {
|
||||
setProcess(s)
|
||||
ic, err := image.Config(ctx)
|
||||
if err != nil {
|
||||
@@ -67,7 +67,7 @@ func WithImageConfig(image Image) SpecOpts {
|
||||
// WithTTY sets the information on the spec as well as the environment variables for
|
||||
// using a TTY
|
||||
func WithTTY(width, height int) SpecOpts {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *specs.Spec) error {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
setProcess(s)
|
||||
s.Process.Terminal = true
|
||||
if s.Process.ConsoleSize == nil {
|
||||
@@ -81,7 +81,7 @@ func WithTTY(width, height int) SpecOpts {
|
||||
|
||||
// WithUsername sets the username on the process
|
||||
func WithUsername(username string) SpecOpts {
|
||||
return func(ctx context.Context, client Client, c *containers.Container, s *specs.Spec) error {
|
||||
return func(ctx context.Context, client Client, c *containers.Container, s *Spec) error {
|
||||
setProcess(s)
|
||||
s.Process.User.Username = username
|
||||
return nil
|
||||
|
||||
4
vendor/github.com/containerd/containerd/oci/spec_unix.go
generated
vendored
4
vendor/github.com/containerd/containerd/oci/spec_unix.go
generated
vendored
@@ -76,12 +76,12 @@ func defaultNamespaces() []specs.LinuxNamespace {
|
||||
}
|
||||
}
|
||||
|
||||
func createDefaultSpec(ctx context.Context, id string) (*specs.Spec, error) {
|
||||
func createDefaultSpec(ctx context.Context, id string) (*Spec, error) {
|
||||
ns, err := namespaces.NamespaceRequired(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s := &specs.Spec{
|
||||
s := &Spec{
|
||||
Version: specs.Version,
|
||||
Root: &specs.Root{
|
||||
Path: defaultRootfsPath,
|
||||
|
||||
4
vendor/github.com/containerd/containerd/oci/spec_windows.go
generated
vendored
4
vendor/github.com/containerd/containerd/oci/spec_windows.go
generated
vendored
@@ -22,8 +22,8 @@ import (
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
)
|
||||
|
||||
func createDefaultSpec(ctx context.Context, id string) (*specs.Spec, error) {
|
||||
return &specs.Spec{
|
||||
func createDefaultSpec(ctx context.Context, id string) (*Spec, error) {
|
||||
return &Spec{
|
||||
Version: specs.Version,
|
||||
Root: &specs.Root{},
|
||||
Process: &specs.Process{
|
||||
|
||||
4
vendor/github.com/containerd/containerd/plugin/plugin.go
generated
vendored
4
vendor/github.com/containerd/containerd/plugin/plugin.go
generated
vendored
@@ -54,8 +54,8 @@ type Type string
|
||||
func (t Type) String() string { return string(t) }
|
||||
|
||||
const (
|
||||
// AllPlugins declares that the plugin should be initialized after all others.
|
||||
AllPlugins Type = "*"
|
||||
// InternalPlugin implements an internal plugin to containerd
|
||||
InternalPlugin Type = "io.containerd.internal.v1"
|
||||
// RuntimePlugin implements a runtime
|
||||
RuntimePlugin Type = "io.containerd.runtime.v1"
|
||||
// ServicePlugin implements a internal service
|
||||
|
||||
119
vendor/github.com/containerd/containerd/rootfs/apply.go
generated
vendored
119
vendor/github.com/containerd/containerd/rootfs/apply.go
generated
vendored
@@ -17,6 +17,7 @@
|
||||
package rootfs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
@@ -25,12 +26,12 @@ import (
|
||||
"github.com/containerd/containerd/diff"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/mount"
|
||||
"github.com/containerd/containerd/snapshots"
|
||||
"github.com/opencontainers/go-digest"
|
||||
"github.com/opencontainers/image-spec/identity"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// Layer represents the descriptors for a layer diff. These descriptions
|
||||
@@ -47,16 +48,27 @@ type Layer struct {
|
||||
// Layers are applied in order they are given, making the first layer the
|
||||
// bottom-most layer in the layer chain.
|
||||
func ApplyLayers(ctx context.Context, layers []Layer, sn snapshots.Snapshotter, a diff.Applier) (digest.Digest, error) {
|
||||
var chain []digest.Digest
|
||||
for _, layer := range layers {
|
||||
if _, err := ApplyLayer(ctx, layer, chain, sn, a); err != nil {
|
||||
// TODO: possibly wait and retry if extraction of same chain id was in progress
|
||||
return "", err
|
||||
chain := make([]digest.Digest, len(layers))
|
||||
for i, layer := range layers {
|
||||
chain[i] = layer.Diff.Digest
|
||||
}
|
||||
chainID := identity.ChainID(chain)
|
||||
|
||||
// Just stat top layer, remaining layers will have their existence checked
|
||||
// on prepare. Calling prepare on upper layers first guarantees that upper
|
||||
// layers are not removed while calling stat on lower layers
|
||||
_, err := sn.Stat(ctx, chainID.String())
|
||||
if err != nil {
|
||||
if !errdefs.IsNotFound(err) {
|
||||
return "", errors.Wrapf(err, "failed to stat snapshot %s", chainID)
|
||||
}
|
||||
|
||||
chain = append(chain, layer.Diff.Digest)
|
||||
if err := applyLayers(ctx, layers, chain, sn, a); err != nil && !errdefs.IsAlreadyExists(err) {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
return identity.ChainID(chain), nil
|
||||
|
||||
return chainID, nil
|
||||
}
|
||||
|
||||
// ApplyLayer applies a single layer on top of the given provided layer chain,
|
||||
@@ -64,59 +76,90 @@ func ApplyLayers(ctx context.Context, layers []Layer, sn snapshots.Snapshotter,
|
||||
// is returned, if the layer already exists false is returned.
|
||||
func ApplyLayer(ctx context.Context, layer Layer, chain []digest.Digest, sn snapshots.Snapshotter, a diff.Applier, opts ...snapshots.Opt) (bool, error) {
|
||||
var (
|
||||
parent = identity.ChainID(chain)
|
||||
chainID = identity.ChainID(append(chain, layer.Diff.Digest))
|
||||
chainID = identity.ChainID(append(chain, layer.Diff.Digest)).String()
|
||||
applied bool
|
||||
)
|
||||
if _, err := sn.Stat(ctx, chainID); err != nil {
|
||||
if !errdefs.IsNotFound(err) {
|
||||
return false, errors.Wrapf(err, "failed to stat snapshot %s", chainID)
|
||||
}
|
||||
|
||||
if err := applyLayers(ctx, []Layer{layer}, append(chain, layer.Diff.Digest), sn, a, opts...); err != nil {
|
||||
if !errdefs.IsAlreadyExists(err) {
|
||||
return false, err
|
||||
}
|
||||
} else {
|
||||
applied = true
|
||||
}
|
||||
}
|
||||
return applied, nil
|
||||
}
|
||||
|
||||
func applyLayers(ctx context.Context, layers []Layer, chain []digest.Digest, sn snapshots.Snapshotter, a diff.Applier, opts ...snapshots.Opt) error {
|
||||
var (
|
||||
parent = identity.ChainID(chain[:len(chain)-1])
|
||||
chainID = identity.ChainID(chain)
|
||||
layer = layers[len(layers)-1]
|
||||
diff ocispec.Descriptor
|
||||
key string
|
||||
mounts []mount.Mount
|
||||
err error
|
||||
)
|
||||
|
||||
_, err := sn.Stat(ctx, chainID.String())
|
||||
if err == nil {
|
||||
log.G(ctx).Debugf("Extraction not needed, layer snapshot %s exists", chainID)
|
||||
return false, nil
|
||||
} else if !errdefs.IsNotFound(err) {
|
||||
return false, errors.Wrapf(err, "failed to stat snapshot %s", chainID)
|
||||
}
|
||||
for {
|
||||
key = fmt.Sprintf("extract-%s %s", uniquePart(), chainID)
|
||||
|
||||
key := fmt.Sprintf("extract-%s %s", uniquePart(), chainID)
|
||||
// Prepare snapshot with from parent, label as root
|
||||
mounts, err = sn.Prepare(ctx, key, parent.String(), opts...)
|
||||
if err != nil {
|
||||
if errdefs.IsNotFound(err) && len(layers) > 1 {
|
||||
if err := applyLayers(ctx, layers[:len(layers)-1], chain[:len(chain)-1], sn, a); err != nil {
|
||||
if !errdefs.IsAlreadyExists(err) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// Do no try applying layers again
|
||||
layers = nil
|
||||
continue
|
||||
} else if errdefs.IsAlreadyExists(err) {
|
||||
// Try a different key
|
||||
continue
|
||||
}
|
||||
|
||||
// Prepare snapshot with from parent, label as root
|
||||
mounts, err := sn.Prepare(ctx, key, parent.String(), opts...)
|
||||
if err != nil {
|
||||
//TODO: If is snapshot exists error, retry
|
||||
return false, errors.Wrapf(err, "failed to prepare extraction snapshot %q", key)
|
||||
// Already exists should have the caller retry
|
||||
return errors.Wrapf(err, "failed to prepare extraction snapshot %q", key)
|
||||
|
||||
}
|
||||
break
|
||||
}
|
||||
defer func() {
|
||||
if err != nil {
|
||||
log.G(ctx).WithError(err).WithField("key", key).Infof("Apply failure, attempting cleanup")
|
||||
if !errdefs.IsAlreadyExists(err) {
|
||||
log.G(ctx).WithError(err).WithField("key", key).Infof("apply failure, attempting cleanup")
|
||||
}
|
||||
|
||||
if rerr := sn.Remove(ctx, key); rerr != nil {
|
||||
log.G(ctx).WithError(rerr).Warnf("Extraction snapshot %q removal failed", key)
|
||||
log.G(ctx).WithError(rerr).WithField("key", key).Warnf("extraction snapshot removal failed")
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
diff, err = a.Apply(ctx, layer.Blob, mounts)
|
||||
if err != nil {
|
||||
return false, errors.Wrapf(err, "failed to extract layer %s", layer.Diff.Digest)
|
||||
err = errors.Wrapf(err, "failed to extract layer %s", layer.Diff.Digest)
|
||||
return err
|
||||
}
|
||||
if diff.Digest != layer.Diff.Digest {
|
||||
err = errors.Errorf("wrong diff id calculated on extraction %q", diff.Digest)
|
||||
return false, err
|
||||
return err
|
||||
}
|
||||
|
||||
if err = sn.Commit(ctx, chainID.String(), key, opts...); err != nil {
|
||||
if !errdefs.IsAlreadyExists(err) {
|
||||
return false, errors.Wrapf(err, "failed to commit snapshot %s", key)
|
||||
}
|
||||
|
||||
// Destination already exists, cleanup key and return without error
|
||||
err = nil
|
||||
if err := sn.Remove(ctx, key); err != nil {
|
||||
return false, errors.Wrapf(err, "failed to cleanup aborted apply %s", key)
|
||||
}
|
||||
return false, nil
|
||||
err = errors.Wrapf(err, "failed to commit snapshot %s", key)
|
||||
return err
|
||||
}
|
||||
|
||||
return true, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func uniquePart() string {
|
||||
|
||||
2
vendor/github.com/containerd/containerd/rootfs/diff.go
generated
vendored
2
vendor/github.com/containerd/containerd/rootfs/diff.go
generated
vendored
@@ -17,13 +17,13 @@
|
||||
package rootfs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/containerd/containerd/diff"
|
||||
"github.com/containerd/containerd/mount"
|
||||
"github.com/containerd/containerd/snapshots"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// CreateDiff creates a layer diff for the given snapshot identifier from the
|
||||
|
||||
2
vendor/github.com/containerd/containerd/rootfs/init.go
generated
vendored
2
vendor/github.com/containerd/containerd/rootfs/init.go
generated
vendored
@@ -75,7 +75,7 @@ func createInitLayer(ctx context.Context, parent, initName string, initFn func(s
|
||||
// TODO: ensure not exist error once added to snapshot package
|
||||
|
||||
// Create tempdir
|
||||
td, err := ioutil.TempDir("", "create-init-")
|
||||
td, err := ioutil.TempDir(os.Getenv("XDG_RUNTIME_DIR"), "create-init-")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
6
vendor/github.com/containerd/containerd/runtime/runtime.go
generated
vendored
6
vendor/github.com/containerd/containerd/runtime/runtime.go
generated
vendored
@@ -53,9 +53,9 @@ type Exit struct {
|
||||
Timestamp time.Time
|
||||
}
|
||||
|
||||
// Runtime is responsible for the creation of containers for a certain platform,
|
||||
// arch, or custom usage.
|
||||
type Runtime interface {
|
||||
// PlatformRuntime is responsible for the creation and management of
|
||||
// tasks and processes for a platform.
|
||||
type PlatformRuntime interface {
|
||||
// ID of the runtime
|
||||
ID() string
|
||||
// Create creates a task with the provided id and options.
|
||||
|
||||
4
vendor/github.com/containerd/containerd/server/server.go
generated
vendored
4
vendor/github.com/containerd/containerd/server/server.go
generated
vendored
@@ -17,6 +17,7 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"expvar"
|
||||
"io"
|
||||
"net"
|
||||
@@ -37,7 +38,6 @@ import (
|
||||
metrics "github.com/docker/go-metrics"
|
||||
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
@@ -146,7 +146,7 @@ func (s *Server) ServeGRPC(l net.Listener) error {
|
||||
// enable grpc time histograms to measure rpc latencies
|
||||
grpc_prometheus.EnableHandlingTimeHistogram()
|
||||
}
|
||||
// before we start serving the grpc API regster the grpc_prometheus metrics
|
||||
// before we start serving the grpc API register the grpc_prometheus metrics
|
||||
// handler. This needs to be the last service registered so that it can collect
|
||||
// metrics for every other service
|
||||
grpc_prometheus.Register(s.rpc)
|
||||
|
||||
3
vendor/github.com/containerd/containerd/services/containers/local.go
generated
vendored
3
vendor/github.com/containerd/containerd/services/containers/local.go
generated
vendored
@@ -17,6 +17,8 @@
|
||||
package containers
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/boltdb/bolt"
|
||||
eventstypes "github.com/containerd/containerd/api/events"
|
||||
api "github.com/containerd/containerd/api/services/containers/v1"
|
||||
@@ -27,7 +29,6 @@ import (
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/services"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
3
vendor/github.com/containerd/containerd/services/containers/service.go
generated
vendored
3
vendor/github.com/containerd/containerd/services/containers/service.go
generated
vendored
@@ -17,12 +17,13 @@
|
||||
package containers
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
api "github.com/containerd/containerd/api/services/containers/v1"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/services"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
|
||||
2
vendor/github.com/containerd/containerd/services/content/service.go
generated
vendored
2
vendor/github.com/containerd/containerd/services/content/service.go
generated
vendored
@@ -17,6 +17,7 @@
|
||||
package content
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"sync"
|
||||
|
||||
@@ -30,7 +31,6 @@ import (
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
3
vendor/github.com/containerd/containerd/services/diff/local.go
generated
vendored
3
vendor/github.com/containerd/containerd/services/diff/local.go
generated
vendored
@@ -17,6 +17,8 @@
|
||||
package diff
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
diffapi "github.com/containerd/containerd/api/services/diff/v1"
|
||||
"github.com/containerd/containerd/api/types"
|
||||
"github.com/containerd/containerd/diff"
|
||||
@@ -26,7 +28,6 @@ import (
|
||||
"github.com/containerd/containerd/services"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
|
||||
3
vendor/github.com/containerd/containerd/services/diff/service.go
generated
vendored
3
vendor/github.com/containerd/containerd/services/diff/service.go
generated
vendored
@@ -17,11 +17,12 @@
|
||||
package diff
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
diffapi "github.com/containerd/containerd/api/services/diff/v1"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/services"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
|
||||
3
vendor/github.com/containerd/containerd/services/events/service.go
generated
vendored
3
vendor/github.com/containerd/containerd/services/events/service.go
generated
vendored
@@ -17,6 +17,8 @@
|
||||
package events
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
api "github.com/containerd/containerd/api/services/events/v1"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/events"
|
||||
@@ -24,7 +26,6 @@ import (
|
||||
"github.com/containerd/containerd/plugin"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
|
||||
5
vendor/github.com/containerd/containerd/services/images/local.go
generated
vendored
5
vendor/github.com/containerd/containerd/services/images/local.go
generated
vendored
@@ -17,7 +17,7 @@
|
||||
package images
|
||||
|
||||
import (
|
||||
gocontext "context"
|
||||
"context"
|
||||
|
||||
eventstypes "github.com/containerd/containerd/api/events"
|
||||
imagesapi "github.com/containerd/containerd/api/services/images/v1"
|
||||
@@ -30,7 +30,6 @@ import (
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/services"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
@@ -64,7 +63,7 @@ func init() {
|
||||
}
|
||||
|
||||
type gcScheduler interface {
|
||||
ScheduleAndWait(gocontext.Context) (gc.Stats, error)
|
||||
ScheduleAndWait(context.Context) (gc.Stats, error)
|
||||
}
|
||||
|
||||
type local struct {
|
||||
|
||||
3
vendor/github.com/containerd/containerd/services/images/service.go
generated
vendored
3
vendor/github.com/containerd/containerd/services/images/service.go
generated
vendored
@@ -17,12 +17,13 @@
|
||||
package images
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
imagesapi "github.com/containerd/containerd/api/services/images/v1"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/services"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
|
||||
3
vendor/github.com/containerd/containerd/services/introspection/service.go
generated
vendored
3
vendor/github.com/containerd/containerd/services/introspection/service.go
generated
vendored
@@ -17,6 +17,8 @@
|
||||
package introspection
|
||||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
api "github.com/containerd/containerd/api/services/introspection/v1"
|
||||
"github.com/containerd/containerd/api/types"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
@@ -24,7 +26,6 @@ import (
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/gogo/googleapis/google/rpc"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
context "golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
2
vendor/github.com/containerd/containerd/services/leases/local.go
generated
vendored
2
vendor/github.com/containerd/containerd/services/leases/local.go
generated
vendored
@@ -17,6 +17,7 @@
|
||||
package leases
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
@@ -30,7 +31,6 @@ import (
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/services"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
3
vendor/github.com/containerd/containerd/services/leases/service.go
generated
vendored
3
vendor/github.com/containerd/containerd/services/leases/service.go
generated
vendored
@@ -17,6 +17,8 @@
|
||||
package leases
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
api "github.com/containerd/containerd/api/services/leases/v1"
|
||||
@@ -24,7 +26,6 @@ import (
|
||||
"github.com/containerd/containerd/services"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
2
vendor/github.com/containerd/containerd/services/namespaces/local.go
generated
vendored
2
vendor/github.com/containerd/containerd/services/namespaces/local.go
generated
vendored
@@ -17,6 +17,7 @@
|
||||
package namespaces
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/boltdb/bolt"
|
||||
@@ -29,7 +30,6 @@ import (
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/services"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
3
vendor/github.com/containerd/containerd/services/namespaces/service.go
generated
vendored
3
vendor/github.com/containerd/containerd/services/namespaces/service.go
generated
vendored
@@ -17,12 +17,13 @@
|
||||
package namespaces
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
api "github.com/containerd/containerd/api/services/namespaces/v1"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/services"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
|
||||
5
vendor/github.com/containerd/containerd/services/snapshots/service.go
generated
vendored
5
vendor/github.com/containerd/containerd/services/snapshots/service.go
generated
vendored
@@ -17,7 +17,7 @@
|
||||
package snapshots
|
||||
|
||||
import (
|
||||
gocontext "context"
|
||||
"context"
|
||||
|
||||
snapshotsapi "github.com/containerd/containerd/api/services/snapshots/v1"
|
||||
"github.com/containerd/containerd/api/types"
|
||||
@@ -29,7 +29,6 @@ import (
|
||||
"github.com/containerd/containerd/snapshots"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
@@ -216,7 +215,7 @@ func (s *service) List(sr *snapshotsapi.ListSnapshotsRequest, ss snapshotsapi.Sn
|
||||
})
|
||||
}
|
||||
)
|
||||
err = sn.Walk(ss.Context(), func(ctx gocontext.Context, info snapshots.Info) error {
|
||||
err = sn.Walk(ss.Context(), func(ctx context.Context, info snapshots.Info) error {
|
||||
buffer = append(buffer, fromInfo(info))
|
||||
|
||||
if len(buffer) >= 100 {
|
||||
|
||||
14
vendor/github.com/containerd/containerd/services/tasks/local.go
generated
vendored
14
vendor/github.com/containerd/containerd/services/tasks/local.go
generated
vendored
@@ -18,6 +18,7 @@ package tasks
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
@@ -45,7 +46,6 @@ import (
|
||||
"github.com/containerd/typeurl"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
@@ -79,14 +79,14 @@ func initFunc(ic *plugin.InitContext) (interface{}, error) {
|
||||
return nil, err
|
||||
}
|
||||
cs := m.(*metadata.DB).ContentStore()
|
||||
runtimes := make(map[string]runtime.Runtime)
|
||||
runtimes := make(map[string]runtime.PlatformRuntime)
|
||||
for _, rr := range rt {
|
||||
ri, err := rr.Instance()
|
||||
if err != nil {
|
||||
log.G(ic.Context).WithError(err).Warn("could not load runtime instance due to initialization error")
|
||||
continue
|
||||
}
|
||||
r := ri.(runtime.Runtime)
|
||||
r := ri.(runtime.PlatformRuntime)
|
||||
runtimes[r.ID()] = r
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ func initFunc(ic *plugin.InitContext) (interface{}, error) {
|
||||
}
|
||||
|
||||
type local struct {
|
||||
runtimes map[string]runtime.Runtime
|
||||
runtimes map[string]runtime.PlatformRuntime
|
||||
db *metadata.DB
|
||||
store content.Store
|
||||
publisher events.Publisher
|
||||
@@ -114,7 +114,7 @@ func (l *local) Create(ctx context.Context, r *api.CreateTaskRequest, _ ...grpc.
|
||||
err error
|
||||
)
|
||||
if r.Checkpoint != nil {
|
||||
checkpointPath, err = ioutil.TempDir("", "ctrd-checkpoint")
|
||||
checkpointPath, err = ioutil.TempDir(os.Getenv("XDG_RUNTIME_DIR"), "ctrd-checkpoint")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -450,7 +450,7 @@ func (l *local) Checkpoint(ctx context.Context, r *api.CheckpointTaskRequest, _
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
image, err := ioutil.TempDir("", "ctd-checkpoint")
|
||||
image, err := ioutil.TempDir(os.Getenv("XDG_RUNTIME_DIR"), "ctd-checkpoint")
|
||||
if err != nil {
|
||||
return nil, errdefs.ToGRPC(err)
|
||||
}
|
||||
@@ -625,7 +625,7 @@ func (l *local) getTaskFromContainer(ctx context.Context, container *containers.
|
||||
return t, nil
|
||||
}
|
||||
|
||||
func (l *local) getRuntime(name string) (runtime.Runtime, error) {
|
||||
func (l *local) getRuntime(name string) (runtime.PlatformRuntime, error) {
|
||||
runtime, ok := l.runtimes[name]
|
||||
if !ok {
|
||||
return nil, status.Errorf(codes.NotFound, "unknown runtime %q", name)
|
||||
|
||||
3
vendor/github.com/containerd/containerd/services/tasks/service.go
generated
vendored
3
vendor/github.com/containerd/containerd/services/tasks/service.go
generated
vendored
@@ -17,12 +17,13 @@
|
||||
package tasks
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
api "github.com/containerd/containerd/api/services/tasks/v1"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/services"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
|
||||
3
vendor/github.com/containerd/containerd/services/version/service.go
generated
vendored
3
vendor/github.com/containerd/containerd/services/version/service.go
generated
vendored
@@ -17,11 +17,12 @@
|
||||
package version
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
api "github.com/containerd/containerd/api/services/version/v1"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
ctrdversion "github.com/containerd/containerd/version"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
|
||||
33
vendor/github.com/containerd/containerd/sys/env.go
generated
vendored
Normal file
33
vendor/github.com/containerd/containerd/sys/env.go
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
// +build !windows
|
||||
|
||||
/*
|
||||
Copyright The containerd Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package sys
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
// RunningPrivileged returns true if the effective user ID of the
|
||||
// calling process is 0
|
||||
func RunningPrivileged() bool {
|
||||
return unix.Geteuid() == 0
|
||||
}
|
||||
|
||||
// RunningUnprivileged returns true if the effective user ID of the
|
||||
// calling process is not 0
|
||||
func RunningUnprivileged() bool {
|
||||
return !RunningPrivileged()
|
||||
}
|
||||
2
vendor/github.com/containerd/containerd/sys/oom_unix.go
generated
vendored
2
vendor/github.com/containerd/containerd/sys/oom_unix.go
generated
vendored
@@ -38,7 +38,7 @@ func SetOOMScore(pid, score int) error {
|
||||
}
|
||||
defer f.Close()
|
||||
if _, err = f.WriteString(strconv.Itoa(score)); err != nil {
|
||||
if os.IsPermission(err) && system.RunningInUserNS() {
|
||||
if os.IsPermission(err) && (system.RunningInUserNS() || RunningUnprivileged()) {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
|
||||
10
vendor/github.com/containerd/containerd/vendor.conf
generated
vendored
10
vendor/github.com/containerd/containerd/vendor.conf
generated
vendored
@@ -1,4 +1,4 @@
|
||||
github.com/containerd/go-runc bcb223a061a3dd7de1a89c0b402a60f4dd9bd307
|
||||
github.com/containerd/go-runc f271fa2021de855d4d918dbef83c5fe19db1bdd5
|
||||
github.com/containerd/console cb7008ab3d8359b78c5f464cb7cf160107ad5925
|
||||
github.com/containerd/cgroups fe281dd265766145e943a034aa41086474ea6130
|
||||
github.com/containerd/typeurl f6943554a7e7e88b3c14aad190bf05932da84788
|
||||
@@ -24,17 +24,17 @@ github.com/opencontainers/runc 69663f0bd4b60df09991c08812a60108003fa340
|
||||
github.com/sirupsen/logrus v1.0.0
|
||||
github.com/pmezard/go-difflib v1.0.0
|
||||
github.com/urfave/cli 7bc6a0acffa589f415f88aca16cc1de5ffd66f9c
|
||||
golang.org/x/net 7dcfb8076726a3fdd9353b6b8a1f1b6be6811bd6
|
||||
golang.org/x/net b3756b4b77d7b13260a0a2ec658753cf48922eac
|
||||
google.golang.org/grpc v1.10.1
|
||||
github.com/pkg/errors v0.8.0
|
||||
github.com/opencontainers/go-digest 21dfd564fd89c944783d00d069f33e3e7123c448
|
||||
github.com/opencontainers/go-digest c9281466c8b2f606084ac71339773efd177436e7
|
||||
golang.org/x/sys 314a259e304ff91bd6985da2a7149bbf91237993 https://github.com/golang/sys
|
||||
github.com/opencontainers/image-spec v1.0.1
|
||||
golang.org/x/sync 450f422ab23cf9881c94e2db30cac0eb1b7cf80c
|
||||
github.com/BurntSushi/toml a368813c5e648fee92e5f6c30e3944ff9d5e8895
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus 6b7015e65d366bf3f19b2b2a000a831940f0f7e0
|
||||
github.com/Microsoft/go-winio v0.4.5
|
||||
github.com/Microsoft/hcsshim v0.6.7
|
||||
github.com/Microsoft/hcsshim v0.6.10
|
||||
github.com/boltdb/bolt e9cf4fae01b5a8ff89d0ec6b32f0d9c9f79aefdd
|
||||
google.golang.org/genproto d80a6e20e776b0b17a324d0ba1ab50a39c8e8944
|
||||
golang.org/x/text 19e51611da83d6be54ddafce4a4af510cb3e9ea4
|
||||
@@ -44,7 +44,7 @@ github.com/gotestyourself/gotestyourself 44dbf532bbf5767611f6f2a61bded572e337010
|
||||
github.com/google/go-cmp v0.1.0
|
||||
|
||||
# cri dependencies
|
||||
github.com/containerd/cri v1.0.0-rc.2
|
||||
github.com/containerd/cri v1.0.0
|
||||
github.com/containerd/go-cni f2d7272f12d045b16ed924f50e91f9f9cecc55a7
|
||||
github.com/blang/semver v3.1.0
|
||||
github.com/containernetworking/cni v0.6.0
|
||||
|
||||
2
vendor/github.com/containerd/containerd/version/version.go
generated
vendored
2
vendor/github.com/containerd/containerd/version/version.go
generated
vendored
@@ -21,7 +21,7 @@ var (
|
||||
Package = "github.com/containerd/containerd"
|
||||
|
||||
// Version holds the complete version number. Filled in at linking time.
|
||||
Version = "1.1.0-rc.2+unknown"
|
||||
Version = "1.1.0+unknown"
|
||||
|
||||
// Revision is filled with the VCS (e.g. git) revision being used to build
|
||||
// the program at linking time.
|
||||
|
||||
2
vendor/github.com/containerd/go-runc/console.go
generated
vendored
2
vendor/github.com/containerd/go-runc/console.go
generated
vendored
@@ -43,7 +43,7 @@ func NewConsoleSocket(path string) (*Socket, error) {
|
||||
return nil, err
|
||||
}
|
||||
return &Socket{
|
||||
l: l,
|
||||
l: l,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
12
vendor/github.com/containerd/go-runc/runc.go
generated
vendored
12
vendor/github.com/containerd/go-runc/runc.go
generated
vendored
@@ -512,10 +512,11 @@ type RestoreOpts struct {
|
||||
CheckpointOpts
|
||||
IO
|
||||
|
||||
Detach bool
|
||||
PidFile string
|
||||
NoSubreaper bool
|
||||
NoPivot bool
|
||||
Detach bool
|
||||
PidFile string
|
||||
NoSubreaper bool
|
||||
NoPivot bool
|
||||
ConsoleSocket ConsoleSocket
|
||||
}
|
||||
|
||||
func (o *RestoreOpts) args() ([]string, error) {
|
||||
@@ -530,6 +531,9 @@ func (o *RestoreOpts) args() ([]string, error) {
|
||||
}
|
||||
out = append(out, "--pid-file", abs)
|
||||
}
|
||||
if o.ConsoleSocket != nil {
|
||||
out = append(out, "--console-socket", o.ConsoleSocket.Path())
|
||||
}
|
||||
if o.NoPivot {
|
||||
out = append(out, "--no-pivot")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user