Update windows and darwin for spec changes
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
		| @@ -5,7 +5,6 @@ import ( | ||||
| 	"encoding/json" | ||||
| 	"fmt" | ||||
| 	"io/ioutil" | ||||
| 	"runtime" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/Sirupsen/logrus" | ||||
| @@ -67,14 +66,10 @@ func spec(id string, config *ocispec.ImageConfig, context *cli.Context) *specs.S | ||||
|  | ||||
| 	return &specs.Spec{ | ||||
| 		Version: specs.Version, | ||||
| 		Platform: specs.Platform{ | ||||
| 			OS:   runtime.GOOS, | ||||
| 			Arch: runtime.GOARCH, | ||||
| 		}, | ||||
| 		Root: specs.Root{ | ||||
| 			Readonly: context.Bool("readonly"), | ||||
| 		}, | ||||
| 		Process: specs.Process{ | ||||
| 		Process: &specs.Process{ | ||||
| 			Args:     args, | ||||
| 			Terminal: tty, | ||||
| 			Cwd:      cwd, | ||||
| @@ -82,7 +77,7 @@ func spec(id string, config *ocispec.ImageConfig, context *cli.Context) *specs.S | ||||
| 			User: specs.User{ | ||||
| 				Username: config.User, | ||||
| 			}, | ||||
| 			ConsoleSize: specs.Box{ | ||||
| 			ConsoleSize: &specs.Box{ | ||||
| 				Height: uint(w), | ||||
| 				Width:  uint(h), | ||||
| 			}, | ||||
|   | ||||
| @@ -1,3 +1,5 @@ | ||||
| // +build linux | ||||
|  | ||||
| package cgroups | ||||
|  | ||||
| import ( | ||||
|   | ||||
| @@ -1,3 +1,5 @@ | ||||
| // +build linux | ||||
|  | ||||
| package cgroups | ||||
|  | ||||
| import ( | ||||
|   | ||||
| @@ -1,3 +1,5 @@ | ||||
| // +build linux | ||||
|  | ||||
| package cgroups | ||||
|  | ||||
| import ( | ||||
|   | ||||
| @@ -1,3 +1,5 @@ | ||||
| // +build linux | ||||
|  | ||||
| package cgroups | ||||
|  | ||||
| import ( | ||||
|   | ||||
| @@ -1,3 +1,5 @@ | ||||
| // +build linux | ||||
|  | ||||
| package cgroups | ||||
|  | ||||
| import ( | ||||
|   | ||||
| @@ -1,7 +1,10 @@ | ||||
| // +build linux | ||||
|  | ||||
| package cgroups | ||||
|  | ||||
| import ( | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"strconv" | ||||
| 	"sync" | ||||
|  | ||||
| @@ -43,6 +46,10 @@ type task struct { | ||||
| 	cgroup    cgroups.Cgroup | ||||
| } | ||||
|  | ||||
| func taskID(id, namespace string) string { | ||||
| 	return fmt.Sprintf("%s-%s", id, namespace) | ||||
| } | ||||
|  | ||||
| // Collector provides the ability to collect container stats and export | ||||
| // them in the prometheus format | ||||
| type Collector struct { | ||||
| @@ -86,10 +93,10 @@ func (c *Collector) collect(id, namespace string, cg cgroups.Cgroup, ch chan<- p | ||||
| func (c *Collector) Add(id, namespace string, cg cgroups.Cgroup) error { | ||||
| 	c.mu.Lock() | ||||
| 	defer c.mu.Unlock() | ||||
| 	if _, ok := c.cgroups[id+namespace]; ok { | ||||
| 	if _, ok := c.cgroups[taskID(id, namespace)]; ok { | ||||
| 		return ErrAlreadyCollected | ||||
| 	} | ||||
| 	c.cgroups[id+namespace] = &task{ | ||||
| 	c.cgroups[taskID(id, namespace)] = &task{ | ||||
| 		id:        id, | ||||
| 		namespace: namespace, | ||||
| 		cgroup:    cg, | ||||
| @@ -102,7 +109,7 @@ func (c *Collector) Add(id, namespace string, cg cgroups.Cgroup) error { | ||||
| func (c *Collector) Get(id, namespace string) (cgroups.Cgroup, error) { | ||||
| 	c.mu.Lock() | ||||
| 	defer c.mu.Unlock() | ||||
| 	t, ok := c.cgroups[id+namespace] | ||||
| 	t, ok := c.cgroups[taskID(id, namespace)] | ||||
| 	if !ok { | ||||
| 		return nil, ErrCgroupNotExists | ||||
| 	} | ||||
| @@ -113,7 +120,7 @@ func (c *Collector) Get(id, namespace string) (cgroups.Cgroup, error) { | ||||
| func (c *Collector) Remove(id, namespace string) { | ||||
| 	c.mu.Lock() | ||||
| 	defer c.mu.Unlock() | ||||
| 	delete(c.cgroups, id+namespace) | ||||
| 	delete(c.cgroups, taskID(id, namespace)) | ||||
| } | ||||
|  | ||||
| func blkioValues(l []cgroups.BlkioEntry) []value { | ||||
|   | ||||
| @@ -1,3 +1,5 @@ | ||||
| // +build linux | ||||
|  | ||||
| package cgroups | ||||
|  | ||||
| import ( | ||||
|   | ||||
| @@ -1,3 +1,5 @@ | ||||
| // +build linux | ||||
|  | ||||
| package cgroups | ||||
|  | ||||
| import ( | ||||
|   | ||||
| @@ -4,7 +4,6 @@ import ( | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"fmt" | ||||
| 	"runtime" | ||||
|  | ||||
| 	"github.com/containerd/containerd/api/services/containers/v1" | ||||
| 	"github.com/containerd/containerd/images" | ||||
| @@ -18,13 +17,9 @@ const pipeRoot = `\\.\pipe` | ||||
| func createDefaultSpec() (*specs.Spec, error) { | ||||
| 	return &specs.Spec{ | ||||
| 		Version: specs.Version, | ||||
| 		Platform: specs.Platform{ | ||||
| 			OS:   runtime.GOOS, | ||||
| 			Arch: runtime.GOARCH, | ||||
| 		}, | ||||
| 		Root: specs.Root{}, | ||||
| 		Process: specs.Process{ | ||||
| 			ConsoleSize: specs.Box{ | ||||
| 		Root:    specs.Root{}, | ||||
| 		Process: &specs.Process{ | ||||
| 			ConsoleSize: &specs.Box{ | ||||
| 				Width:  80, | ||||
| 				Height: 20, | ||||
| 			}, | ||||
|   | ||||
| @@ -142,7 +142,7 @@ func (c *container) Exec(ctx context.Context, opts plugin.ExecOpts) (plugin.Proc | ||||
| 		return nil, errors.Wrap(err, "failed to unmarshal oci spec") | ||||
| 	} | ||||
|  | ||||
| 	p, err := c.ctr.AddProcess(ctx, procSpec, pio) | ||||
| 	p, err := c.ctr.AddProcess(ctx, &procSpec, pio) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|   | ||||
| @@ -303,7 +303,7 @@ func (c *Container) GetConfiguration() Configuration { | ||||
| 	return c.conf | ||||
| } | ||||
|  | ||||
| func (c *Container) AddProcess(ctx context.Context, spec specs.Process, io *IO) (*Process, error) { | ||||
| func (c *Container) AddProcess(ctx context.Context, spec *specs.Process, io *IO) (*Process, error) { | ||||
| 	if len(c.processes) == 0 { | ||||
| 		return nil, errors.New("container not started") | ||||
| 	} | ||||
| @@ -311,7 +311,7 @@ func (c *Container) AddProcess(ctx context.Context, spec specs.Process, io *IO) | ||||
| 	return c.addProcess(ctx, spec, io) | ||||
| } | ||||
|  | ||||
| func (c *Container) addProcess(ctx context.Context, spec specs.Process, pio *IO) (*Process, error) { | ||||
| func (c *Container) addProcess(ctx context.Context, spec *specs.Process, pio *IO) (*Process, error) { | ||||
| 	// If we don't have a process yet, reused the container pid | ||||
| 	var pid uint32 | ||||
| 	if len(c.processes) == 0 { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Michael Crosby
					Michael Crosby