Merge branch 'master' into patch-1
This commit is contained in:
commit
c6f2193c28
9 changed files with 89 additions and 3 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
gocontext "context"
|
gocontext "context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -51,8 +52,13 @@ func spec(id string, config *ocispec.ImageConfig, context *cli.Context) (*specs.
|
||||||
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||||||
}
|
}
|
||||||
env = append(env, config.Env...)
|
env = append(env, config.Env...)
|
||||||
|
cmd := config.Cmd
|
||||||
|
if v := context.Args().Tail(); len(v) > 0 {
|
||||||
|
cmd = v
|
||||||
|
}
|
||||||
var (
|
var (
|
||||||
args = append(config.Entrypoint, config.Cmd...)
|
// TODO: support overriding entrypoint
|
||||||
|
args = append(config.Entrypoint, cmd...)
|
||||||
tty = context.Bool("tty")
|
tty = context.Bool("tty")
|
||||||
uid, gid uint32
|
uid, gid uint32
|
||||||
)
|
)
|
||||||
|
@ -216,6 +222,7 @@ func spec(id string, config *ocispec.ImageConfig, context *cli.Context) (*specs.
|
||||||
var runCommand = cli.Command{
|
var runCommand = cli.Command{
|
||||||
Name: "run",
|
Name: "run",
|
||||||
Usage: "run a container",
|
Usage: "run a container",
|
||||||
|
ArgsUsage: "IMAGE [COMMAND] [ARG...]",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "id",
|
Name: "id",
|
||||||
|
@ -254,6 +261,7 @@ var runCommand = cli.Command{
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer os.RemoveAll(tmpDir)
|
||||||
events, err := containers.Events(ctx, &execution.EventsRequest{})
|
events, err := containers.Events(ctx, &execution.EventsRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
38
cmd/dist/images.go
vendored
38
cmd/dist/images.go
vendored
|
@ -61,3 +61,41 @@ var imagesCommand = cli.Command{
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var rmiCommand = cli.Command{
|
||||||
|
Name: "rmi",
|
||||||
|
Usage: "Delete one or more images by reference.",
|
||||||
|
ArgsUsage: "[flags] <ref> [<ref>, ...]",
|
||||||
|
Description: `Delete one or more images by reference.`,
|
||||||
|
Flags: []cli.Flag{},
|
||||||
|
Action: func(clicontext *cli.Context) error {
|
||||||
|
var (
|
||||||
|
ctx = background
|
||||||
|
exitErr error
|
||||||
|
)
|
||||||
|
|
||||||
|
db, err := getDB(clicontext, false)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "failed to open database")
|
||||||
|
}
|
||||||
|
|
||||||
|
tx, err := db.Begin(true)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "could not start transaction")
|
||||||
|
}
|
||||||
|
defer tx.Rollback()
|
||||||
|
|
||||||
|
for _, target := range clicontext.Args() {
|
||||||
|
if err := images.Delete(tx, target); err != nil {
|
||||||
|
if exitErr == nil {
|
||||||
|
exitErr = errors.Wrapf(err, "unable to delete %v", target)
|
||||||
|
}
|
||||||
|
log.G(ctx).WithError(err).Errorf("unable to delete %v", target)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(target)
|
||||||
|
}
|
||||||
|
|
||||||
|
return exitErr
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
1
cmd/dist/main.go
vendored
1
cmd/dist/main.go
vendored
|
@ -62,6 +62,7 @@ distribution tool
|
||||||
}
|
}
|
||||||
app.Commands = []cli.Command{
|
app.Commands = []cli.Command{
|
||||||
imagesCommand,
|
imagesCommand,
|
||||||
|
rmiCommand,
|
||||||
pullCommand,
|
pullCommand,
|
||||||
fetchCommand,
|
fetchCommand,
|
||||||
fetchObjectCommand,
|
fetchObjectCommand,
|
||||||
|
|
1
cmd/dist/pull.go
vendored
1
cmd/dist/pull.go
vendored
|
@ -67,6 +67,7 @@ command. As part of this process, we do the following:
|
||||||
|
|
||||||
ingester := contentservice.NewIngesterFromClient(contentapi.NewContentClient(conn))
|
ingester := contentservice.NewIngesterFromClient(contentapi.NewContentClient(conn))
|
||||||
provider := contentservice.NewProviderFromClient(contentapi.NewContentClient(conn))
|
provider := contentservice.NewProviderFromClient(contentapi.NewContentClient(conn))
|
||||||
|
|
||||||
cs, err := resolveContentStore(clicontext)
|
cs, err := resolveContentStore(clicontext)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -17,5 +17,7 @@ If you have not signed up to attend the summit you can do so in this [form](http
|
||||||
|
|
||||||
The following are proposed discussion points for the containerd summit at Dockercon US 2017:
|
The following are proposed discussion points for the containerd summit at Dockercon US 2017:
|
||||||
|
|
||||||
|
|
||||||
* Since containerd is one of the bottom bricks in the stack, how can we setup automated integration tests for consumers of containerd?
|
* Since containerd is one of the bottom bricks in the stack, how can we setup automated integration tests for consumers of containerd?
|
||||||
* We'd like to propose an Authorization plugin to containerd that would allow an external component to police events like container start & stop (and have a discussion about the best way to go about it)
|
* We'd like to propose an Authorization plugin to containerd that would allow an external component to police events like container start & stop (and have a discussion about the best way to go about it)
|
||||||
|
* Should containerd provide image filesystem metrics? If yes, what metrics should be included? How to implement that?
|
|
@ -103,6 +103,12 @@ func List(tx *bolt.Tx) ([]Image, error) {
|
||||||
return images, nil
|
return images, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Delete(tx *bolt.Tx, name string) error {
|
||||||
|
return withImagesBucket(tx, func(bkt *bolt.Bucket) error {
|
||||||
|
return bkt.DeleteBucket([]byte(name))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func readImage(image *Image, bkt *bolt.Bucket) error {
|
func readImage(image *Image, bkt *bolt.Bucket) error {
|
||||||
return bkt.ForEach(func(k, v []byte) error {
|
return bkt.ForEach(func(k, v []byte) error {
|
||||||
if v == nil {
|
if v == nil {
|
||||||
|
|
|
@ -4,14 +4,17 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"github.com/crosbymichael/console"
|
"github.com/crosbymichael/console"
|
||||||
runc "github.com/crosbymichael/go-runc"
|
runc "github.com/crosbymichael/go-runc"
|
||||||
shimapi "github.com/docker/containerd/api/services/shim"
|
shimapi "github.com/docker/containerd/api/services/shim"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
|
"github.com/tonistiigi/fifo"
|
||||||
)
|
)
|
||||||
|
|
||||||
type execProcess struct {
|
type execProcess struct {
|
||||||
|
@ -22,6 +25,7 @@ type execProcess struct {
|
||||||
io runc.IO
|
io runc.IO
|
||||||
status int
|
status int
|
||||||
pid int
|
pid int
|
||||||
|
closers []io.Closer
|
||||||
|
|
||||||
parent *initProcess
|
parent *initProcess
|
||||||
}
|
}
|
||||||
|
@ -66,6 +70,13 @@ func newExecProcess(context context.Context, path string, r *shimapi.ExecRequest
|
||||||
if err := parent.runc.Exec(context, parent.id, spec, opts); err != nil {
|
if err := parent.runc.Exec(context, parent.id, spec, opts); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if r.Stdin != "" {
|
||||||
|
sc, err := fifo.OpenFifo(context, r.Stdin, syscall.O_WRONLY|syscall.O_NONBLOCK, 0)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
e.closers = append(e.closers, sc)
|
||||||
|
}
|
||||||
if socket != nil {
|
if socket != nil {
|
||||||
console, err := socket.ReceiveMaster()
|
console, err := socket.ReceiveMaster()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -111,6 +122,9 @@ func (e *execProcess) Exited(status int) {
|
||||||
e.status = status
|
e.status = status
|
||||||
e.Wait()
|
e.Wait()
|
||||||
if e.io != nil {
|
if e.io != nil {
|
||||||
|
for _, c := range e.closers {
|
||||||
|
c.Close()
|
||||||
|
}
|
||||||
e.io.Close()
|
e.io.Close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package shim
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -11,6 +12,7 @@ import (
|
||||||
runc "github.com/crosbymichael/go-runc"
|
runc "github.com/crosbymichael/go-runc"
|
||||||
"github.com/docker/containerd"
|
"github.com/docker/containerd"
|
||||||
shimapi "github.com/docker/containerd/api/services/shim"
|
shimapi "github.com/docker/containerd/api/services/shim"
|
||||||
|
"github.com/tonistiigi/fifo"
|
||||||
)
|
)
|
||||||
|
|
||||||
type initProcess struct {
|
type initProcess struct {
|
||||||
|
@ -23,6 +25,7 @@ type initProcess struct {
|
||||||
runc *runc.Runc
|
runc *runc.Runc
|
||||||
status int
|
status int
|
||||||
pid int
|
pid int
|
||||||
|
closers []io.Closer
|
||||||
}
|
}
|
||||||
|
|
||||||
func newInitProcess(context context.Context, path string, r *shimapi.CreateRequest) (*initProcess, error) {
|
func newInitProcess(context context.Context, path string, r *shimapi.CreateRequest) (*initProcess, error) {
|
||||||
|
@ -73,6 +76,13 @@ func newInitProcess(context context.Context, path string, r *shimapi.CreateReque
|
||||||
if err := p.runc.Create(context, r.ID, r.Bundle, opts); err != nil {
|
if err := p.runc.Create(context, r.ID, r.Bundle, opts); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if r.Stdin != "" {
|
||||||
|
sc, err := fifo.OpenFifo(context, r.Stdin, syscall.O_WRONLY|syscall.O_NONBLOCK, 0)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
p.closers = append(p.closers, sc)
|
||||||
|
}
|
||||||
if socket != nil {
|
if socket != nil {
|
||||||
console, err := socket.ReceiveMaster()
|
console, err := socket.ReceiveMaster()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -125,6 +135,9 @@ func (p *initProcess) Delete(context context.Context) error {
|
||||||
p.Wait()
|
p.Wait()
|
||||||
err := p.runc.Delete(context, p.id)
|
err := p.runc.Delete(context, p.id)
|
||||||
if p.io != nil {
|
if p.io != nil {
|
||||||
|
for _, c := range p.closers {
|
||||||
|
c.Close()
|
||||||
|
}
|
||||||
p.io.Close()
|
p.io.Close()
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -68,6 +68,9 @@ func copyPipes(ctx context.Context, rio runc.IO, stdin, stdout, stderr string, w
|
||||||
}
|
}
|
||||||
dest(fw, fr)
|
dest(fw, fr)
|
||||||
}
|
}
|
||||||
|
if stdin == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
f, err := fifo.OpenFifo(ctx, stdin, syscall.O_RDONLY, 0)
|
f, err := fifo.OpenFifo(ctx, stdin, syscall.O_RDONLY, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("containerd-shim: opening %s failed: %s", stdin, err)
|
return fmt.Errorf("containerd-shim: opening %s failed: %s", stdin, err)
|
||||||
|
|
Loading…
Reference in a new issue