Update containerd to v1.2.0.

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu
2018-11-12 11:12:41 -08:00
parent edf2b81778
commit f818de9dce
131 changed files with 2368 additions and 288 deletions

View File

@@ -1,4 +1,4 @@
![banner](https://github.com/containerd/containerd.io/blob/master/static/img/containerd-dark.png?raw=true)
![containerd banner](https://raw.githubusercontent.com/cncf/artwork/master/containerd/horizontal/color/containerd-horizontal-color.png)
[![GoDoc](https://godoc.org/github.com/containerd/containerd?status.svg)](https://godoc.org/github.com/containerd/containerd)
[![Build Status](https://travis-ci.org/containerd/containerd.svg?branch=master)](https://travis-ci.org/containerd/containerd)
@@ -236,3 +236,16 @@ The containerd codebase is released under the [Apache 2.0 license](LICENSE.code)
The README.md file, and files in the "docs" folder are licensed under the
Creative Commons Attribution 4.0 International License. You may obtain a
copy of the license, titled CC-BY-4.0, at http://creativecommons.org/licenses/by/4.0/.
## Project details
**containerd** is the primary open source project within the broader containerd GitHub repository.
However, all projects within the repo have common maintainership, governance, and contributing
guidelines which are stored in a `project` repository commonly for all containerd projects.
Please find all these core project documents, including the:
* [Project governance](https://github.com/containerd/project/blob/master/GOVERNANCE.md),
* [Maintainers](https://github.com/containerd/project/blob/master/MAINTAINERS),
* and [Contributing guidelines](https://github.com/containerd/project/blob/master/CONTRIBUTING.md)
information in our [`containerd/project`](https://github.com/containerd/project) repository.

View File

@@ -1,4 +1,4 @@
// +build linux freebsd solaris
// +build freebsd linux openbsd solaris
/*
Copyright The containerd Authors.

View File

@@ -23,12 +23,13 @@ import (
"github.com/BurntSushi/toml"
"github.com/containerd/containerd/services/server"
srvconfig "github.com/containerd/containerd/services/server/config"
"github.com/urfave/cli"
)
// Config is a wrapper of server config for printing out.
type Config struct {
*server.Config
*srvconfig.Config
// Plugins overrides `Plugins map[string]toml.Primitive` in server config.
Plugins map[string]interface{} `toml:"plugins"`
}

View File

@@ -18,14 +18,14 @@ package command
import (
"github.com/containerd/containerd/defaults"
"github.com/containerd/containerd/services/server"
srvconfig "github.com/containerd/containerd/services/server/config"
)
func defaultConfig() *server.Config {
return &server.Config{
func defaultConfig() *srvconfig.Config {
return &srvconfig.Config{
Root: defaults.DefaultRootDir,
State: defaults.DefaultStateDir,
GRPC: server.GRPCConfig{
GRPC: srvconfig.GRPCConfig{
Address: defaults.DefaultAddress,
MaxRecvMsgSize: defaults.DefaultMaxRecvMsgSize,
MaxSendMsgSize: defaults.DefaultMaxSendMsgSize,

View File

@@ -20,17 +20,17 @@ package command
import (
"github.com/containerd/containerd/defaults"
"github.com/containerd/containerd/services/server"
srvconfig "github.com/containerd/containerd/services/server/config"
)
func defaultConfig() *server.Config {
return &server.Config{
func defaultConfig() *srvconfig.Config {
return &srvconfig.Config{
Root: defaults.DefaultRootDir,
State: defaults.DefaultStateDir,
GRPC: server.GRPCConfig{
GRPC: srvconfig.GRPCConfig{
Address: defaults.DefaultAddress,
},
Debug: server.Debug{
Debug: srvconfig.Debug{
Level: "info",
Address: defaults.DefaultDebugAddress,
},

View File

@@ -18,14 +18,14 @@ package command
import (
"github.com/containerd/containerd/defaults"
"github.com/containerd/containerd/services/server"
srvconfig "github.com/containerd/containerd/services/server/config"
)
func defaultConfig() *server.Config {
return &server.Config{
func defaultConfig() *srvconfig.Config {
return &srvconfig.Config{
Root: defaults.DefaultRootDir,
State: defaults.DefaultStateDir,
GRPC: server.GRPCConfig{
GRPC: srvconfig.GRPCConfig{
Address: defaults.DefaultAddress,
MaxRecvMsgSize: defaults.DefaultMaxRecvMsgSize,
MaxSendMsgSize: defaults.DefaultMaxSendMsgSize,

View File

@@ -29,6 +29,7 @@ import (
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/mount"
"github.com/containerd/containerd/services/server"
srvconfig "github.com/containerd/containerd/services/server/config"
"github.com/containerd/containerd/sys"
"github.com/containerd/containerd/version"
"github.com/pkg/errors"
@@ -109,7 +110,7 @@ func App() *cli.App {
// we don't miss any signals during boot
signal.Notify(signals, handledSignals...)
if err := server.LoadConfig(context.GlobalString("config"), config); err != nil && !os.IsNotExist(err) {
if err := srvconfig.LoadConfig(context.GlobalString("config"), config); err != nil && !os.IsNotExist(err) {
return err
}
// apply flags to the config
@@ -187,7 +188,7 @@ func serve(ctx gocontext.Context, l net.Listener, serveFunc func(net.Listener) e
}()
}
func applyFlags(context *cli.Context, config *server.Config) error {
func applyFlags(context *cli.Context, config *srvconfig.Config) error {
// the order for config vs flag values is that flags will always override
// the config values if they are set
if err := setLevel(context, config); err != nil {
@@ -217,7 +218,7 @@ func applyFlags(context *cli.Context, config *server.Config) error {
return nil
}
func setLevel(context *cli.Context, config *server.Config) error {
func setLevel(context *cli.Context, config *srvconfig.Config) error {
l := context.GlobalString("log-level")
if l == "" {
l = config.Debug.Level

View File

@@ -28,7 +28,9 @@ import (
"github.com/containerd/containerd/cio"
"github.com/containerd/containerd/cmd/ctr/commands"
"github.com/containerd/containerd/cmd/ctr/commands/run"
"github.com/containerd/containerd/containers"
"github.com/containerd/containerd/log"
"github.com/containerd/typeurl"
"github.com/urfave/cli"
)
@@ -261,8 +263,22 @@ var infoCommand = cli.Command{
if err != nil {
return err
}
commands.PrintAsJSON(info)
if info.Spec != nil && info.Spec.Value != nil {
v, err := typeurl.UnmarshalAny(info.Spec)
if err != nil {
return err
}
commands.PrintAsJSON(struct {
containers.Container
Spec interface{} `json:"Spec,omitempty"`
}{
Container: info,
Spec: v,
})
return nil
}
commands.PrintAsJSON(info)
return nil
},
}

View File

@@ -89,10 +89,18 @@ var pprofHeapCommand = cli.Command{
var pprofProfileCommand = cli.Command{
Name: "profile",
Usage: "CPU profile",
Flags: []cli.Flag{
cli.DurationFlag{
Name: "seconds,s",
Usage: "duration for collection (seconds)",
Value: 30 * time.Second,
},
},
Action: func(context *cli.Context) error {
client := getPProfClient(context)
output, err := httpGetRequest(client, "/debug/pprof/profile")
seconds := context.Duration("seconds").Seconds()
output, err := httpGetRequest(client, fmt.Sprintf("/debug/pprof/profile?seconds=%v", seconds))
if err != nil {
return err
}

View File

@@ -89,10 +89,19 @@ var metricsCommand = cli.Command{
fmt.Fprintf(w, "%s\t%s\t\n\n", metric.ID, metric.Timestamp)
fmt.Fprintf(w, "METRIC\tVALUE\t\n")
fmt.Fprintf(w, "memory.usage_in_bytes\t%d\t\n", data.Memory.Usage.Usage)
fmt.Fprintf(w, "memory.stat.cache\t%d\t\n", data.Memory.TotalCache)
fmt.Fprintf(w, "cpuacct.usage\t%d\t\n", data.CPU.Usage.Total)
fmt.Fprintf(w, "cpuacct.usage_percpu\t%v\t\n", data.CPU.Usage.PerCPU)
if data.Memory != nil {
fmt.Fprintf(w, "memory.usage_in_bytes\t%d\t\n", data.Memory.Usage.Usage)
fmt.Fprintf(w, "memory.limit_in_bytes\t%d\t\n", data.Memory.Usage.Limit)
fmt.Fprintf(w, "memory.stat.cache\t%d\t\n", data.Memory.TotalCache)
}
if data.CPU != nil {
fmt.Fprintf(w, "cpuacct.usage\t%d\t\n", data.CPU.Usage.Total)
fmt.Fprintf(w, "cpuacct.usage_percpu\t%v\t\n", data.CPU.Usage.PerCPU)
}
if data.Pids != nil {
fmt.Fprintf(w, "pids.current\t%v\t\n", data.Pids.Current)
fmt.Fprintf(w, "pids.limit\t%v\t\n", data.Pids.Limit)
}
return w.Flush()
case formatJSON:
marshaledJSON, err := json.MarshalIndent(data, "", " ")

View File

@@ -110,8 +110,9 @@ type IngestManager interface {
// Writer handles the write of content into a content store
type Writer interface {
// Close is expected to be called after Commit() when commission is needed.
// Closing a writer without commit allows resuming or aborting.
// Close closes the writer, if the writer has not been
// committed this allows resuming or aborting.
// Calling Close on a closed writer will not error.
io.WriteCloser
// Digest may return empty digest or panics until committed.
@@ -119,6 +120,8 @@ type Writer interface {
// Commit commits the blob (but no roll-back is guaranteed on an error).
// size and expected can be zero-value when unknown.
// Commit always closes the writer, even on error.
// ErrAlreadyExists aborts the writer.
Commit(ctx context.Context, size int64, expected digest.Digest, opts ...Opt) error
// Status returns the current state of write

View File

@@ -524,12 +524,11 @@ func (s *store) writer(ctx context.Context, ref string, total int64, expected di
if err != nil {
return nil, err
}
defer fp.Close()
p := bufPool.Get().(*[]byte)
defer bufPool.Put(p)
offset, err = io.CopyBuffer(digester.Hash(), fp, *p)
bufPool.Put(p)
fp.Close()
if err != nil {
return nil, err
}

View File

@@ -26,6 +26,7 @@ import (
"github.com/containerd/containerd/content"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/log"
"github.com/opencontainers/go-digest"
"github.com/pkg/errors"
)
@@ -80,43 +81,36 @@ func (w *writer) Commit(ctx context.Context, size int64, expected digest.Digest,
}
}
if w.fp == nil {
// Ensure even on error the writer is fully closed
defer unlock(w.ref)
fp := w.fp
w.fp = nil
if fp == nil {
return errors.Wrap(errdefs.ErrFailedPrecondition, "cannot commit on closed writer")
}
if err := w.fp.Sync(); err != nil {
if err := fp.Sync(); err != nil {
fp.Close()
return errors.Wrap(err, "sync failed")
}
fi, err := w.fp.Stat()
fi, err := fp.Stat()
closeErr := fp.Close()
if err != nil {
return errors.Wrap(err, "stat on ingest file failed")
}
// change to readonly, more important for read, but provides _some_
// protection from this point on. We use the existing perms with a mask
// only allowing reads honoring the umask on creation.
//
// This removes write and exec, only allowing read per the creation umask.
//
// NOTE: Windows does not support this operation
if runtime.GOOS != "windows" {
if err := w.fp.Chmod((fi.Mode() & os.ModePerm) &^ 0333); err != nil {
return errors.Wrap(err, "failed to change ingest file permissions")
}
if closeErr != nil {
return errors.Wrap(err, "failed to close ingest file")
}
if size > 0 && size != fi.Size() {
return errors.Errorf("unexpected commit size %d, expected %d", fi.Size(), size)
}
if err := w.fp.Close(); err != nil {
return errors.Wrap(err, "failed closing ingest")
return errors.Wrapf(errdefs.ErrFailedPrecondition, "unexpected commit size %d, expected %d", fi.Size(), size)
}
dgst := w.digester.Digest()
if expected != "" && expected != dgst {
return errors.Errorf("unexpected commit digest %s, expected %s", dgst, expected)
return errors.Wrapf(errdefs.ErrFailedPrecondition, "unexpected commit digest %s, expected %s", dgst, expected)
}
var (
@@ -129,27 +123,48 @@ func (w *writer) Commit(ctx context.Context, size int64, expected digest.Digest,
return err
}
// clean up!!
defer os.RemoveAll(w.path)
if _, err := os.Stat(target); err == nil {
// collision with the target file!
if err := os.RemoveAll(w.path); err != nil {
log.G(ctx).WithField("ref", w.ref).WithField("path", w.path).Errorf("failed to remove ingest directory")
}
return errors.Wrapf(errdefs.ErrAlreadyExists, "content %v", dgst)
}
if err := os.Rename(ingest, target); err != nil {
return err
}
// Ingest has now been made available in the content store, attempt to complete
// setting metadata but errors should only be logged and not returned since
// the content store cannot be cleanly rolled back.
commitTime := time.Now()
if err := os.Chtimes(target, commitTime, commitTime); err != nil {
return err
log.G(ctx).WithField("digest", dgst).Errorf("failed to change file time to commit time")
}
w.fp = nil
unlock(w.ref)
// clean up!!
if err := os.RemoveAll(w.path); err != nil {
log.G(ctx).WithField("ref", w.ref).WithField("path", w.path).Errorf("failed to remove ingest directory")
}
if w.s.ls != nil && base.Labels != nil {
if err := w.s.ls.Set(dgst, base.Labels); err != nil {
return err
log.G(ctx).WithField("digest", dgst).Errorf("failed to set labels")
}
}
// change to readonly, more important for read, but provides _some_
// protection from this point on. We use the existing perms with a mask
// only allowing reads honoring the umask on creation.
//
// This removes write and exec, only allowing read per the creation umask.
//
// NOTE: Windows does not support this operation
if runtime.GOOS != "windows" {
if err := os.Chmod(target, (fi.Mode()&os.ModePerm)&^0333); err != nil {
log.G(ctx).WithField("ref", w.ref).Errorf("failed to make readonly")
}
}

View File

@@ -41,6 +41,7 @@ type walkingDiff struct {
}
var emptyDesc = ocispec.Descriptor{}
var uncompressed = "containerd.io/uncompressed"
// NewWalkingDiff is a generic implementation of diff.Comparer. The diff is
// calculated by mounting both the upper and lower mount sets and walking the
@@ -125,7 +126,7 @@ func (s *walkingDiff) Compare(ctx context.Context, lower, upper []mount.Mount, o
if config.Labels == nil {
config.Labels = map[string]string{}
}
config.Labels["containerd.io/uncompressed"] = dgstr.Digest().String()
config.Labels[uncompressed] = dgstr.Digest().String()
} else {
if err = archive.WriteDiff(ctx, cw, lowerRoot, upperRoot); err != nil {
return errors.Wrap(err, "failed to write diff")
@@ -149,6 +150,14 @@ func (s *walkingDiff) Compare(ctx context.Context, lower, upper []mount.Mount, o
return errors.Wrap(err, "failed to get info from content store")
}
// Set uncompressed label if digest already existed without label
if _, ok := info.Labels[uncompressed]; !ok {
info.Labels[uncompressed] = config.Labels[uncompressed]
if _, err := s.store.Update(ctx, info, "labels."+uncompressed); err != nil {
return errors.Wrap(err, "error setting uncompressed label")
}
}
ocidesc = ocispec.Descriptor{
MediaType: config.MediaType,
Size: info.Size,

View File

@@ -110,6 +110,9 @@ func (e *eventRemote) Subscribe(ctx context.Context, filters ...string) (ch <-ch
Event: ev.Event,
}:
case <-ctx.Done():
if cerr := ctx.Err(); cerr != context.Canceled {
errq <- cerr
}
return
}
}

View File

@@ -36,7 +36,7 @@ import (
"github.com/pkg/errors"
)
// ImportIndex imports an index from a tar achive image bundle
// ImportIndex imports an index from a tar archive image bundle
// - implements Docker v1.1, v1.2 and OCI v1.
// - prefers OCI v1 when provided
// - creates OCI index for Docker formats
@@ -164,7 +164,7 @@ func ImportIndex(ctx context.Context, store content.Store, reader io.Reader) (oc
if len(platforms) > 0 {
// Only one platform can be resolved from non-index manifest,
// The platform can only come from the config included above,
// if the config has no platform it can be safely ommitted.
// if the config has no platform it can be safely omitted.
desc.Platform = &platforms[0]
}

View File

@@ -556,12 +556,6 @@ func (nw *namespacedWriter) Commit(ctx context.Context, size int64, expected dig
var innerErr error
if err := update(ctx, nw.db, func(tx *bolt.Tx) error {
bkt := getIngestsBucket(tx, nw.namespace)
if bkt != nil {
if err := bkt.DeleteBucket([]byte(nw.ref)); err != nil && err != bolt.ErrBucketNotFound {
return err
}
}
dgst, err := nw.commit(ctx, tx, size, expected, opts...)
if err != nil {
if !errdefs.IsAlreadyExists(err) {
@@ -569,6 +563,12 @@ func (nw *namespacedWriter) Commit(ctx context.Context, size int64, expected dig
}
innerErr = err
}
bkt := getIngestsBucket(tx, nw.namespace)
if bkt != nil {
if err := bkt.DeleteBucket([]byte(nw.ref)); err != nil && err != bolt.ErrBucketNotFound {
return err
}
}
if err := removeIngestLease(ctx, tx, nw.ref); err != nil {
return err
}
@@ -584,30 +584,38 @@ func (nw *namespacedWriter) commit(ctx context.Context, tx *bolt.Tx, size int64,
var base content.Info
for _, opt := range opts {
if err := opt(&base); err != nil {
if nw.w != nil {
nw.w.Close()
}
return "", err
}
}
if err := validateInfo(&base); err != nil {
if nw.w != nil {
nw.w.Close()
}
return "", err
}
var actual digest.Digest
if nw.w == nil {
if size != 0 && size != nw.desc.Size {
return "", errors.Errorf("%q failed size validation: %v != %v", nw.ref, nw.desc.Size, size)
return "", errors.Wrapf(errdefs.ErrFailedPrecondition, "%q failed size validation: %v != %v", nw.ref, nw.desc.Size, size)
}
if expected != "" && expected != nw.desc.Digest {
return "", errors.Errorf("%q unexpected digest", nw.ref)
return "", errors.Wrapf(errdefs.ErrFailedPrecondition, "%q unexpected digest", nw.ref)
}
size = nw.desc.Size
actual = nw.desc.Digest
} else {
status, err := nw.w.Status()
if err != nil {
nw.w.Close()
return "", err
}
if size != 0 && size != status.Offset {
return "", errors.Errorf("%q failed size validation: %v != %v", nw.ref, status.Offset, size)
nw.w.Close()
return "", errors.Wrapf(errdefs.ErrFailedPrecondition, "%q failed size validation: %v != %v", nw.ref, status.Offset, size)
}
size = status.Offset
actual = nw.w.Digest()

View File

@@ -20,7 +20,6 @@ package cgroups
import (
"context"
"errors"
"fmt"
"sync"
@@ -33,13 +32,6 @@ import (
"github.com/prometheus/client_golang/prometheus"
)
var (
// ErrAlreadyCollected is returned when a cgroups is already being monitored
ErrAlreadyCollected = errors.New("cgroup is already being collected")
// ErrCgroupNotExists is returns when a cgroup no longer exists
ErrCgroupNotExists = errors.New("cgroup does not exist in the collector")
)
// Trigger will be called when an event happens and provides the cgroup
// where the event originated from
type Trigger func(string, string, cgroups.Cgroup)
@@ -141,7 +133,7 @@ func (c *collector) Add(t runtime.Task) error {
defer c.mu.Unlock()
id := taskID(t.ID(), t.Namespace())
if _, ok := c.tasks[id]; ok {
return ErrAlreadyCollected
return nil // requests to collect metrics should be idempotent
}
c.tasks[id] = t
return nil

View File

@@ -1,4 +1,4 @@
// +build darwin freebsd
// +build darwin freebsd openbsd
/*
Copyright The containerd Authors.

View File

@@ -1,3 +1,5 @@
// +build freebsd openbsd
/*
Copyright The containerd Authors.

View File

@@ -1,4 +1,4 @@
// +build !linux,!freebsd,!solaris freebsd,!cgo solaris,!cgo
// +build !linux,!freebsd,!solaris,!openbsd freebsd,!cgo solaris,!cgo openbsd,!cgo
/*
Copyright The containerd Authors.

View File

@@ -74,6 +74,22 @@ func getCPUInfo(pattern string) (info string, err error) {
}
func getCPUVariant() string {
if runtime.GOOS == "windows" {
// Windows only supports v7 for ARM32 and v8 for ARM64 and so we can use
// runtime.GOARCH to determine the variants
var variant string
switch runtime.GOARCH {
case "arm64":
variant = "v8"
case "arm":
variant = "v7"
default:
variant = "unknown"
}
return variant
}
variant, err := getCPUInfo("Cpu architecture")
if err != nil {
log.L.WithError(err).Error("failure getting variant")

View File

@@ -80,11 +80,7 @@ func (a *dockerAuthorizer) AddResponses(ctx context.Context, responses []*http.R
// TODO(dmcg): Store challenge, not token
// Move token fetching to authorize
if err := a.setTokenAuth(ctx, host, c.parameters); err != nil {
return err
}
return nil
return a.setTokenAuth(ctx, host, c.parameters)
} else if c.scheme == basicAuth {
// TODO: Resolve credentials on authorize
username, secret, err := a.credentials(host)

View File

@@ -24,6 +24,7 @@ import (
"fmt"
"io"
"io/ioutil"
"strconv"
"strings"
"sync"
"time"
@@ -42,7 +43,10 @@ import (
"github.com/pkg/errors"
)
const manifestSizeLimit = 8e6 // 8MB
const (
manifestSizeLimit = 8e6 // 8MB
labelDockerSchema1EmptyLayer = "containerd.io/docker.schema1.empty-layer"
)
type blobState struct {
diffID digest.Digest
@@ -353,10 +357,11 @@ func (c *Converter) fetchBlob(ctx context.Context, desc ocispec.Descriptor) erro
Digest: desc.Digest,
Labels: map[string]string{
"containerd.io/uncompressed": state.diffID.String(),
labelDockerSchema1EmptyLayer: strconv.FormatBool(state.empty),
},
}
if _, err := c.contentStore.Update(ctx, cinfo, "labels.containerd.io/uncompressed"); err != nil {
if _, err := c.contentStore.Update(ctx, cinfo, "labels.containerd.io/uncompressed", fmt.Sprintf("labels.%s", labelDockerSchema1EmptyLayer)); err != nil {
return errors.Wrap(err, "failed to update uncompressed label")
}
@@ -380,7 +385,18 @@ func (c *Converter) reuseLabelBlobState(ctx context.Context, desc ocispec.Descri
return false, nil
}
bState := blobState{empty: false}
emptyVal, ok := cinfo.Labels[labelDockerSchema1EmptyLayer]
if !ok {
return false, nil
}
isEmpty, err := strconv.ParseBool(emptyVal)
if err != nil {
log.G(ctx).WithField("id", desc.Digest).Warnf("failed to parse bool from label %s: %v", labelDockerSchema1EmptyLayer, isEmpty)
return false, nil
}
bState := blobState{empty: isEmpty}
if bState.diffID, err = digest.Parse(diffID); err != nil {
log.G(ctx).WithField("id", desc.Digest).Warnf("failed to parse digest from label containerd.io/uncompressed: %v", diffID)

View File

@@ -13,7 +13,7 @@ The runtime can also be changed via a container update.
```
When a user specifies a runtime name, `io.containerd.runc.v1`, they will specify the name and version of the runtime.
This will be trasnlated by containerd into a binary name for the shim.
This will be translated by containerd into a binary name for the shim.
`io.containerd.runc.v1` -> `containerd-shim-runc-v1`
@@ -113,7 +113,7 @@ Containers that are to be launched with an interactive terminal will have the `t
### Root Filesystems
The root filesytems for the containers is provided by on the `Create` rpc.
The root filesystem for the containers is provided by on the `Create` rpc.
Shims are responsible for managing the lifecycle of the filesystem mount during the lifecycle of a container.
```proto

View File

@@ -196,7 +196,7 @@ type deferredShimWriteLogger struct {
conerr error
}
// beginAccept issues an accept to wait for a connection. Once a conneciton
// beginAccept issues an accept to wait for a connection. Once a connection
// occurs drains any outstanding buffer. While draining the buffer any writes
// are blocked. If the buffer fails to fully drain due to a connection drop a
// call to `beginAccept` is re-issued waiting for another connection from

View File

@@ -49,6 +49,9 @@ func Command(ctx context.Context, runtime, containerdAddress, path string, cmdAr
}
args = append(args, cmdArgs...)
name := BinaryName(runtime)
if name == "" {
return nil, fmt.Errorf("invalid runtime name %s, correct runtime name should format like io.containerd.runc.v1", runtime)
}
var cmdPath string
var lerr error
if cmdPath, lerr = exec.LookPath(name); lerr != nil {
@@ -69,10 +72,15 @@ func Command(ctx context.Context, runtime, containerdAddress, path string, cmdAr
return cmd, nil
}
// BinaryName returns the shim binary name from the runtime name
// BinaryName returns the shim binary name from the runtime name,
// empty string returns means runtime name is invalid
func BinaryName(runtime string) string {
// runtime name should format like $prefix.name.version
parts := strings.Split(runtime, ".")
// TODO: add validation for runtime
if len(parts) < 2 {
return ""
}
return fmt.Sprintf(shimBinaryFormat, parts[len(parts)-2], parts[len(parts)-1])
}

View File

@@ -376,6 +376,9 @@ func (s *service) Write(session api.Content_WriteServer) (err error) {
expected = req.Expected
if _, err := s.store.Info(session.Context(), req.Expected); err == nil {
if err := wr.Close(); err != nil {
log.G(ctx).WithError(err).Error("failed to close writer")
}
if err := s.store.Abort(session.Context(), ref); err != nil {
log.G(ctx).WithError(err).Error("failed to abort write")
}

View File

@@ -14,7 +14,7 @@
limitations under the License.
*/
package server
package config
import (
"github.com/BurntSushi/toml"

View File

@@ -40,6 +40,7 @@ import (
"github.com/containerd/containerd/metadata"
"github.com/containerd/containerd/pkg/dialer"
"github.com/containerd/containerd/plugin"
srvconfig "github.com/containerd/containerd/services/server/config"
"github.com/containerd/containerd/snapshots"
ssproxy "github.com/containerd/containerd/snapshots/proxy"
metrics "github.com/docker/go-metrics"
@@ -50,7 +51,7 @@ import (
)
// New creates and initializes a new containerd server
func New(ctx context.Context, config *Config) (*Server, error) {
func New(ctx context.Context, config *srvconfig.Config) (*Server, error) {
switch {
case config.Root == "":
return nil, errors.New("root must be specified")
@@ -149,7 +150,7 @@ func New(ctx context.Context, config *Config) (*Server, error) {
type Server struct {
rpc *grpc.Server
events *exchange.Exchange
config *Config
config *srvconfig.Config
plugins []*plugin.Plugin
}
@@ -211,7 +212,7 @@ func (s *Server) Stop() {
// LoadPlugins loads all plugins into containerd and generates an ordered graph
// of all plugins.
func LoadPlugins(ctx context.Context, config *Config) ([]*plugin.Registration, error) {
func LoadPlugins(ctx context.Context, config *srvconfig.Config) ([]*plugin.Registration, error) {
// load all plugins into containerd
if err := plugin.Load(filepath.Join(config.Root, "plugins")); err != nil {
return nil, err

View File

@@ -22,12 +22,13 @@ import (
"github.com/containerd/cgroups"
"github.com/containerd/containerd/log"
srvconfig "github.com/containerd/containerd/services/server/config"
"github.com/containerd/containerd/sys"
specs "github.com/opencontainers/runtime-spec/specs-go"
)
// apply sets config settings on the server process
func apply(ctx context.Context, config *Config) error {
func apply(ctx context.Context, config *srvconfig.Config) error {
if config.OOMScore != 0 {
log.G(ctx).Debugf("changing OOM score to %d", config.OOMScore)
if err := sys.SetOOMScore(os.Getpid(), config.OOMScore); err != nil {

View File

@@ -16,8 +16,12 @@
package server
import "context"
import (
"context"
func apply(_ context.Context, _ *Config) error {
srvconfig "github.com/containerd/containerd/server/config"
)
func apply(_ context.Context, _ *srvconfig.Config) error {
return nil
}

View File

@@ -18,8 +18,12 @@
package server
import "context"
import (
"context"
func apply(_ context.Context, _ *Config) error {
srvconfig "github.com/containerd/containerd/services/server/config"
)
func apply(_ context.Context, _ *srvconfig.Config) error {
return nil
}

View File

@@ -20,8 +20,10 @@ package server
import (
"context"
srvconfig "github.com/containerd/containerd/services/server/config"
)
func apply(_ context.Context, _ *Config) error {
func apply(_ context.Context, _ *srvconfig.Config) error {
return nil
}

View File

@@ -20,7 +20,7 @@ github.com/gogo/protobuf v1.0.0
github.com/gogo/googleapis 08a7655d27152912db7aaf4f983275eaf8d128ef
github.com/golang/protobuf v1.1.0
github.com/opencontainers/runtime-spec eba862dc2470385a233c7507392675cbeadf7353 # v1.0.1-45-geba862d
github.com/opencontainers/runc 00dc70017d222b178a002ed30e9321b12647af2d
github.com/opencontainers/runc 58592df56734acf62e574865fe40b9e53e967910
github.com/sirupsen/logrus v1.0.0
github.com/urfave/cli 7bc6a0acffa589f415f88aca16cc1de5ffd66f9c
golang.org/x/net b3756b4b77d7b13260a0a2ec658753cf48922eac
@@ -32,8 +32,8 @@ 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.10
github.com/Microsoft/hcsshim v0.7.6
github.com/Microsoft/go-winio v0.4.11
github.com/Microsoft/hcsshim v0.7.12
google.golang.org/genproto d80a6e20e776b0b17a324d0ba1ab50a39c8e8944
golang.org/x/text 19e51611da83d6be54ddafce4a4af510cb3e9ea4
github.com/containerd/ttrpc 2a805f71863501300ae1976d29f0454ae003e85a
@@ -43,8 +43,8 @@ github.com/google/go-cmp v0.1.0
go.etcd.io/bbolt v1.3.1-etcd.8
# cri dependencies
github.com/containerd/cri 8506fe836677cc3bb23a16b68145128243d843b5 # release/1.2 branch
github.com/containerd/go-cni 6d7b509a054a3cb1c35ed1865d4fde2f0cb547cd
github.com/containerd/cri f913714917d2456d7e65a0be84962b1ce8acb487 # release/1.2 branch
github.com/containerd/go-cni 40bcf8ec8acd7372be1d77031d585d5d8e561c90
github.com/blang/semver v3.1.0
github.com/containernetworking/cni v0.6.0
github.com/containernetworking/plugins v0.7.0

View File

@@ -21,7 +21,7 @@ var (
Package = "github.com/containerd/containerd"
// Version holds the complete version number. Filled in at linking time.
Version = "1.2.0-rc.1+unknown"
Version = "1.2.0+unknown"
// Revision is filled with the VCS (e.g. git) revision being used to build
// the program at linking time.