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