Move shim protos into linux pkg
This moves the shim's API and protos out of the containerd services package and into the linux runtime package. This is because the shim is an implementation detail of the linux runtime that we have and it is not a containerd user facing api. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
6ad3ba739e
commit
990536f2cc
@ -8,8 +8,6 @@ import proto "github.com/gogo/protobuf/proto"
|
|||||||
import fmt "fmt"
|
import fmt "fmt"
|
||||||
import math "math"
|
import math "math"
|
||||||
import _ "github.com/gogo/protobuf/gogoproto"
|
import _ "github.com/gogo/protobuf/gogoproto"
|
||||||
import _ "github.com/gogo/protobuf/types"
|
|
||||||
import _ "github.com/gogo/protobuf/types"
|
|
||||||
|
|
||||||
import strings "strings"
|
import strings "strings"
|
||||||
import reflect "reflect"
|
import reflect "reflect"
|
||||||
@ -884,25 +882,23 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var fileDescriptorNamespace = []byte{
|
var fileDescriptorNamespace = []byte{
|
||||||
// 311 bytes of a gzipped FileDescriptorProto
|
// 277 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x72, 0x4f, 0xcf, 0x2c, 0xc9,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x72, 0x4f, 0xcf, 0x2c, 0xc9,
|
||||||
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d,
|
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d,
|
||||||
0x4a, 0x41, 0x66, 0x26, 0x16, 0x64, 0xea, 0x17, 0xa7, 0x16, 0x95, 0x65, 0x26, 0xa7, 0x16, 0xeb,
|
0x4a, 0x41, 0x66, 0x26, 0x16, 0x64, 0xea, 0x17, 0xa7, 0x16, 0x95, 0x65, 0x26, 0xa7, 0x16, 0xeb,
|
||||||
0xa7, 0x96, 0xa5, 0xe6, 0x95, 0x14, 0xeb, 0x97, 0x19, 0xea, 0xe7, 0x25, 0xe6, 0xa6, 0x16, 0x17,
|
0xa7, 0x96, 0xa5, 0xe6, 0x95, 0x14, 0xeb, 0x97, 0x19, 0xea, 0xe7, 0x25, 0xe6, 0xa6, 0x16, 0x17,
|
||||||
0x24, 0x26, 0xa7, 0xea, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0xc9, 0x22, 0xb4, 0xe8, 0xc1, 0x94,
|
0x24, 0x26, 0xa7, 0xea, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0xc9, 0x22, 0xb4, 0xe8, 0xc1, 0x94,
|
||||||
0xeb, 0x41, 0x94, 0xeb, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x55, 0xea, 0x83,
|
0xeb, 0x41, 0x94, 0xeb, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x55, 0xea, 0x83,
|
||||||
0x58, 0x10, 0x4d, 0x52, 0xf2, 0xe9, 0xf9, 0xf9, 0xe9, 0x39, 0xa9, 0xfa, 0x60, 0x5e, 0x52, 0x69,
|
0x58, 0x10, 0x4d, 0x4a, 0x5b, 0x18, 0xb9, 0xf8, 0xfd, 0x60, 0x06, 0x39, 0x17, 0xa5, 0x26, 0x96,
|
||||||
0x9a, 0x7e, 0x49, 0x66, 0x6e, 0x6a, 0x71, 0x49, 0x62, 0x6e, 0x01, 0x54, 0x81, 0x24, 0xba, 0x82,
|
0xa4, 0x0a, 0x09, 0x71, 0xb1, 0x80, 0xcc, 0x96, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0x02, 0xb3,
|
||||||
0xc4, 0xbc, 0x4a, 0x88, 0x94, 0xd2, 0x16, 0x46, 0x2e, 0x7e, 0x3f, 0x98, 0x23, 0x9c, 0x8b, 0x52,
|
0x85, 0x82, 0xb8, 0xd8, 0x72, 0x12, 0x93, 0x52, 0x73, 0x8a, 0x25, 0x98, 0x14, 0x98, 0x35, 0xb8,
|
||||||
0x13, 0x4b, 0x52, 0x85, 0x84, 0xb8, 0x58, 0x40, 0xee, 0x92, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c,
|
0x8d, 0xac, 0xf4, 0xf0, 0xda, 0xa6, 0x87, 0x66, 0xa6, 0x9e, 0x0f, 0x58, 0xb3, 0x6b, 0x5e, 0x49,
|
||||||
0x02, 0xb3, 0x85, 0x82, 0xb8, 0xd8, 0x72, 0x12, 0x93, 0x52, 0x73, 0x8a, 0x25, 0x98, 0x14, 0x98,
|
0x51, 0x65, 0x10, 0xd4, 0x24, 0x29, 0x4b, 0x2e, 0x6e, 0x24, 0x61, 0x21, 0x01, 0x2e, 0xe6, 0xec,
|
||||||
0x35, 0xb8, 0x8d, 0xac, 0xf4, 0xf0, 0xba, 0x54, 0x0f, 0xcd, 0x4c, 0x3d, 0x1f, 0xb0, 0x66, 0xd7,
|
0xd4, 0x4a, 0xa8, 0xad, 0x20, 0xa6, 0x90, 0x08, 0x17, 0x6b, 0x59, 0x62, 0x4e, 0x69, 0xaa, 0x04,
|
||||||
0xbc, 0x92, 0xa2, 0xca, 0x20, 0xa8, 0x49, 0x52, 0x96, 0x5c, 0xdc, 0x48, 0xc2, 0x42, 0x02, 0x5c,
|
0x13, 0x58, 0x0c, 0xc2, 0xb1, 0x62, 0xb2, 0x60, 0x44, 0x75, 0x76, 0x68, 0x41, 0x0a, 0xd5, 0x9d,
|
||||||
0xcc, 0xd9, 0xa9, 0x95, 0x50, 0x5b, 0x41, 0x4c, 0x21, 0x11, 0x2e, 0xd6, 0xb2, 0xc4, 0x9c, 0xd2,
|
0x0d, 0x31, 0x93, 0xda, 0xce, 0x56, 0x45, 0x72, 0xb5, 0x4b, 0x6a, 0x4e, 0x2a, 0x76, 0x57, 0x3b,
|
||||||
0x54, 0x09, 0x26, 0xb0, 0x18, 0x84, 0x63, 0xc5, 0x64, 0xc1, 0x88, 0xea, 0xec, 0xd0, 0x82, 0x14,
|
0x45, 0x9c, 0x78, 0x28, 0xc7, 0x70, 0xe3, 0xa1, 0x1c, 0x43, 0xc3, 0x23, 0x39, 0xc6, 0x13, 0x8f,
|
||||||
0xaa, 0x3b, 0x1b, 0x62, 0x26, 0xb5, 0x9d, 0xad, 0x8a, 0xe4, 0x6a, 0x97, 0xd4, 0x9c, 0x54, 0xec,
|
0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x31, 0xca, 0x8e, 0xcc, 0xc4, 0x62,
|
||||||
0xae, 0x76, 0x8a, 0x38, 0xf1, 0x50, 0x8e, 0xe1, 0xc6, 0x43, 0x39, 0x86, 0x86, 0x47, 0x72, 0x8c,
|
0x0d, 0x61, 0x25, 0xb1, 0x81, 0x63, 0xdd, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xbe, 0xf0, 0x68,
|
||||||
0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0x63, 0x94, 0x1d, 0x99,
|
0xa6, 0x75, 0x02, 0x00, 0x00,
|
||||||
0x09, 0xcd, 0x1a, 0xc2, 0x4a, 0x62, 0x03, 0xc7, 0xba, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x78,
|
|
||||||
0xf1, 0x6d, 0xaa, 0xb1, 0x02, 0x00, 0x00,
|
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,6 @@ syntax = "proto3";
|
|||||||
package containerd.services.events.v1;
|
package containerd.services.events.v1;
|
||||||
|
|
||||||
import "gogoproto/gogo.proto";
|
import "gogoproto/gogo.proto";
|
||||||
import "google/protobuf/timestamp.proto";
|
|
||||||
import "google/protobuf/any.proto";
|
|
||||||
|
|
||||||
option go_package = "github.com/containerd/containerd/api/services/events/v1;events";
|
option go_package = "github.com/containerd/containerd/api/services/events/v1;events";
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ import fmt "fmt"
|
|||||||
import math "math"
|
import math "math"
|
||||||
import _ "github.com/gogo/protobuf/gogoproto"
|
import _ "github.com/gogo/protobuf/gogoproto"
|
||||||
import _ "github.com/gogo/protobuf/types"
|
import _ "github.com/gogo/protobuf/types"
|
||||||
import containerd_v1_types "github.com/containerd/containerd/api/types/task"
|
|
||||||
|
|
||||||
import time "time"
|
import time "time"
|
||||||
|
|
||||||
@ -26,6 +25,41 @@ var _ = fmt.Errorf
|
|||||||
var _ = math.Inf
|
var _ = math.Inf
|
||||||
var _ = time.Kitchen
|
var _ = time.Kitchen
|
||||||
|
|
||||||
|
type RuntimeEvent_EventType int32
|
||||||
|
|
||||||
|
const (
|
||||||
|
RuntimeEvent_EXIT RuntimeEvent_EventType = 0
|
||||||
|
RuntimeEvent_OOM RuntimeEvent_EventType = 1
|
||||||
|
RuntimeEvent_CREATE RuntimeEvent_EventType = 2
|
||||||
|
RuntimeEvent_START RuntimeEvent_EventType = 3
|
||||||
|
RuntimeEvent_EXEC_ADDED RuntimeEvent_EventType = 4
|
||||||
|
RuntimeEvent_PAUSED RuntimeEvent_EventType = 5
|
||||||
|
)
|
||||||
|
|
||||||
|
var RuntimeEvent_EventType_name = map[int32]string{
|
||||||
|
0: "EXIT",
|
||||||
|
1: "OOM",
|
||||||
|
2: "CREATE",
|
||||||
|
3: "START",
|
||||||
|
4: "EXEC_ADDED",
|
||||||
|
5: "PAUSED",
|
||||||
|
}
|
||||||
|
var RuntimeEvent_EventType_value = map[string]int32{
|
||||||
|
"EXIT": 0,
|
||||||
|
"OOM": 1,
|
||||||
|
"CREATE": 2,
|
||||||
|
"START": 3,
|
||||||
|
"EXEC_ADDED": 4,
|
||||||
|
"PAUSED": 5,
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x RuntimeEvent_EventType) String() string {
|
||||||
|
return proto.EnumName(RuntimeEvent_EventType_name, int32(x))
|
||||||
|
}
|
||||||
|
func (RuntimeEvent_EventType) EnumDescriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptorRuntime, []int{3, 0}
|
||||||
|
}
|
||||||
|
|
||||||
type RuntimeIO struct {
|
type RuntimeIO struct {
|
||||||
Stdin string `protobuf:"bytes,1,opt,name=stdin,proto3" json:"stdin,omitempty"`
|
Stdin string `protobuf:"bytes,1,opt,name=stdin,proto3" json:"stdin,omitempty"`
|
||||||
Stdout string `protobuf:"bytes,2,opt,name=stdout,proto3" json:"stdout,omitempty"`
|
Stdout string `protobuf:"bytes,2,opt,name=stdout,proto3" json:"stdout,omitempty"`
|
||||||
@ -61,7 +95,7 @@ func (*RuntimeCreate) Descriptor() ([]byte, []int) { return fileDescriptorRuntim
|
|||||||
|
|
||||||
type RuntimeEvent struct {
|
type RuntimeEvent struct {
|
||||||
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||||
Type containerd_v1_types.Event_EventType `protobuf:"varint,2,opt,name=type,proto3,enum=containerd.v1.types.Event_EventType" json:"type,omitempty"`
|
Type RuntimeEvent_EventType `protobuf:"varint,2,opt,name=type,proto3,enum=containerd.services.events.v1.RuntimeEvent_EventType" json:"type,omitempty"`
|
||||||
Pid uint32 `protobuf:"varint,3,opt,name=pid,proto3" json:"pid,omitempty"`
|
Pid uint32 `protobuf:"varint,3,opt,name=pid,proto3" json:"pid,omitempty"`
|
||||||
ExitStatus uint32 `protobuf:"varint,4,opt,name=exit_status,json=exitStatus,proto3" json:"exit_status,omitempty"`
|
ExitStatus uint32 `protobuf:"varint,4,opt,name=exit_status,json=exitStatus,proto3" json:"exit_status,omitempty"`
|
||||||
ExitedAt time.Time `protobuf:"bytes,5,opt,name=exited_at,json=exitedAt,stdtime" json:"exited_at"`
|
ExitedAt time.Time `protobuf:"bytes,5,opt,name=exited_at,json=exitedAt,stdtime" json:"exited_at"`
|
||||||
@ -88,6 +122,7 @@ func init() {
|
|||||||
proto.RegisterType((*RuntimeCreate)(nil), "containerd.services.events.v1.RuntimeCreate")
|
proto.RegisterType((*RuntimeCreate)(nil), "containerd.services.events.v1.RuntimeCreate")
|
||||||
proto.RegisterType((*RuntimeEvent)(nil), "containerd.services.events.v1.RuntimeEvent")
|
proto.RegisterType((*RuntimeEvent)(nil), "containerd.services.events.v1.RuntimeEvent")
|
||||||
proto.RegisterType((*RuntimeDelete)(nil), "containerd.services.events.v1.RuntimeDelete")
|
proto.RegisterType((*RuntimeDelete)(nil), "containerd.services.events.v1.RuntimeDelete")
|
||||||
|
proto.RegisterEnum("containerd.services.events.v1.RuntimeEvent_EventType", RuntimeEvent_EventType_name, RuntimeEvent_EventType_value)
|
||||||
}
|
}
|
||||||
func (m *RuntimeIO) Marshal() (dAtA []byte, err error) {
|
func (m *RuntimeIO) Marshal() (dAtA []byte, err error) {
|
||||||
size := m.Size()
|
size := m.Size()
|
||||||
@ -1118,7 +1153,7 @@ func (m *RuntimeEvent) Unmarshal(dAtA []byte) error {
|
|||||||
}
|
}
|
||||||
b := dAtA[iNdEx]
|
b := dAtA[iNdEx]
|
||||||
iNdEx++
|
iNdEx++
|
||||||
m.Type |= (containerd_v1_types.Event_EventType(b) & 0x7F) << shift
|
m.Type |= (RuntimeEvent_EventType(b) & 0x7F) << shift
|
||||||
if b < 0x80 {
|
if b < 0x80 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -1479,40 +1514,43 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var fileDescriptorRuntime = []byte{
|
var fileDescriptorRuntime = []byte{
|
||||||
// 555 bytes of a gzipped FileDescriptorProto
|
// 599 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xc1, 0x6a, 0xdb, 0x4c,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xc1, 0x6a, 0xdb, 0x40,
|
||||||
0x10, 0x8e, 0x64, 0xc7, 0xb1, 0xd7, 0xbf, 0x7f, 0xca, 0x12, 0x8a, 0x30, 0x54, 0x32, 0xa6, 0x07,
|
0x10, 0x86, 0x2d, 0xc9, 0x76, 0xec, 0x71, 0x13, 0xc4, 0x12, 0x8a, 0x30, 0x54, 0x0e, 0x3e, 0x19,
|
||||||
0x43, 0x61, 0x85, 0xdd, 0x4b, 0x69, 0xa1, 0x34, 0x6e, 0x52, 0xf0, 0xa1, 0x18, 0x36, 0x3e, 0x94,
|
0x0a, 0x12, 0x71, 0xe9, 0xa9, 0x50, 0x6a, 0xc7, 0x2a, 0xf8, 0x10, 0xdc, 0xae, 0x55, 0x08, 0xbd,
|
||||||
0x5e, 0x82, 0x2c, 0x6d, 0x9c, 0x25, 0xb6, 0x56, 0xec, 0x8e, 0x4c, 0x73, 0xeb, 0x23, 0xf4, 0x25,
|
0x04, 0x59, 0xda, 0x38, 0x4b, 0x6d, 0xad, 0x58, 0xad, 0x4c, 0x73, 0xeb, 0x23, 0xf4, 0x25, 0xfa,
|
||||||
0xfa, 0x2e, 0x3e, 0xf6, 0x54, 0x7a, 0x72, 0x1b, 0x3d, 0x42, 0x9f, 0xa0, 0x68, 0x77, 0xed, 0x98,
|
0x12, 0x7d, 0x82, 0x1c, 0x7b, 0xec, 0x29, 0x6d, 0xf4, 0x08, 0x7d, 0x82, 0xa2, 0x5d, 0x59, 0x09,
|
||||||
0x42, 0x4d, 0xc8, 0x65, 0x99, 0x6f, 0x98, 0xf9, 0xf6, 0x9b, 0xfd, 0x46, 0x42, 0x67, 0x33, 0x0e,
|
0x85, 0x9a, 0x90, 0x8b, 0x99, 0x7f, 0x98, 0xfd, 0x66, 0xfe, 0xdd, 0xb1, 0xc0, 0x5b, 0x52, 0x71,
|
||||||
0x57, 0xf9, 0x94, 0xc4, 0x62, 0x11, 0xc6, 0x22, 0x85, 0x88, 0xa7, 0x4c, 0x26, 0xbb, 0x61, 0x94,
|
0x99, 0x2d, 0x9c, 0x90, 0xad, 0xdd, 0x90, 0xc5, 0x22, 0xa0, 0x31, 0xe1, 0xd1, 0xfd, 0x30, 0x48,
|
||||||
0xf1, 0x50, 0x31, 0xb9, 0xe4, 0x31, 0x53, 0x21, 0x5b, 0xb2, 0x14, 0x54, 0xb8, 0xec, 0x87, 0x32,
|
0xa8, 0x9b, 0x12, 0xbe, 0xa1, 0x21, 0x49, 0x5d, 0xb2, 0x21, 0xb1, 0x48, 0xdd, 0xcd, 0xb1, 0xcb,
|
||||||
0x4f, 0x81, 0x2f, 0x18, 0xc9, 0xa4, 0x00, 0x81, 0x9f, 0xdc, 0x35, 0x90, 0x4d, 0x31, 0x31, 0xc5,
|
0xb3, 0x58, 0xd0, 0x35, 0x71, 0x12, 0xce, 0x04, 0x43, 0xcf, 0xee, 0x0e, 0x38, 0xdb, 0x62, 0x47,
|
||||||
0x64, 0xd9, 0x6f, 0x1f, 0xcf, 0xc4, 0x4c, 0xe8, 0xca, 0xb0, 0x8c, 0x4c, 0x53, 0x3b, 0x98, 0x09,
|
0x15, 0x3b, 0x9b, 0xe3, 0xee, 0xe1, 0x92, 0x2d, 0x99, 0xac, 0x74, 0x8b, 0x48, 0x1d, 0xea, 0xf6,
|
||||||
0x31, 0x9b, 0xb3, 0x50, 0xa3, 0x69, 0x7e, 0x19, 0x96, 0x84, 0x0a, 0xa2, 0x45, 0x66, 0x0b, 0x5e,
|
0x96, 0x8c, 0x2d, 0x57, 0xc4, 0x95, 0x6a, 0x91, 0x5d, 0xb8, 0x05, 0x30, 0x15, 0xc1, 0x3a, 0x51,
|
||||||
0xde, 0x4b, 0x1c, 0xdc, 0x64, 0x4c, 0x85, 0x10, 0xa9, 0x6b, 0x7d, 0x98, 0xde, 0xee, 0x02, 0x35,
|
0x05, 0xfd, 0x35, 0xb4, 0xb1, 0x6a, 0x33, 0x9d, 0xa1, 0x43, 0x68, 0xa4, 0x22, 0xa2, 0xb1, 0xa5,
|
||||||
0xa8, 0x91, 0x38, 0x1a, 0xe3, 0x63, 0x74, 0xa8, 0x20, 0xe1, 0xa9, 0xe7, 0x74, 0x9c, 0x5e, 0x83,
|
0x1d, 0x69, 0x83, 0x36, 0x56, 0x02, 0x3d, 0x85, 0x66, 0x2a, 0x22, 0x96, 0x09, 0x4b, 0x97, 0xe9,
|
||||||
0x1a, 0x80, 0x1f, 0xa3, 0x9a, 0x82, 0x44, 0xe4, 0xe0, 0xb9, 0x3a, 0x6d, 0x91, 0xcd, 0x33, 0x29,
|
0x52, 0x95, 0x79, 0xc2, 0xb9, 0x65, 0x54, 0x79, 0xc2, 0x39, 0xea, 0x42, 0x4b, 0x10, 0xbe, 0xa6,
|
||||||
0xbd, 0xca, 0x36, 0xcf, 0xa4, 0xc4, 0x6d, 0x54, 0x07, 0x26, 0x17, 0x3c, 0x8d, 0xe6, 0x5e, 0xb5,
|
0x71, 0xb0, 0xb2, 0xea, 0x47, 0xda, 0xa0, 0x85, 0x2b, 0xdd, 0xf7, 0xe1, 0x49, 0xd9, 0xee, 0x94,
|
||||||
0xe3, 0xf4, 0xea, 0x74, 0x8b, 0xbb, 0x13, 0xf4, 0x9f, 0xbd, 0xee, 0xbd, 0xc8, 0x53, 0xc0, 0x18,
|
0x65, 0xb1, 0x40, 0x08, 0xea, 0xe2, 0x2a, 0x21, 0x65, 0x43, 0x19, 0x4b, 0x2e, 0xcb, 0x78, 0x48,
|
||||||
0x55, 0x4b, 0x5d, 0xf6, 0x42, 0x1d, 0x6b, 0x5e, 0x91, 0xcb, 0x98, 0x6d, 0xef, 0xd3, 0x08, 0x7b,
|
0xaa, 0x7e, 0x52, 0x21, 0x0b, 0xf6, 0x58, 0x22, 0x28, 0x8b, 0x53, 0xcb, 0x38, 0x32, 0x06, 0x6d,
|
||||||
0xe8, 0x48, 0x64, 0xc0, 0x45, 0x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, 0xc6, 0x82, 0xbd, 0xf2, 0x7f, 0x58, 0xae, 0xcc, 0x56, 0xfe, 0x6b, 0xdd,
|
||||||
0x00, 0xff, 0xff, 0xe0, 0x7b, 0x76, 0x39, 0x76, 0x04, 0x00, 0x00,
|
0xd8, 0x6d, 0xbd, 0xfe, 0x18, 0xeb, 0xe3, 0xb3, 0xeb, 0x5b, 0xbb, 0xf6, 0xf3, 0xd6, 0xae, 0x7d,
|
||||||
|
0xc9, 0x6d, 0xed, 0x3a, 0xb7, 0xb5, 0x1f, 0xb9, 0xad, 0xfd, 0xce, 0x6d, 0xed, 0xe3, 0xeb, 0x47,
|
||||||
|
0x7e, 0x55, 0x5e, 0xa9, 0x68, 0xd1, 0x94, 0x13, 0xbc, 0xf8, 0x1b, 0x00, 0x00, 0xff, 0xff, 0xa8,
|
||||||
|
0x82, 0x1b, 0x05, 0x9e, 0x04, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ package containerd.services.events.v1;
|
|||||||
|
|
||||||
import "gogoproto/gogo.proto";
|
import "gogoproto/gogo.proto";
|
||||||
import "google/protobuf/timestamp.proto";
|
import "google/protobuf/timestamp.proto";
|
||||||
import "github.com/containerd/containerd/api/types/task/task.proto";
|
|
||||||
|
|
||||||
option go_package = "github.com/containerd/containerd/api/services/events/v1;events";
|
option go_package = "github.com/containerd/containerd/api/services/events/v1;events";
|
||||||
|
|
||||||
@ -31,7 +30,15 @@ message RuntimeCreate {
|
|||||||
|
|
||||||
message RuntimeEvent {
|
message RuntimeEvent {
|
||||||
string id = 1;
|
string id = 1;
|
||||||
containerd.v1.types.Event.EventType type = 2;
|
enum EventType {
|
||||||
|
EXIT = 0;
|
||||||
|
OOM = 1;
|
||||||
|
CREATE = 2;
|
||||||
|
START = 3;
|
||||||
|
EXEC_ADDED = 4;
|
||||||
|
PAUSED = 5;
|
||||||
|
}
|
||||||
|
EventType type = 2;
|
||||||
uint32 pid = 3;
|
uint32 pid = 3;
|
||||||
uint32 exit_status = 4;
|
uint32 exit_status = 4;
|
||||||
google.protobuf.Timestamp exited_at = 5 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
|
google.protobuf.Timestamp exited_at = 5 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
Task
|
Task
|
||||||
Process
|
Process
|
||||||
User
|
User
|
||||||
Event
|
|
||||||
*/
|
*/
|
||||||
package task
|
package task
|
||||||
|
|
||||||
@ -21,11 +20,6 @@ import fmt "fmt"
|
|||||||
import math "math"
|
import math "math"
|
||||||
import _ "github.com/gogo/protobuf/gogoproto"
|
import _ "github.com/gogo/protobuf/gogoproto"
|
||||||
import google_protobuf1 "github.com/gogo/protobuf/types"
|
import google_protobuf1 "github.com/gogo/protobuf/types"
|
||||||
import _ "github.com/gogo/protobuf/types"
|
|
||||||
|
|
||||||
import time "time"
|
|
||||||
|
|
||||||
import github_com_gogo_protobuf_types "github.com/gogo/protobuf/types"
|
|
||||||
|
|
||||||
import strings "strings"
|
import strings "strings"
|
||||||
import reflect "reflect"
|
import reflect "reflect"
|
||||||
@ -36,7 +30,6 @@ import io "io"
|
|||||||
var _ = proto.Marshal
|
var _ = proto.Marshal
|
||||||
var _ = fmt.Errorf
|
var _ = fmt.Errorf
|
||||||
var _ = math.Inf
|
var _ = math.Inf
|
||||||
var _ = time.Kitchen
|
|
||||||
|
|
||||||
// This is a compile-time assertion to ensure that this generated file
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
// is compatible with the proto package it is being compiled against.
|
// is compatible with the proto package it is being compiled against.
|
||||||
@ -74,39 +67,6 @@ func (x Status) String() string {
|
|||||||
}
|
}
|
||||||
func (Status) EnumDescriptor() ([]byte, []int) { return fileDescriptorTask, []int{0} }
|
func (Status) EnumDescriptor() ([]byte, []int) { return fileDescriptorTask, []int{0} }
|
||||||
|
|
||||||
type Event_EventType int32
|
|
||||||
|
|
||||||
const (
|
|
||||||
Event_EXIT Event_EventType = 0
|
|
||||||
Event_OOM Event_EventType = 1
|
|
||||||
Event_CREATE Event_EventType = 2
|
|
||||||
Event_START Event_EventType = 3
|
|
||||||
Event_EXEC_ADDED Event_EventType = 4
|
|
||||||
Event_PAUSED Event_EventType = 5
|
|
||||||
)
|
|
||||||
|
|
||||||
var Event_EventType_name = map[int32]string{
|
|
||||||
0: "EXIT",
|
|
||||||
1: "OOM",
|
|
||||||
2: "CREATE",
|
|
||||||
3: "START",
|
|
||||||
4: "EXEC_ADDED",
|
|
||||||
5: "PAUSED",
|
|
||||||
}
|
|
||||||
var Event_EventType_value = map[string]int32{
|
|
||||||
"EXIT": 0,
|
|
||||||
"OOM": 1,
|
|
||||||
"CREATE": 2,
|
|
||||||
"START": 3,
|
|
||||||
"EXEC_ADDED": 4,
|
|
||||||
"PAUSED": 5,
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x Event_EventType) String() string {
|
|
||||||
return proto.EnumName(Event_EventType_name, int32(x))
|
|
||||||
}
|
|
||||||
func (Event_EventType) EnumDescriptor() ([]byte, []int) { return fileDescriptorTask, []int{3, 0} }
|
|
||||||
|
|
||||||
type Task struct {
|
type Task struct {
|
||||||
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||||
ContainerID string `protobuf:"bytes,2,opt,name=container_id,json=containerId,proto3" json:"container_id,omitempty"`
|
ContainerID string `protobuf:"bytes,2,opt,name=container_id,json=containerId,proto3" json:"container_id,omitempty"`
|
||||||
@ -152,25 +112,11 @@ func (m *User) Reset() { *m = User{} }
|
|||||||
func (*User) ProtoMessage() {}
|
func (*User) ProtoMessage() {}
|
||||||
func (*User) Descriptor() ([]byte, []int) { return fileDescriptorTask, []int{2} }
|
func (*User) Descriptor() ([]byte, []int) { return fileDescriptorTask, []int{2} }
|
||||||
|
|
||||||
type Event struct {
|
|
||||||
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
|
||||||
Type Event_EventType `protobuf:"varint,2,opt,name=type,proto3,enum=containerd.v1.types.Event_EventType" json:"type,omitempty"`
|
|
||||||
Pid uint32 `protobuf:"varint,3,opt,name=pid,proto3" json:"pid,omitempty"`
|
|
||||||
ExitStatus uint32 `protobuf:"varint,4,opt,name=exit_status,json=exitStatus,proto3" json:"exit_status,omitempty"`
|
|
||||||
ExitedAt time.Time `protobuf:"bytes,5,opt,name=exited_at,json=exitedAt,stdtime" json:"exited_at"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Event) Reset() { *m = Event{} }
|
|
||||||
func (*Event) ProtoMessage() {}
|
|
||||||
func (*Event) Descriptor() ([]byte, []int) { return fileDescriptorTask, []int{3} }
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
proto.RegisterType((*Task)(nil), "containerd.v1.types.Task")
|
proto.RegisterType((*Task)(nil), "containerd.v1.types.Task")
|
||||||
proto.RegisterType((*Process)(nil), "containerd.v1.types.Process")
|
proto.RegisterType((*Process)(nil), "containerd.v1.types.Process")
|
||||||
proto.RegisterType((*User)(nil), "containerd.v1.types.User")
|
proto.RegisterType((*User)(nil), "containerd.v1.types.User")
|
||||||
proto.RegisterType((*Event)(nil), "containerd.v1.types.Event")
|
|
||||||
proto.RegisterEnum("containerd.v1.types.Status", Status_name, Status_value)
|
proto.RegisterEnum("containerd.v1.types.Status", Status_name, Status_value)
|
||||||
proto.RegisterEnum("containerd.v1.types.Event_EventType", Event_EventType_name, Event_EventType_value)
|
|
||||||
}
|
}
|
||||||
func (m *Task) Marshal() (dAtA []byte, err error) {
|
func (m *Task) Marshal() (dAtA []byte, err error) {
|
||||||
size := m.Size()
|
size := m.Size()
|
||||||
@ -412,53 +358,6 @@ func (m *User) MarshalTo(dAtA []byte) (int, error) {
|
|||||||
return i, nil
|
return i, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Event) Marshal() (dAtA []byte, err error) {
|
|
||||||
size := m.Size()
|
|
||||||
dAtA = make([]byte, size)
|
|
||||||
n, err := m.MarshalTo(dAtA)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return dAtA[:n], nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Event) MarshalTo(dAtA []byte) (int, error) {
|
|
||||||
var i int
|
|
||||||
_ = i
|
|
||||||
var l int
|
|
||||||
_ = l
|
|
||||||
if len(m.ID) > 0 {
|
|
||||||
dAtA[i] = 0xa
|
|
||||||
i++
|
|
||||||
i = encodeVarintTask(dAtA, i, uint64(len(m.ID)))
|
|
||||||
i += copy(dAtA[i:], m.ID)
|
|
||||||
}
|
|
||||||
if m.Type != 0 {
|
|
||||||
dAtA[i] = 0x10
|
|
||||||
i++
|
|
||||||
i = encodeVarintTask(dAtA, i, uint64(m.Type))
|
|
||||||
}
|
|
||||||
if m.Pid != 0 {
|
|
||||||
dAtA[i] = 0x18
|
|
||||||
i++
|
|
||||||
i = encodeVarintTask(dAtA, i, uint64(m.Pid))
|
|
||||||
}
|
|
||||||
if m.ExitStatus != 0 {
|
|
||||||
dAtA[i] = 0x20
|
|
||||||
i++
|
|
||||||
i = encodeVarintTask(dAtA, i, uint64(m.ExitStatus))
|
|
||||||
}
|
|
||||||
dAtA[i] = 0x2a
|
|
||||||
i++
|
|
||||||
i = encodeVarintTask(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.ExitedAt)))
|
|
||||||
n6, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.ExitedAt, dAtA[i:])
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
i += n6
|
|
||||||
return i, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeFixed64Task(dAtA []byte, offset int, v uint64) int {
|
func encodeFixed64Task(dAtA []byte, offset int, v uint64) int {
|
||||||
dAtA[offset] = uint8(v)
|
dAtA[offset] = uint8(v)
|
||||||
dAtA[offset+1] = uint8(v >> 8)
|
dAtA[offset+1] = uint8(v >> 8)
|
||||||
@ -598,27 +497,6 @@ func (m *User) Size() (n int) {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Event) Size() (n int) {
|
|
||||||
var l int
|
|
||||||
_ = l
|
|
||||||
l = len(m.ID)
|
|
||||||
if l > 0 {
|
|
||||||
n += 1 + l + sovTask(uint64(l))
|
|
||||||
}
|
|
||||||
if m.Type != 0 {
|
|
||||||
n += 1 + sovTask(uint64(m.Type))
|
|
||||||
}
|
|
||||||
if m.Pid != 0 {
|
|
||||||
n += 1 + sovTask(uint64(m.Pid))
|
|
||||||
}
|
|
||||||
if m.ExitStatus != 0 {
|
|
||||||
n += 1 + sovTask(uint64(m.ExitStatus))
|
|
||||||
}
|
|
||||||
l = github_com_gogo_protobuf_types.SizeOfStdTime(m.ExitedAt)
|
|
||||||
n += 1 + l + sovTask(uint64(l))
|
|
||||||
return n
|
|
||||||
}
|
|
||||||
|
|
||||||
func sovTask(x uint64) (n int) {
|
func sovTask(x uint64) (n int) {
|
||||||
for {
|
for {
|
||||||
n++
|
n++
|
||||||
@ -683,20 +561,6 @@ func (this *User) String() string {
|
|||||||
}, "")
|
}, "")
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
func (this *Event) String() string {
|
|
||||||
if this == nil {
|
|
||||||
return "nil"
|
|
||||||
}
|
|
||||||
s := strings.Join([]string{`&Event{`,
|
|
||||||
`ID:` + fmt.Sprintf("%v", this.ID) + `,`,
|
|
||||||
`Type:` + fmt.Sprintf("%v", this.Type) + `,`,
|
|
||||||
`Pid:` + fmt.Sprintf("%v", this.Pid) + `,`,
|
|
||||||
`ExitStatus:` + fmt.Sprintf("%v", this.ExitStatus) + `,`,
|
|
||||||
`ExitedAt:` + strings.Replace(strings.Replace(this.ExitedAt.String(), "Timestamp", "google_protobuf2.Timestamp", 1), `&`, ``, 1) + `,`,
|
|
||||||
`}`,
|
|
||||||
}, "")
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
func valueToStringTask(v interface{}) string {
|
func valueToStringTask(v interface{}) string {
|
||||||
rv := reflect.ValueOf(v)
|
rv := reflect.ValueOf(v)
|
||||||
if rv.IsNil() {
|
if rv.IsNil() {
|
||||||
@ -1508,172 +1372,6 @@ func (m *User) Unmarshal(dAtA []byte) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func (m *Event) Unmarshal(dAtA []byte) error {
|
|
||||||
l := len(dAtA)
|
|
||||||
iNdEx := 0
|
|
||||||
for iNdEx < l {
|
|
||||||
preIndex := iNdEx
|
|
||||||
var wire uint64
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowTask
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
wire |= (uint64(b) & 0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fieldNum := int32(wire >> 3)
|
|
||||||
wireType := int(wire & 0x7)
|
|
||||||
if wireType == 4 {
|
|
||||||
return fmt.Errorf("proto: Event: wiretype end group for non-group")
|
|
||||||
}
|
|
||||||
if fieldNum <= 0 {
|
|
||||||
return fmt.Errorf("proto: Event: illegal tag %d (wire type %d)", fieldNum, wire)
|
|
||||||
}
|
|
||||||
switch fieldNum {
|
|
||||||
case 1:
|
|
||||||
if wireType != 2 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
|
|
||||||
}
|
|
||||||
var stringLen uint64
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowTask
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
stringLen |= (uint64(b) & 0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
intStringLen := int(stringLen)
|
|
||||||
if intStringLen < 0 {
|
|
||||||
return ErrInvalidLengthTask
|
|
||||||
}
|
|
||||||
postIndex := iNdEx + intStringLen
|
|
||||||
if postIndex > l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
m.ID = string(dAtA[iNdEx:postIndex])
|
|
||||||
iNdEx = postIndex
|
|
||||||
case 2:
|
|
||||||
if wireType != 0 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType)
|
|
||||||
}
|
|
||||||
m.Type = 0
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowTask
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
m.Type |= (Event_EventType(b) & 0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 3:
|
|
||||||
if wireType != 0 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Pid", wireType)
|
|
||||||
}
|
|
||||||
m.Pid = 0
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowTask
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
m.Pid |= (uint32(b) & 0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 4:
|
|
||||||
if wireType != 0 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field ExitStatus", wireType)
|
|
||||||
}
|
|
||||||
m.ExitStatus = 0
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowTask
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
m.ExitStatus |= (uint32(b) & 0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 5:
|
|
||||||
if wireType != 2 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field ExitedAt", wireType)
|
|
||||||
}
|
|
||||||
var msglen int
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowTask
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
msglen |= (int(b) & 0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if msglen < 0 {
|
|
||||||
return ErrInvalidLengthTask
|
|
||||||
}
|
|
||||||
postIndex := iNdEx + msglen
|
|
||||||
if postIndex > l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.ExitedAt, dAtA[iNdEx:postIndex]); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
iNdEx = postIndex
|
|
||||||
default:
|
|
||||||
iNdEx = preIndex
|
|
||||||
skippy, err := skipTask(dAtA[iNdEx:])
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if skippy < 0 {
|
|
||||||
return ErrInvalidLengthTask
|
|
||||||
}
|
|
||||||
if (iNdEx + skippy) > l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
iNdEx += skippy
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if iNdEx > l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
func skipTask(dAtA []byte) (n int, err error) {
|
func skipTask(dAtA []byte) (n int, err error) {
|
||||||
l := len(dAtA)
|
l := len(dAtA)
|
||||||
iNdEx := 0
|
iNdEx := 0
|
||||||
@ -1784,54 +1482,45 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var fileDescriptorTask = []byte{
|
var fileDescriptorTask = []byte{
|
||||||
// 775 bytes of a gzipped FileDescriptorProto
|
// 630 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x4d, 0x6f, 0xe3, 0x44,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xc1, 0x4e, 0xdb, 0x40,
|
||||||
0x18, 0x8e, 0x1d, 0xe7, 0x6b, 0xd2, 0x66, 0xcd, 0x50, 0xad, 0xbc, 0x01, 0x39, 0x56, 0x84, 0x44,
|
0x14, 0x8c, 0x1d, 0xe3, 0x24, 0xeb, 0x04, 0xdc, 0x2d, 0x42, 0x26, 0xad, 0x8c, 0xc5, 0xa5, 0x56,
|
||||||
0x84, 0x84, 0x23, 0xb2, 0x07, 0x10, 0xb7, 0xb4, 0xb6, 0x56, 0x11, 0x22, 0x0d, 0x13, 0x47, 0xec,
|
0xa5, 0x3a, 0x6a, 0x38, 0x54, 0xea, 0x0d, 0x48, 0x84, 0xa2, 0x4a, 0x21, 0xda, 0x10, 0xf5, 0x18,
|
||||||
0x2d, 0x9a, 0x66, 0x06, 0x33, 0x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0x1c, 0x9f, 0x3a, 0x35, 0x4f, 0xf3, 0xab, 0x68, 0x36, 0x6f, 0xff,
|
||||||
0x69, 0x96, 0xc1, 0x2e, 0x68, 0x4a, 0x9a, 0x5d, 0x32, 0x8e, 0x2f, 0x9c, 0x96, 0x67, 0x0c, 0x9a,
|
0xd5, 0x41, 0x65, 0x90, 0x44, 0x13, 0x2a, 0xc4, 0xfd, 0x79, 0xda, 0xfc, 0x3c, 0x08, 0x0c, 0x9c,
|
||||||
0x68, 0x73, 0xee, 0xff, 0x67, 0x82, 0xc6, 0x2c, 0x4b, 0x56, 0x54, 0x88, 0xbb, 0xf1, 0x8c, 0xed,
|
0x84, 0xc2, 0xd1, 0xbd, 0xb2, 0x5f, 0x43, 0x0a, 0x67, 0x2e, 0xca, 0xcf, 0x9d, 0xb2, 0xa2, 0x32,
|
||||||
0x78, 0x10, 0x58, 0x38, 0x8b, 0x85, 0x63, 0x7a, 0xd5, 0x41, 0x0b, 0xe9, 0x5a, 0xb1, 0x28, 0xbf,
|
0x08, 0x5f, 0x01, 0x23, 0x15, 0x34, 0x51, 0x11, 0x58, 0xed, 0xcd, 0xa5, 0x11, 0x8c, 0x04, 0x4d,
|
||||||
0x72, 0xaa, 0xba, 0xa5, 0x4a, 0xf8, 0x29, 0xb0, 0x72, 0x41, 0x33, 0x6d, 0x41, 0x7b, 0xf4, 0x64,
|
0x90, 0xb2, 0x65, 0x7f, 0x30, 0xb9, 0x20, 0xea, 0xfa, 0x1a, 0xca, 0xe0, 0x83, 0x05, 0xcd, 0x87,
|
||||||
0xaf, 0x05, 0x0b, 0x41, 0x33, 0xa4, 0x69, 0xea, 0x81, 0xd5, 0x0b, 0xa2, 0xa7, 0x6f, 0x21, 0x55,
|
0x0b, 0xc2, 0x2d, 0x60, 0xd1, 0x4f, 0x4c, 0x8e, 0x8b, 0x98, 0x2b, 0x6a, 0x39, 0x90, 0x51, 0x79,
|
||||||
0xbe, 0x21, 0xb0, 0xfe, 0xa6, 0x40, 0xd8, 0x03, 0x6d, 0xfa, 0x03, 0x93, 0xcb, 0xd2, 0xe6, 0x86,
|
0xaa, 0x0b, 0x15, 0x54, 0xff, 0xbf, 0x82, 0x37, 0xa0, 0x9e, 0xa4, 0x5c, 0xb2, 0x33, 0x3a, 0x26,
|
||||||
0x16, 0x07, 0x54, 0xab, 0x70, 0x75, 0x27, 0x82, 0xe6, 0xbb, 0x47, 0xf0, 0x39, 0x38, 0xc8, 0x72,
|
0x58, 0x62, 0x15, 0xcb, 0x63, 0x55, 0x58, 0x85, 0xb3, 0x83, 0x25, 0x9e, 0x37, 0x02, 0x96, 0x37,
|
||||||
0xae, 0x96, 0x66, 0x49, 0xb0, 0xc4, 0xda, 0x96, 0x87, 0xa2, 0x68, 0x97, 0xcc, 0x00, 0x4b, 0xbc,
|
0x62, 0x3d, 0xd2, 0x48, 0x7d, 0xb1, 0x91, 0xed, 0x21, 0x30, 0x46, 0x45, 0x14, 0xe9, 0x3c, 0xf1,
|
||||||
0x4d, 0x04, 0xec, 0x4f, 0xa4, 0xfd, 0x40, 0x22, 0x07, 0xbb, 0x89, 0xf4, 0xe7, 0xc0, 0x5a, 0x94,
|
0x94, 0xa9, 0x27, 0x16, 0x16, 0xaf, 0xb1, 0x81, 0x32, 0x08, 0x5f, 0x80, 0x35, 0x4c, 0x08, 0x93,
|
||||||
0x56, 0xe4, 0x5b, 0xc7, 0x73, 0xa6, 0x57, 0x2c, 0x2e, 0xb7, 0xf1, 0x10, 0xa9, 0x12, 0x7e, 0x0c,
|
0x2c, 0xe2, 0xf8, 0x74, 0x1c, 0x32, 0x22, 0x54, 0xf6, 0x0d, 0xb4, 0x3a, 0xa7, 0x0f, 0x18, 0x11,
|
||||||
0x1e, 0x61, 0x42, 0x98, 0x64, 0x09, 0xc7, 0x17, 0xcb, 0x98, 0x11, 0xa1, 0xbd, 0x3f, 0x44, 0x9d,
|
0x2f, 0x7f, 0x68, 0xc0, 0x2c, 0x32, 0x71, 0x41, 0x65, 0xd4, 0x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x29,
|
|
||||||
0x25, 0xf0, 0xc3, 0x8d, 0x2c, 0xab, 0x6b, 0xbf, 0x7c, 0xe5, 0x1d, 0x14, 0xf0, 0x0c, 0xe7, 0x82,
|
|
||||||
0x92, 0x6e, 0xe7, 0xa7, 0x5f, 0xdd, 0xca, 0x9f, 0xbf, 0xb9, 0xa5, 0xda, 0x63, 0xe7, 0xe6, 0xb5,
|
|
||||||
0x5b, 0xf9, 0xfb, 0xb5, 0x5b, 0xf9, 0x71, 0xed, 0x1a, 0x37, 0x6b, 0xd7, 0xf8, 0x6b, 0xed, 0x1a,
|
|
||||||
0xff, 0xae, 0x5d, 0xe3, 0xac, 0xae, 0xdd, 0x7c, 0xfa, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x48,
|
|
||||||
0xcc, 0xfd, 0x9a, 0x96, 0x05, 0x00, 0x00,
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ package containerd.v1.types;
|
|||||||
|
|
||||||
import "gogoproto/gogo.proto";
|
import "gogoproto/gogo.proto";
|
||||||
import "google/protobuf/any.proto";
|
import "google/protobuf/any.proto";
|
||||||
import "google/protobuf/timestamp.proto";
|
|
||||||
|
|
||||||
enum Status {
|
enum Status {
|
||||||
option (gogoproto.goproto_enum_prefix) = false;
|
option (gogoproto.goproto_enum_prefix) = false;
|
||||||
@ -49,21 +48,3 @@ message User {
|
|||||||
uint32 gid = 2;
|
uint32 gid = 2;
|
||||||
repeated uint32 additional_gids = 3;
|
repeated uint32 additional_gids = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Event {
|
|
||||||
string id = 1;
|
|
||||||
|
|
||||||
enum EventType {
|
|
||||||
EXIT = 0;
|
|
||||||
OOM = 1;
|
|
||||||
CREATE = 2;
|
|
||||||
START = 3;
|
|
||||||
EXEC_ADDED = 4;
|
|
||||||
PAUSED = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
EventType type = 2;
|
|
||||||
uint32 pid = 3;
|
|
||||||
uint32 exit_status = 4;
|
|
||||||
google.protobuf.Timestamp exited_at = 5 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
|
|
||||||
}
|
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
@ -13,8 +14,8 @@ import (
|
|||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
shimapi "github.com/containerd/containerd/api/services/shim/v1"
|
|
||||||
"github.com/containerd/containerd/linux/shim"
|
"github.com/containerd/containerd/linux/shim"
|
||||||
|
shimapi "github.com/containerd/containerd/linux/shim/v1"
|
||||||
"github.com/containerd/containerd/reaper"
|
"github.com/containerd/containerd/reaper"
|
||||||
"github.com/containerd/containerd/version"
|
"github.com/containerd/containerd/version"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
@ -66,7 +67,7 @@ func main() {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
server := grpc.NewServer()
|
server := grpc.NewServer()
|
||||||
sv, err := shim.New(path, context.GlobalString("namespace"))
|
sv, err := shim.NewService(path, context.GlobalString("namespace"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -114,7 +115,24 @@ func handleSignals(signals chan os.Signal, server *grpc.Server) error {
|
|||||||
// i.e. machine reboot
|
// i.e. machine reboot
|
||||||
server.Stop()
|
server.Stop()
|
||||||
return nil
|
return nil
|
||||||
|
case unix.SIGUSR1:
|
||||||
|
dumpStacks()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func dumpStacks() {
|
||||||
|
var (
|
||||||
|
buf []byte
|
||||||
|
stackSize int
|
||||||
|
)
|
||||||
|
bufferLen := 16384
|
||||||
|
for stackSize == len(buf) {
|
||||||
|
buf = make([]byte, bufferLen)
|
||||||
|
stackSize = runtime.Stack(buf, true)
|
||||||
|
bufferLen *= 2
|
||||||
|
}
|
||||||
|
buf = buf[:stackSize]
|
||||||
|
logrus.Infof("=== BEGIN goroutine stack dump ===\n%s\n=== END goroutine stack dump ===", buf)
|
||||||
|
}
|
||||||
|
@ -19,13 +19,16 @@ import (
|
|||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/containerd/console"
|
"github.com/containerd/console"
|
||||||
"github.com/containerd/containerd/api/services/shim/v1"
|
shim "github.com/containerd/containerd/linux/shim/v1"
|
||||||
protobuf "github.com/gogo/protobuf/types"
|
protobuf "github.com/gogo/protobuf/types"
|
||||||
|
google_protobuf "github.com/golang/protobuf/ptypes/empty"
|
||||||
"github.com/opencontainers/runtime-spec/specs-go"
|
"github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var empty = &google_protobuf.Empty{}
|
||||||
|
|
||||||
var fifoFlags = []cli.Flag{
|
var fifoFlags = []cli.Flag{
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "stdin",
|
Name: "stdin",
|
||||||
@ -94,7 +97,7 @@ var shimCreateCommand = cli.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
r, err := service.Create(ctx, &shim.CreateRequest{
|
r, err := service.Create(ctx, &shim.CreateTaskRequest{
|
||||||
ID: id,
|
ID: id,
|
||||||
Bundle: context.String("bundle"),
|
Bundle: context.String("bundle"),
|
||||||
Runtime: context.String("runtime"),
|
Runtime: context.String("runtime"),
|
||||||
@ -118,7 +121,7 @@ var shimCreateCommand = cli.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if _, err := service.Pty(ctx, &shim.PtyRequest{
|
if _, err := service.ResizePty(ctx, &shim.ResizePtyRequest{
|
||||||
Pid: r.Pid,
|
Pid: r.Pid,
|
||||||
Width: uint32(size.Width),
|
Width: uint32(size.Width),
|
||||||
Height: uint32(size.Height),
|
Height: uint32(size.Height),
|
||||||
@ -140,7 +143,7 @@ var shimStartCommand = cli.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, err = service.Start(gocontext.Background(), &shim.StartRequest{})
|
_, err = service.Start(gocontext.Background(), empty)
|
||||||
return err
|
return err
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -153,7 +156,7 @@ var shimDeleteCommand = cli.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
r, err := service.Delete(gocontext.Background(), &shim.DeleteRequest{})
|
r, err := service.Delete(gocontext.Background(), empty)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -170,7 +173,7 @@ var shimStateCommand = cli.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
r, err := service.State(gocontext.Background(), &shim.StateRequest{})
|
r, err := service.State(gocontext.Background(), empty)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -227,7 +230,7 @@ var shimExecCommand = cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
rq := &shim.ExecRequest{
|
rq := &shim.ExecProcessRequest{
|
||||||
Spec: &protobuf.Any{
|
Spec: &protobuf.Any{
|
||||||
TypeUrl: specs.Version,
|
TypeUrl: specs.Version,
|
||||||
Value: spec,
|
Value: spec,
|
||||||
@ -254,7 +257,7 @@ var shimExecCommand = cli.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if _, err := service.Pty(ctx, &shim.PtyRequest{
|
if _, err := service.ResizePty(ctx, &shim.ResizePtyRequest{
|
||||||
Pid: r.Pid,
|
Pid: r.Pid,
|
||||||
Width: uint32(size.Width),
|
Width: uint32(size.Width),
|
||||||
Height: uint32(size.Height),
|
Height: uint32(size.Height),
|
||||||
@ -276,7 +279,7 @@ var shimEventsCommand = cli.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
events, err := service.Events(gocontext.Background(), &shim.EventsRequest{})
|
events, err := service.Stream(gocontext.Background(), &shim.StreamEventsRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
91
linux/bundle.go
Normal file
91
linux/bundle.go
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
// +build linux
|
||||||
|
|
||||||
|
package linux
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
client "github.com/containerd/containerd/linux/shim"
|
||||||
|
)
|
||||||
|
|
||||||
|
func loadBundle(path, namespace string) *bundle {
|
||||||
|
return &bundle{
|
||||||
|
path: path,
|
||||||
|
namespace: namespace,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// newBundle creates a new bundle on disk at the provided path for the given id
|
||||||
|
func newBundle(path, namespace, id string, spec []byte) (b *bundle, err error) {
|
||||||
|
if err := os.MkdirAll(path, 0700); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
path = filepath.Join(path, id)
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
os.RemoveAll(path)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
if err := os.Mkdir(path, 0700); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := os.Mkdir(filepath.Join(path, "rootfs"), 0700); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
f, err := os.Create(filepath.Join(path, configFilename))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
_, err = io.Copy(f, bytes.NewReader(spec))
|
||||||
|
return &bundle{
|
||||||
|
path: path,
|
||||||
|
namespace: namespace,
|
||||||
|
}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
type bundle struct {
|
||||||
|
path string
|
||||||
|
namespace string
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewShim connects to the shim managing the bundle and tasks
|
||||||
|
func (b *bundle) NewShim(ctx context.Context, binary string, remote bool) (*client.Client, error) {
|
||||||
|
opt := client.WithStart(binary)
|
||||||
|
if !remote {
|
||||||
|
opt = client.WithLocal
|
||||||
|
}
|
||||||
|
return client.New(ctx, client.Config{
|
||||||
|
Address: filepath.Join(b.path, "shim.sock"),
|
||||||
|
Path: b.path,
|
||||||
|
Namespace: b.namespace,
|
||||||
|
}, opt)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Connect reconnects to an existing shim
|
||||||
|
func (b *bundle) Connect(ctx context.Context, remote bool) (*client.Client, error) {
|
||||||
|
opt := client.WithConnect
|
||||||
|
if !remote {
|
||||||
|
opt = client.WithLocal
|
||||||
|
}
|
||||||
|
return client.New(ctx, client.Config{
|
||||||
|
Address: filepath.Join(b.path, "shim.sock"),
|
||||||
|
Path: b.path,
|
||||||
|
Namespace: b.namespace,
|
||||||
|
}, opt)
|
||||||
|
}
|
||||||
|
|
||||||
|
// spec returns the spec written to the bundle
|
||||||
|
func (b *bundle) Spec() ([]byte, error) {
|
||||||
|
return ioutil.ReadFile(filepath.Join(b.path, configFilename))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete deletes the bundle from disk
|
||||||
|
func (b *bundle) Delete() error {
|
||||||
|
return os.RemoveAll(b.path)
|
||||||
|
}
|
75
linux/list.go
Normal file
75
linux/list.go
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
// +build linux
|
||||||
|
|
||||||
|
package linux
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/containerd/containerd/namespaces"
|
||||||
|
)
|
||||||
|
|
||||||
|
func newTaskList() *taskList {
|
||||||
|
return &taskList{
|
||||||
|
tasks: make(map[string]map[string]*Task),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type taskList struct {
|
||||||
|
mu sync.Mutex
|
||||||
|
tasks map[string]map[string]*Task
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *taskList) get(ctx context.Context, id string) (*Task, error) {
|
||||||
|
l.mu.Lock()
|
||||||
|
defer l.mu.Unlock()
|
||||||
|
namespace, err := namespaces.NamespaceRequired(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
tasks, ok := l.tasks[namespace]
|
||||||
|
if !ok {
|
||||||
|
return nil, ErrTaskNotExists
|
||||||
|
}
|
||||||
|
t, ok := tasks[id]
|
||||||
|
if !ok {
|
||||||
|
return nil, ErrTaskNotExists
|
||||||
|
}
|
||||||
|
return t, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *taskList) add(ctx context.Context, t *Task) error {
|
||||||
|
namespace, err := namespaces.NamespaceRequired(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return l.addWithNamespace(namespace, t)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *taskList) addWithNamespace(namespace string, t *Task) error {
|
||||||
|
l.mu.Lock()
|
||||||
|
defer l.mu.Unlock()
|
||||||
|
|
||||||
|
id := t.containerID
|
||||||
|
if _, ok := l.tasks[namespace]; !ok {
|
||||||
|
l.tasks[namespace] = make(map[string]*Task)
|
||||||
|
}
|
||||||
|
if _, ok := l.tasks[namespace][id]; ok {
|
||||||
|
return ErrTaskAlreadyExists
|
||||||
|
}
|
||||||
|
l.tasks[namespace][id] = t
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *taskList) delete(ctx context.Context, t *Task) {
|
||||||
|
l.mu.Lock()
|
||||||
|
defer l.mu.Unlock()
|
||||||
|
namespace, err := namespaces.NamespaceRequired(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tasks, ok := l.tasks[namespace]
|
||||||
|
if ok {
|
||||||
|
delete(tasks, t.containerID)
|
||||||
|
}
|
||||||
|
}
|
310
linux/runtime.go
310
linux/runtime.go
@ -3,29 +3,29 @@
|
|||||||
package linux
|
package linux
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
|
||||||
|
"github.com/boltdb/bolt"
|
||||||
eventsapi "github.com/containerd/containerd/api/services/events/v1"
|
eventsapi "github.com/containerd/containerd/api/services/events/v1"
|
||||||
"github.com/containerd/containerd/api/services/shim/v1"
|
|
||||||
"github.com/containerd/containerd/api/types"
|
"github.com/containerd/containerd/api/types"
|
||||||
"github.com/containerd/containerd/api/types/task"
|
"github.com/containerd/containerd/containers"
|
||||||
"github.com/containerd/containerd/events"
|
"github.com/containerd/containerd/events"
|
||||||
shimb "github.com/containerd/containerd/linux/shim"
|
client "github.com/containerd/containerd/linux/shim"
|
||||||
|
shim "github.com/containerd/containerd/linux/shim/v1"
|
||||||
"github.com/containerd/containerd/log"
|
"github.com/containerd/containerd/log"
|
||||||
|
"github.com/containerd/containerd/metadata"
|
||||||
"github.com/containerd/containerd/namespaces"
|
"github.com/containerd/containerd/namespaces"
|
||||||
"github.com/containerd/containerd/plugin"
|
"github.com/containerd/containerd/plugin"
|
||||||
runc "github.com/containerd/go-runc"
|
runc "github.com/containerd/go-runc"
|
||||||
|
google_protobuf "github.com/golang/protobuf/ptypes/empty"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
@ -35,6 +35,7 @@ var (
|
|||||||
ErrTaskNotExists = errors.New("task does not exist")
|
ErrTaskNotExists = errors.New("task does not exist")
|
||||||
ErrTaskAlreadyExists = errors.New("task already exists")
|
ErrTaskAlreadyExists = errors.New("task already exists")
|
||||||
pluginID = fmt.Sprintf("%s.%s", plugin.RuntimePlugin, "linux")
|
pluginID = fmt.Sprintf("%s.%s", plugin.RuntimePlugin, "linux")
|
||||||
|
empty = &google_protobuf.Empty{}
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -50,6 +51,7 @@ func init() {
|
|||||||
Init: New,
|
Init: New,
|
||||||
Requires: []plugin.PluginType{
|
Requires: []plugin.PluginType{
|
||||||
plugin.TaskMonitorPlugin,
|
plugin.TaskMonitorPlugin,
|
||||||
|
plugin.MetadataPlugin,
|
||||||
},
|
},
|
||||||
Config: &Config{
|
Config: &Config{
|
||||||
Shim: defaultShim,
|
Shim: defaultShim,
|
||||||
@ -69,71 +71,6 @@ type Config struct {
|
|||||||
NoShim bool `toml:"no_shim,omitempty"`
|
NoShim bool `toml:"no_shim,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTaskList() *taskList {
|
|
||||||
return &taskList{
|
|
||||||
tasks: make(map[string]map[string]*Task),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type taskList struct {
|
|
||||||
mu sync.Mutex
|
|
||||||
tasks map[string]map[string]*Task
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *taskList) get(ctx context.Context, id string) (*Task, error) {
|
|
||||||
l.mu.Lock()
|
|
||||||
defer l.mu.Unlock()
|
|
||||||
namespace, err := namespaces.NamespaceRequired(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
tasks, ok := l.tasks[namespace]
|
|
||||||
if !ok {
|
|
||||||
return nil, ErrTaskNotExists
|
|
||||||
}
|
|
||||||
t, ok := tasks[id]
|
|
||||||
if !ok {
|
|
||||||
return nil, ErrTaskNotExists
|
|
||||||
}
|
|
||||||
return t, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *taskList) add(ctx context.Context, t *Task) error {
|
|
||||||
namespace, err := namespaces.NamespaceRequired(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return l.addWithNamespace(namespace, t)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *taskList) addWithNamespace(namespace string, t *Task) error {
|
|
||||||
l.mu.Lock()
|
|
||||||
defer l.mu.Unlock()
|
|
||||||
|
|
||||||
id := t.containerID
|
|
||||||
if _, ok := l.tasks[namespace]; !ok {
|
|
||||||
l.tasks[namespace] = make(map[string]*Task)
|
|
||||||
}
|
|
||||||
if _, ok := l.tasks[namespace][id]; ok {
|
|
||||||
return ErrTaskAlreadyExists
|
|
||||||
}
|
|
||||||
l.tasks[namespace][id] = t
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *taskList) delete(ctx context.Context, t *Task) {
|
|
||||||
l.mu.Lock()
|
|
||||||
defer l.mu.Unlock()
|
|
||||||
namespace, err := namespaces.NamespaceRequired(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
tasks, ok := l.tasks[namespace]
|
|
||||||
if ok {
|
|
||||||
delete(tasks, t.containerID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func New(ic *plugin.InitContext) (interface{}, error) {
|
func New(ic *plugin.InitContext) (interface{}, error) {
|
||||||
if err := os.MkdirAll(ic.Root, 0700); err != nil {
|
if err := os.MkdirAll(ic.Root, 0700); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -142,6 +79,10 @@ func New(ic *plugin.InitContext) (interface{}, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
m, err := ic.Get(plugin.MetadataPlugin)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
cfg := ic.Config.(*Config)
|
cfg := ic.Config.(*Config)
|
||||||
c, cancel := context.WithCancel(ic.Context)
|
c, cancel := context.WithCancel(ic.Context)
|
||||||
r := &Runtime{
|
r := &Runtime{
|
||||||
@ -155,10 +96,11 @@ func New(ic *plugin.InitContext) (interface{}, error) {
|
|||||||
monitor: monitor.(plugin.TaskMonitor),
|
monitor: monitor.(plugin.TaskMonitor),
|
||||||
tasks: newTaskList(),
|
tasks: newTaskList(),
|
||||||
emitter: events.GetPoster(ic.Context),
|
emitter: events.GetPoster(ic.Context),
|
||||||
|
db: m.(*bolt.DB),
|
||||||
}
|
}
|
||||||
// set the events output for a monitor if it generates events
|
// set the events output for a monitor if it generates events
|
||||||
r.monitor.Events(r.events)
|
r.monitor.Events(r.events)
|
||||||
tasks, err := r.loadAllTasks(ic.Context)
|
tasks, err := r.restoreTasks(ic.Context)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -166,6 +108,9 @@ func New(ic *plugin.InitContext) (interface{}, error) {
|
|||||||
if err := r.tasks.addWithNamespace(t.namespace, t); err != nil {
|
if err := r.tasks.addWithNamespace(t.namespace, t); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if err := r.handleEvents(ic.Context, t.shim); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return r, nil
|
return r, nil
|
||||||
}
|
}
|
||||||
@ -182,39 +127,44 @@ type Runtime struct {
|
|||||||
monitor plugin.TaskMonitor
|
monitor plugin.TaskMonitor
|
||||||
tasks *taskList
|
tasks *taskList
|
||||||
emitter events.Poster
|
emitter events.Poster
|
||||||
|
db *bolt.DB
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Runtime) ID() string {
|
func (r *Runtime) ID() string {
|
||||||
return pluginID
|
return pluginID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Runtime) Create(ctx context.Context, id string, opts plugin.CreateOpts) (t plugin.Task, err error) {
|
func (r *Runtime) Create(ctx context.Context, id string, opts plugin.CreateOpts) (_ plugin.Task, err error) {
|
||||||
namespace, err := namespaces.NamespaceRequired(ctx)
|
namespace, err := namespaces.NamespaceRequired(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
path, err := r.newBundle(namespace, id, opts.Spec)
|
bundle, err := newBundle(filepath.Join(r.root, namespace), namespace, id, opts.Spec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
s, err := newShim(ctx, r.shim, path, namespace, r.remote)
|
|
||||||
if err != nil {
|
|
||||||
os.RemoveAll(path)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
// Exit the shim on error
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.Exit(context.Background(), &shim.ExitRequest{})
|
bundle.Delete()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
s, err := bundle.NewShim(ctx, r.shim, r.remote)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
if kerr := s.KillShim(ctx); kerr != nil {
|
||||||
|
log.G(ctx).WithError(err).Error("failed to kill shim")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
if err = r.handleEvents(ctx, s); err != nil {
|
if err = r.handleEvents(ctx, s); err != nil {
|
||||||
os.RemoveAll(path)
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
sopts := &shim.CreateRequest{
|
sopts := &shim.CreateTaskRequest{
|
||||||
ID: id,
|
ID: id,
|
||||||
Bundle: path,
|
Bundle: bundle.path,
|
||||||
Runtime: r.runtime,
|
Runtime: r.runtime,
|
||||||
Stdin: opts.IO.Stdin,
|
Stdin: opts.IO.Stdin,
|
||||||
Stdout: opts.IO.Stdout,
|
Stdout: opts.IO.Stdout,
|
||||||
@ -230,15 +180,14 @@ func (r *Runtime) Create(ctx context.Context, id string, opts plugin.CreateOpts)
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
if _, err = s.Create(ctx, sopts); err != nil {
|
if _, err = s.Create(ctx, sopts); err != nil {
|
||||||
os.RemoveAll(path)
|
|
||||||
return nil, errors.New(grpc.ErrorDesc(err))
|
return nil, errors.New(grpc.ErrorDesc(err))
|
||||||
}
|
}
|
||||||
c := newTask(id, namespace, opts.Spec, s)
|
t := newTask(id, namespace, opts.Spec, s)
|
||||||
if err := r.tasks.add(ctx, c); err != nil {
|
if err := r.tasks.add(ctx, t); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// after the task is created, add it to the monitor
|
// after the task is created, add it to the monitor
|
||||||
if err = r.monitor.Monitor(c); err != nil {
|
if err = r.monitor.Monitor(t); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +201,7 @@ func (r *Runtime) Create(ctx context.Context, id string, opts plugin.CreateOpts)
|
|||||||
}
|
}
|
||||||
if err := r.emit(ctx, "/runtime/create", &eventsapi.RuntimeCreate{
|
if err := r.emit(ctx, "/runtime/create", &eventsapi.RuntimeCreate{
|
||||||
ID: id,
|
ID: id,
|
||||||
Bundle: path,
|
Bundle: bundle.path,
|
||||||
RootFS: runtimeMounts,
|
RootFS: runtimeMounts,
|
||||||
IO: &eventsapi.RuntimeIO{
|
IO: &eventsapi.RuntimeIO{
|
||||||
Stdin: opts.IO.Stdin,
|
Stdin: opts.IO.Stdin,
|
||||||
@ -264,8 +213,7 @@ func (r *Runtime) Create(ctx context.Context, id string, opts plugin.CreateOpts)
|
|||||||
}); err != nil {
|
}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
return t, nil
|
||||||
return c, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Runtime) Delete(ctx context.Context, c plugin.Task) (*plugin.Exit, error) {
|
func (r *Runtime) Delete(ctx context.Context, c plugin.Task) (*plugin.Exit, error) {
|
||||||
@ -275,22 +223,25 @@ func (r *Runtime) Delete(ctx context.Context, c plugin.Task) (*plugin.Exit, erro
|
|||||||
}
|
}
|
||||||
lc, ok := c.(*Task)
|
lc, ok := c.(*Task)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("container cannot be cast as *linux.Container")
|
return nil, fmt.Errorf("task cannot be cast as *linux.Task")
|
||||||
}
|
}
|
||||||
// remove the container from the monitor
|
|
||||||
if err := r.monitor.Stop(lc); err != nil {
|
if err := r.monitor.Stop(lc); err != nil {
|
||||||
// TODO: log error here
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
rsp, err := lc.shim.Delete(ctx, &shim.DeleteRequest{})
|
rsp, err := lc.shim.Delete(ctx, empty)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New(grpc.ErrorDesc(err))
|
return nil, errors.New(grpc.ErrorDesc(err))
|
||||||
}
|
}
|
||||||
lc.shim.Exit(ctx, &shim.ExitRequest{})
|
if err := lc.shim.KillShim(ctx); err != nil {
|
||||||
|
log.G(ctx).WithError(err).Error("failed to kill shim")
|
||||||
|
}
|
||||||
r.tasks.delete(ctx, lc)
|
r.tasks.delete(ctx, lc)
|
||||||
|
|
||||||
i := c.Info()
|
var (
|
||||||
if err := r.emit(ctx, "/runtime/delete", &eventsapi.RuntimeDelete{
|
bundle = loadBundle(filepath.Join(r.root, namespace, lc.containerID), namespace)
|
||||||
|
i = c.Info()
|
||||||
|
)
|
||||||
|
if err := r.emit(ctx, "/runtime/delete", eventsapi.RuntimeDelete{
|
||||||
ID: i.ID,
|
ID: i.ID,
|
||||||
Runtime: i.Runtime,
|
Runtime: i.Runtime,
|
||||||
ExitStatus: rsp.ExitStatus,
|
ExitStatus: rsp.ExitStatus,
|
||||||
@ -302,7 +253,7 @@ func (r *Runtime) Delete(ctx context.Context, c plugin.Task) (*plugin.Exit, erro
|
|||||||
Status: rsp.ExitStatus,
|
Status: rsp.ExitStatus,
|
||||||
Timestamp: rsp.ExitedAt,
|
Timestamp: rsp.ExitedAt,
|
||||||
Pid: rsp.Pid,
|
Pid: rsp.Pid,
|
||||||
}, r.deleteBundle(namespace, lc.containerID)
|
}, bundle.Delete()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Runtime) Tasks(ctx context.Context) ([]plugin.Task, error) {
|
func (r *Runtime) Tasks(ctx context.Context) ([]plugin.Task, error) {
|
||||||
@ -321,17 +272,19 @@ func (r *Runtime) Tasks(ctx context.Context) ([]plugin.Task, error) {
|
|||||||
return o, nil
|
return o, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Runtime) loadAllTasks(ctx context.Context) ([]*Task, error) {
|
func (r *Runtime) restoreTasks(ctx context.Context) ([]*Task, error) {
|
||||||
dir, err := ioutil.ReadDir(r.root)
|
dir, err := ioutil.ReadDir(r.root)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var o []*Task
|
var o []*Task
|
||||||
for _, fi := range dir {
|
for _, namespace := range dir {
|
||||||
if !fi.IsDir() {
|
if !namespace.IsDir() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
tasks, err := r.loadTasks(ctx, fi.Name())
|
name := namespace.Name()
|
||||||
|
log.G(ctx).WithField("namespace", name).Debug("loading tasks in namespace")
|
||||||
|
tasks, err := r.loadTasks(ctx, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -350,28 +303,41 @@ func (r *Runtime) loadTasks(ctx context.Context, ns string) ([]*Task, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var o []*Task
|
var o []*Task
|
||||||
for _, fi := range dir {
|
for _, path := range dir {
|
||||||
if !fi.IsDir() {
|
if !path.IsDir() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
id := fi.Name()
|
id := path.Name()
|
||||||
// TODO: optimize this if it is call frequently to list all containers
|
bundle := loadBundle(filepath.Join(r.root, ns, id), ns)
|
||||||
// i.e. dont' reconnect to the the shim's ever time
|
|
||||||
c, err := r.loadTask(ctx, ns, filepath.Join(r.root, ns, id))
|
s, err := bundle.Connect(ctx, r.remote)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.G(ctx).WithError(err).Warnf("failed to load container %s/%s", ns, id)
|
log.G(ctx).WithError(err).Error("connecting to shim")
|
||||||
// if we fail to load the container, connect to the shim, make sure if the shim has
|
if err := r.terminate(ctx, bundle, ns, id); err != nil {
|
||||||
// been killed and cleanup the resources still being held by the container
|
log.G(ctx).WithError(err).WithField("bundle", bundle.path).Error("failed to terminate task, leaving bundle for debugging")
|
||||||
r.killContainer(ctx, ns, id)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
o = append(o, c)
|
if err := bundle.Delete(); err != nil {
|
||||||
|
log.G(ctx).WithError(err).Error("delete bundle")
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
spec, err := bundle.Spec()
|
||||||
|
if err != nil {
|
||||||
|
log.G(ctx).WithError(err).Error("load task spec")
|
||||||
|
}
|
||||||
|
o = append(o, &Task{
|
||||||
|
containerID: id,
|
||||||
|
shim: s,
|
||||||
|
spec: spec,
|
||||||
|
namespace: ns,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
return o, nil
|
return o, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Runtime) handleEvents(ctx context.Context, s shim.ShimClient) error {
|
func (r *Runtime) handleEvents(ctx context.Context, s *client.Client) error {
|
||||||
events, err := s.Events(r.eventsContext, &shim.EventsRequest{})
|
events, err := s.Stream(r.eventsContext, &shim.StreamEventsRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -379,7 +345,7 @@ func (r *Runtime) handleEvents(ctx context.Context, s shim.ShimClient) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Runtime) forward(ctx context.Context, events shim.Shim_EventsClient) {
|
func (r *Runtime) forward(ctx context.Context, events shim.Shim_StreamClient) {
|
||||||
for {
|
for {
|
||||||
e, err := events.Recv()
|
e, err := events.Recv()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -391,19 +357,19 @@ func (r *Runtime) forward(ctx context.Context, events shim.Shim_EventsClient) {
|
|||||||
topic := ""
|
topic := ""
|
||||||
var et plugin.EventType
|
var et plugin.EventType
|
||||||
switch e.Type {
|
switch e.Type {
|
||||||
case task.Event_CREATE:
|
case shim.Event_CREATE:
|
||||||
topic = "task-create"
|
topic = "task-create"
|
||||||
et = plugin.CreateEvent
|
et = plugin.CreateEvent
|
||||||
case task.Event_START:
|
case shim.Event_START:
|
||||||
topic = "task-start"
|
topic = "task-start"
|
||||||
et = plugin.StartEvent
|
et = plugin.StartEvent
|
||||||
case task.Event_EXEC_ADDED:
|
case shim.Event_EXEC_ADDED:
|
||||||
topic = "task-execadded"
|
topic = "task-execadded"
|
||||||
et = plugin.ExecAddEvent
|
et = plugin.ExecAddEvent
|
||||||
case task.Event_OOM:
|
case shim.Event_OOM:
|
||||||
topic = "task-oom"
|
topic = "task-oom"
|
||||||
et = plugin.OOMEvent
|
et = plugin.OOMEvent
|
||||||
case task.Event_EXIT:
|
case shim.Event_EXIT:
|
||||||
topic = "task-exit"
|
topic = "task-exit"
|
||||||
et = plugin.ExitEvent
|
et = plugin.ExitEvent
|
||||||
}
|
}
|
||||||
@ -418,7 +384,7 @@ func (r *Runtime) forward(ctx context.Context, events shim.Shim_EventsClient) {
|
|||||||
}
|
}
|
||||||
if err := r.emit(ctx, "/runtime/"+topic, &eventsapi.RuntimeEvent{
|
if err := r.emit(ctx, "/runtime/"+topic, &eventsapi.RuntimeEvent{
|
||||||
ID: e.ID,
|
ID: e.ID,
|
||||||
Type: e.Type,
|
Type: eventsapi.RuntimeEvent_EventType(e.Type),
|
||||||
Pid: e.Pid,
|
Pid: e.Pid,
|
||||||
ExitStatus: e.ExitStatus,
|
ExitStatus: e.ExitStatus,
|
||||||
ExitedAt: e.ExitedAt,
|
ExitedAt: e.ExitedAt,
|
||||||
@ -428,89 +394,51 @@ func (r *Runtime) forward(ctx context.Context, events shim.Shim_EventsClient) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Runtime) newBundle(namespace, id string, spec []byte) (string, error) {
|
func (r *Runtime) terminate(ctx context.Context, bundle *bundle, ns, id string) error {
|
||||||
path := filepath.Join(r.root, namespace)
|
ctx = namespaces.WithNamespace(ctx, ns)
|
||||||
if err := os.MkdirAll(path, 0700); err != nil {
|
rt, err := r.getRuntime(ctx, ns, id)
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
path = filepath.Join(path, id)
|
|
||||||
if err := os.Mkdir(path, 0700); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
if err := os.Mkdir(filepath.Join(path, "rootfs"), 0700); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
f, err := os.Create(filepath.Join(path, configFilename))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return err
|
||||||
}
|
}
|
||||||
defer f.Close()
|
if err := rt.Kill(ctx, id, int(unix.SIGKILL), &runc.KillOpts{All: true}); err != nil {
|
||||||
_, err = io.Copy(f, bytes.NewReader(spec))
|
|
||||||
return path, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *Runtime) deleteBundle(namespace, id string) error {
|
|
||||||
return os.RemoveAll(filepath.Join(r.root, namespace, id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *Runtime) loadTask(ctx context.Context, namespace, path string) (*Task, error) {
|
|
||||||
id := filepath.Base(path)
|
|
||||||
s, err := loadShim(path, namespace, r.remote)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = r.handleEvents(ctx, s); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
data, err := ioutil.ReadFile(filepath.Join(path, configFilename))
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &Task{
|
|
||||||
containerID: id,
|
|
||||||
shim: s,
|
|
||||||
spec: data,
|
|
||||||
namespace: namespace,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// killContainer is used whenever the runtime fails to connect to a shim (it died)
|
|
||||||
// and needs to cleanup the container resources in the underlying runtime (runc, etc...)
|
|
||||||
func (r *Runtime) killContainer(ctx context.Context, ns, id string) {
|
|
||||||
log.G(ctx).Debug("terminating container after failed load")
|
|
||||||
runtime := &runc.Runc{
|
|
||||||
// TODO: should we get Command provided for initial container creation?
|
|
||||||
Command: r.runtime,
|
|
||||||
LogFormat: runc.JSON,
|
|
||||||
PdeathSignal: unix.SIGKILL,
|
|
||||||
Root: filepath.Join(shimb.RuncRoot, ns),
|
|
||||||
}
|
|
||||||
if err := runtime.Kill(ctx, id, int(unix.SIGKILL), &runc.KillOpts{
|
|
||||||
All: true,
|
|
||||||
}); err != nil {
|
|
||||||
log.G(ctx).WithError(err).Warnf("kill all processes for %s", id)
|
log.G(ctx).WithError(err).Warnf("kill all processes for %s", id)
|
||||||
}
|
}
|
||||||
// it can take a while for the container to be killed so poll for the container's status
|
// it can take a while for the container to be killed so poll for the container's status
|
||||||
// until it is in a stopped state
|
// until it is in a stopped state
|
||||||
status := "running"
|
status := "running"
|
||||||
for status != "stopped" {
|
for status != "stopped" {
|
||||||
c, err := runtime.State(ctx, id)
|
c, err := rt.State(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
status = c.Status
|
status = c.Status
|
||||||
time.Sleep(10 * time.Millisecond)
|
time.Sleep(50 * time.Millisecond)
|
||||||
}
|
}
|
||||||
if err := runtime.Delete(ctx, id); err != nil {
|
if err := rt.Delete(ctx, id); err != nil {
|
||||||
log.G(ctx).WithError(err).Warnf("delete container %s", id)
|
log.G(ctx).WithError(err).Warnf("delete runtime state %s", id)
|
||||||
}
|
}
|
||||||
// try to unmount the rootfs in case it was not owned by an external mount namespace
|
if err := unix.Unmount(filepath.Join(bundle.path, "rootfs"), 0); err != nil {
|
||||||
unix.Unmount(filepath.Join(r.root, ns, id, "rootfs"), 0)
|
log.G(ctx).WithError(err).Warnf("unmount task rootfs %s", id)
|
||||||
// remove container bundle
|
|
||||||
if err := r.deleteBundle(ns, id); err != nil {
|
|
||||||
log.G(ctx).WithError(err).Warnf("delete container bundle %s", id)
|
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Runtime) getRuntime(ctx context.Context, ns, id string) (*runc.Runc, error) {
|
||||||
|
var c containers.Container
|
||||||
|
if err := r.db.View(func(tx *bolt.Tx) error {
|
||||||
|
store := metadata.NewContainerStore(tx)
|
||||||
|
var err error
|
||||||
|
c, err = store.Get(ctx, id)
|
||||||
|
return err
|
||||||
|
}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &runc.Runc{
|
||||||
|
Command: c.Runtime.Name,
|
||||||
|
LogFormat: runc.JSON,
|
||||||
|
PdeathSignal: unix.SIGKILL,
|
||||||
|
Root: filepath.Join(client.RuncRoot, ns),
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Runtime) emit(ctx context.Context, topic string, evt interface{}) error {
|
func (r *Runtime) emit(ctx context.Context, topic string, evt interface{}) error {
|
||||||
|
@ -1,90 +0,0 @@
|
|||||||
// +build linux
|
|
||||||
|
|
||||||
package linux
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"net"
|
|
||||||
"os/exec"
|
|
||||||
"path/filepath"
|
|
||||||
"syscall"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
|
|
||||||
"github.com/containerd/containerd/api/services/shim/v1"
|
|
||||||
localShim "github.com/containerd/containerd/linux/shim"
|
|
||||||
"github.com/containerd/containerd/log"
|
|
||||||
"github.com/containerd/containerd/reaper"
|
|
||||||
"github.com/containerd/containerd/sys"
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
func newShim(ctx context.Context, shimName string, path, namespace string, remote bool) (shim.ShimClient, error) {
|
|
||||||
if !remote {
|
|
||||||
return localShim.Client(path, namespace)
|
|
||||||
}
|
|
||||||
socket := filepath.Join(path, "shim.sock")
|
|
||||||
l, err := sys.CreateUnixSocket(socket)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
cmd := exec.Command(shimName, "--namespace", namespace)
|
|
||||||
cmd.Dir = path
|
|
||||||
f, err := l.(*net.UnixListener).File()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
// close our side of the socket, do not close the listener as it will
|
|
||||||
// remove the socket from disk
|
|
||||||
defer f.Close()
|
|
||||||
cmd.ExtraFiles = append(cmd.ExtraFiles, f)
|
|
||||||
// make sure the shim can be re-parented to system init
|
|
||||||
// and is cloned in a new mount namespace because the overlay/filesystems
|
|
||||||
// will be mounted by the shim
|
|
||||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
|
||||||
Cloneflags: syscall.CLONE_NEWNS,
|
|
||||||
Setpgid: true,
|
|
||||||
}
|
|
||||||
if err := reaper.Default.Start(cmd); err != nil {
|
|
||||||
return nil, errors.Wrapf(err, "failed to start shim")
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if err != nil {
|
|
||||||
cmd.Process.Kill()
|
|
||||||
reaper.Default.Wait(cmd)
|
|
||||||
} else {
|
|
||||||
log.G(ctx).WithField("socket", socket).Infof("new shim started")
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
if err = sys.SetOOMScore(cmd.Process.Pid, sys.OOMScoreMaxKillable); err != nil {
|
|
||||||
return nil, errors.Wrap(err, "failed to set OOM Score on shim")
|
|
||||||
}
|
|
||||||
return connectShim(socket)
|
|
||||||
}
|
|
||||||
|
|
||||||
func loadShim(path, namespace string, remote bool) (shim.ShimClient, error) {
|
|
||||||
if !remote {
|
|
||||||
return localShim.Client(path, namespace)
|
|
||||||
}
|
|
||||||
socket := filepath.Join(path, "shim.sock")
|
|
||||||
return connectShim(socket)
|
|
||||||
}
|
|
||||||
|
|
||||||
func connectShim(socket string) (shim.ShimClient, error) {
|
|
||||||
// reset the logger for grpc to log to dev/null so that it does not mess with our stdio
|
|
||||||
dialOpts := []grpc.DialOption{grpc.WithInsecure(), grpc.WithTimeout(100 * time.Second)}
|
|
||||||
dialOpts = append(dialOpts,
|
|
||||||
grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
|
|
||||||
return net.DialTimeout("unix", socket, timeout)
|
|
||||||
}),
|
|
||||||
grpc.WithBlock(),
|
|
||||||
grpc.WithTimeout(2*time.Second),
|
|
||||||
)
|
|
||||||
conn, err := grpc.Dial(fmt.Sprintf("unix://%s", socket), dialOpts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrapf(err, "failed to connect to shim via \"%s\"", fmt.Sprintf("unix://%s", socket))
|
|
||||||
}
|
|
||||||
return shim.NewShimClient(conn), nil
|
|
||||||
}
|
|
@ -1,150 +1,181 @@
|
|||||||
// +build !windows
|
// +build linux
|
||||||
|
|
||||||
package shim
|
package shim
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path/filepath"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"net"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
"time"
|
||||||
|
|
||||||
shimapi "github.com/containerd/containerd/api/services/shim/v1"
|
|
||||||
"github.com/containerd/containerd/api/types/task"
|
|
||||||
runc "github.com/containerd/go-runc"
|
|
||||||
google_protobuf "github.com/golang/protobuf/ptypes/empty"
|
|
||||||
"golang.org/x/net/context"
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
|
"github.com/Sirupsen/logrus"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
|
shim "github.com/containerd/containerd/linux/shim/v1"
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
|
"github.com/containerd/containerd/reaper"
|
||||||
|
"github.com/containerd/containerd/sys"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/metadata"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Client(path, namespace string) (shimapi.ShimClient, error) {
|
type ClientOpt func(context.Context, Config) (shim.ShimClient, io.Closer, error)
|
||||||
pid, err := runc.ReadPidFile(filepath.Join(path, "init.pid"))
|
|
||||||
|
// WithStart executes a new shim process
|
||||||
|
func WithStart(binary string) ClientOpt {
|
||||||
|
return func(ctx context.Context, config Config) (shim.ShimClient, io.Closer, error) {
|
||||||
|
socket, err := newSocket(config)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
// close our side of the socket, do not close the listener as it will
|
||||||
|
// remove the socket from disk
|
||||||
|
defer socket.Close()
|
||||||
|
|
||||||
|
cmd := newCommand(binary, config, socket)
|
||||||
|
if err := reaper.Default.Start(cmd); err != nil {
|
||||||
|
return nil, nil, errors.Wrapf(err, "failed to start shim")
|
||||||
|
}
|
||||||
|
log.G(ctx).WithFields(logrus.Fields{
|
||||||
|
"pid": cmd.Process.Pid,
|
||||||
|
"address": config.Address,
|
||||||
|
}).Infof("shim %s started", binary)
|
||||||
|
if err = sys.SetOOMScore(cmd.Process.Pid, sys.OOMScoreMaxKillable); err != nil {
|
||||||
|
return nil, nil, errors.Wrap(err, "failed to set OOM Score on shim")
|
||||||
|
}
|
||||||
|
return WithConnect(ctx, config)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newCommand(binary string, config Config, socket *os.File) *exec.Cmd {
|
||||||
|
args := []string{
|
||||||
|
"--namespace", config.Namespace,
|
||||||
|
}
|
||||||
|
if config.Debug {
|
||||||
|
args = append(args, "--debug")
|
||||||
|
}
|
||||||
|
cmd := exec.Command(binary, args...)
|
||||||
|
cmd.Dir = config.Path
|
||||||
|
// make sure the shim can be re-parented to system init
|
||||||
|
// and is cloned in a new mount namespace because the overlay/filesystems
|
||||||
|
// will be mounted by the shim
|
||||||
|
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||||
|
Cloneflags: syscall.CLONE_NEWNS,
|
||||||
|
Setpgid: true,
|
||||||
|
}
|
||||||
|
cmd.ExtraFiles = append(cmd.ExtraFiles, socket)
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func newSocket(config Config) (*os.File, error) {
|
||||||
|
l, err := sys.CreateUnixSocket(config.Address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
return l.(*net.UnixListener).File()
|
||||||
|
}
|
||||||
|
|
||||||
s, err := New(path, namespace)
|
func connect(address string) (*grpc.ClientConn, error) {
|
||||||
|
gopts := []grpc.DialOption{
|
||||||
|
grpc.WithBlock(),
|
||||||
|
grpc.WithInsecure(),
|
||||||
|
grpc.WithTimeout(100 * time.Second),
|
||||||
|
grpc.WithDialer(dialer),
|
||||||
|
grpc.FailOnNonTempDialError(true),
|
||||||
|
}
|
||||||
|
conn, err := grpc.Dial(dialAddress(address), gopts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrapf(err, "failed to dial %q", address)
|
||||||
|
}
|
||||||
|
return conn, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func dialer(address string, timeout time.Duration) (net.Conn, error) {
|
||||||
|
address = strings.TrimPrefix(address, "unix://")
|
||||||
|
return net.DialTimeout("unix", address, timeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
func dialAddress(address string) string {
|
||||||
|
return fmt.Sprintf("unix://%s", address)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithConnect connects to an existing shim
|
||||||
|
func WithConnect(ctx context.Context, config Config) (shim.ShimClient, io.Closer, error) {
|
||||||
|
conn, err := connect(config.Address)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
return shim.NewShimClient(conn), conn, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithLocal uses an in process shim
|
||||||
|
func WithLocal(ctx context.Context, config Config) (shim.ShimClient, io.Closer, error) {
|
||||||
|
service, err := NewService(config.Path, config.Namespace)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
return NewLocal(service), nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type Config struct {
|
||||||
|
Address string
|
||||||
|
Path string
|
||||||
|
Namespace string
|
||||||
|
Debug bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// New returns a new shim client
|
||||||
|
func New(ctx context.Context, config Config, opt ClientOpt) (*Client, error) {
|
||||||
|
s, c, err := opt(ctx, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
cl := &client{
|
return &Client{
|
||||||
s: s,
|
ShimClient: s,
|
||||||
}
|
c: c,
|
||||||
// used when quering container status and info
|
|
||||||
cl.s.initProcess = &initProcess{
|
|
||||||
id: filepath.Base(path),
|
|
||||||
pid: pid,
|
|
||||||
runc: &runc.Runc{
|
|
||||||
Log: filepath.Join(path, "log.json"),
|
|
||||||
LogFormat: runc.JSON,
|
|
||||||
PdeathSignal: syscall.SIGKILL,
|
|
||||||
Root: filepath.Join(RuncRoot, namespace),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return cl, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type client struct {
|
|
||||||
s *Service
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *client) Create(ctx context.Context, in *shimapi.CreateRequest, opts ...grpc.CallOption) (*shimapi.CreateResponse, error) {
|
|
||||||
return c.s.Create(ctx, in)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *client) Start(ctx context.Context, in *shimapi.StartRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) {
|
|
||||||
return c.s.Start(ctx, in)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *client) Delete(ctx context.Context, in *shimapi.DeleteRequest, opts ...grpc.CallOption) (*shimapi.DeleteResponse, error) {
|
|
||||||
return c.s.Delete(ctx, in)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *client) DeleteProcess(ctx context.Context, in *shimapi.DeleteProcessRequest, opts ...grpc.CallOption) (*shimapi.DeleteResponse, error) {
|
|
||||||
return c.s.DeleteProcess(ctx, in)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *client) Exec(ctx context.Context, in *shimapi.ExecRequest, opts ...grpc.CallOption) (*shimapi.ExecResponse, error) {
|
|
||||||
return c.s.Exec(ctx, in)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *client) Pty(ctx context.Context, in *shimapi.PtyRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) {
|
|
||||||
return c.s.Pty(ctx, in)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *client) Events(ctx context.Context, in *shimapi.EventsRequest, opts ...grpc.CallOption) (shimapi.Shim_EventsClient, error) {
|
|
||||||
return &events{
|
|
||||||
c: c.s.events,
|
|
||||||
ctx: ctx,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *client) State(ctx context.Context, in *shimapi.StateRequest, opts ...grpc.CallOption) (*shimapi.StateResponse, error) {
|
type Client struct {
|
||||||
return c.s.State(ctx, in)
|
shim.ShimClient
|
||||||
|
|
||||||
|
c io.Closer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *client) Pause(ctx context.Context, in *shimapi.PauseRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) {
|
func (c *Client) IsAlive(ctx context.Context) (bool, error) {
|
||||||
return c.s.Pause(ctx, in)
|
_, err := c.ShimInfo(ctx, empty)
|
||||||
|
if err != nil {
|
||||||
|
if err != grpc.ErrServerStopped {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *client) Resume(ctx context.Context, in *shimapi.ResumeRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) {
|
// KillShim kills the shim forcefully
|
||||||
return c.s.Resume(ctx, in)
|
func (c *Client) KillShim(ctx context.Context) error {
|
||||||
|
info, err := c.ShimInfo(ctx, empty)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
pid := int(info.ShimPid)
|
||||||
func (c *client) Kill(ctx context.Context, in *shimapi.KillRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) {
|
// make sure we don't kill ourselves if we are running a local shim
|
||||||
return c.s.Kill(ctx, in)
|
if os.Getpid() == pid {
|
||||||
}
|
|
||||||
|
|
||||||
func (c *client) Processes(ctx context.Context, in *shimapi.ProcessesRequest, opts ...grpc.CallOption) (*shimapi.ProcessesResponse, error) {
|
|
||||||
return c.s.Processes(ctx, in)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *client) Exit(ctx context.Context, in *shimapi.ExitRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) {
|
|
||||||
// don't exit the calling process for the client
|
|
||||||
// but make sure we unmount the containers rootfs for this client
|
|
||||||
if err := unix.Unmount(filepath.Join(c.s.path, "rootfs"), 0); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return empty, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *client) CloseStdin(ctx context.Context, in *shimapi.CloseStdinRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) {
|
|
||||||
return c.s.CloseStdin(ctx, in)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *client) Checkpoint(ctx context.Context, in *shimapi.CheckpointRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) {
|
|
||||||
return c.s.Checkpoint(ctx, in)
|
|
||||||
}
|
|
||||||
|
|
||||||
type events struct {
|
|
||||||
c chan *task.Event
|
|
||||||
ctx context.Context
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *events) Recv() (*task.Event, error) {
|
|
||||||
ev := <-e.c
|
|
||||||
return ev, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *events) Header() (metadata.MD, error) {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *events) Trailer() metadata.MD {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
return unix.Kill(pid, unix.SIGKILL)
|
||||||
|
}
|
||||||
|
|
||||||
func (e *events) CloseSend() error {
|
func (c *Client) Close() error {
|
||||||
|
if c.c == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
return c.c.Close()
|
||||||
func (e *events) Context() context.Context {
|
|
||||||
return e.ctx
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *events) SendMsg(m interface{}) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *events) RecvMsg(m interface{}) error {
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ import (
|
|||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
"github.com/containerd/console"
|
"github.com/containerd/console"
|
||||||
shimapi "github.com/containerd/containerd/api/services/shim/v1"
|
shimapi "github.com/containerd/containerd/linux/shim/v1"
|
||||||
"github.com/containerd/fifo"
|
"github.com/containerd/fifo"
|
||||||
runc "github.com/containerd/go-runc"
|
runc "github.com/containerd/go-runc"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
@ -43,7 +43,7 @@ type execProcess struct {
|
|||||||
terminal bool
|
terminal bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func newExecProcess(context context.Context, path string, r *shimapi.ExecRequest, parent *initProcess, id int) (process, error) {
|
func newExecProcess(context context.Context, path string, r *shimapi.ExecProcessRequest, parent *initProcess, id int) (process, error) {
|
||||||
e := &execProcess{
|
e := &execProcess{
|
||||||
id: id,
|
id: id,
|
||||||
parent: parent,
|
parent: parent,
|
||||||
@ -120,17 +120,6 @@ func newExecProcess(context context.Context, path string, r *shimapi.ExecRequest
|
|||||||
return e, nil
|
return e, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func rlimits(rr []*shimapi.Rlimit) (o []specs.LinuxRlimit) {
|
|
||||||
for _, r := range rr {
|
|
||||||
o = append(o, specs.LinuxRlimit{
|
|
||||||
Type: r.Type,
|
|
||||||
Hard: r.Hard,
|
|
||||||
Soft: r.Soft,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return o
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *execProcess) Pid() int {
|
func (e *execProcess) Pid() int {
|
||||||
return e.pid
|
return e.pid
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
"github.com/containerd/console"
|
"github.com/containerd/console"
|
||||||
shimapi "github.com/containerd/containerd/api/services/shim/v1"
|
shimapi "github.com/containerd/containerd/linux/shim/v1"
|
||||||
"github.com/containerd/containerd/log"
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/mount"
|
"github.com/containerd/containerd/mount"
|
||||||
"github.com/containerd/containerd/plugin"
|
"github.com/containerd/containerd/plugin"
|
||||||
@ -52,7 +52,7 @@ type initProcess struct {
|
|||||||
terminal bool
|
terminal bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func newInitProcess(context context.Context, path, namespace string, r *shimapi.CreateRequest) (*initProcess, error) {
|
func newInitProcess(context context.Context, path, namespace string, r *shimapi.CreateTaskRequest) (*initProcess, error) {
|
||||||
for _, rm := range r.Rootfs {
|
for _, rm := range r.Rootfs {
|
||||||
m := &mount.Mount{
|
m := &mount.Mount{
|
||||||
Type: rm.Type,
|
Type: rm.Type,
|
||||||
@ -106,7 +106,8 @@ func newInitProcess(context context.Context, path, namespace string, r *shimapi.
|
|||||||
},
|
},
|
||||||
PidFile: pidFile,
|
PidFile: pidFile,
|
||||||
IO: io,
|
IO: io,
|
||||||
NoPivot: r.NoPivot,
|
// TODO: implement runtime options
|
||||||
|
//NoPivot: r.NoPivot,
|
||||||
Detach: true,
|
Detach: true,
|
||||||
NoSubreaper: true,
|
NoSubreaper: true,
|
||||||
}
|
}
|
||||||
@ -117,7 +118,7 @@ func newInitProcess(context context.Context, path, namespace string, r *shimapi.
|
|||||||
opts := &runc.CreateOpts{
|
opts := &runc.CreateOpts{
|
||||||
PidFile: pidFile,
|
PidFile: pidFile,
|
||||||
IO: io,
|
IO: io,
|
||||||
NoPivot: r.NoPivot,
|
// NoPivot: r.NoPivot,
|
||||||
}
|
}
|
||||||
if socket != nil {
|
if socket != nil {
|
||||||
opts.ConsoleSocket = socket
|
opts.ConsoleSocket = socket
|
||||||
@ -253,7 +254,7 @@ func (p *initProcess) Stdin() io.Closer {
|
|||||||
return p.stdin
|
return p.stdin
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *initProcess) Checkpoint(context context.Context, r *shimapi.CheckpointRequest) error {
|
func (p *initProcess) Checkpoint(context context.Context, r *shimapi.CheckpointTaskRequest) error {
|
||||||
var actions []runc.CheckpointAction
|
var actions []runc.CheckpointAction
|
||||||
/*
|
/*
|
||||||
if !r.Exit {
|
if !r.Exit {
|
||||||
|
126
linux/shim/local.go
Normal file
126
linux/shim/local.go
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
// +build !windows
|
||||||
|
|
||||||
|
package shim
|
||||||
|
|
||||||
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
shimapi "github.com/containerd/containerd/linux/shim/v1"
|
||||||
|
google_protobuf "github.com/golang/protobuf/ptypes/empty"
|
||||||
|
"golang.org/x/net/context"
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
"google.golang.org/grpc/metadata"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewLocal returns a shim client implementation for issue commands to a shim
|
||||||
|
func NewLocal(s *Service) shimapi.ShimClient {
|
||||||
|
return &local{
|
||||||
|
s: s,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type local struct {
|
||||||
|
s *Service
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *local) Create(ctx context.Context, in *shimapi.CreateTaskRequest, opts ...grpc.CallOption) (*shimapi.CreateTaskResponse, error) {
|
||||||
|
return c.s.Create(ctx, in)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *local) Start(ctx context.Context, in *google_protobuf.Empty, opts ...grpc.CallOption) (*google_protobuf.Empty, error) {
|
||||||
|
return c.s.Start(ctx, in)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *local) Delete(ctx context.Context, in *google_protobuf.Empty, opts ...grpc.CallOption) (*shimapi.DeleteResponse, error) {
|
||||||
|
// make sure we unmount the containers rootfs for this local
|
||||||
|
if err := unix.Unmount(filepath.Join(c.s.path, "rootfs"), 0); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return c.s.Delete(ctx, in)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *local) DeleteProcess(ctx context.Context, in *shimapi.DeleteProcessRequest, opts ...grpc.CallOption) (*shimapi.DeleteResponse, error) {
|
||||||
|
return c.s.DeleteProcess(ctx, in)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *local) Exec(ctx context.Context, in *shimapi.ExecProcessRequest, opts ...grpc.CallOption) (*shimapi.ExecProcessResponse, error) {
|
||||||
|
return c.s.Exec(ctx, in)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *local) ResizePty(ctx context.Context, in *shimapi.ResizePtyRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) {
|
||||||
|
return c.s.ResizePty(ctx, in)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *local) Stream(ctx context.Context, in *shimapi.StreamEventsRequest, opts ...grpc.CallOption) (shimapi.Shim_StreamClient, error) {
|
||||||
|
return &events{
|
||||||
|
c: c.s.events,
|
||||||
|
ctx: ctx,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *local) State(ctx context.Context, in *google_protobuf.Empty, opts ...grpc.CallOption) (*shimapi.StateResponse, error) {
|
||||||
|
return c.s.State(ctx, in)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *local) Pause(ctx context.Context, in *google_protobuf.Empty, opts ...grpc.CallOption) (*google_protobuf.Empty, error) {
|
||||||
|
return c.s.Pause(ctx, in)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *local) Resume(ctx context.Context, in *google_protobuf.Empty, opts ...grpc.CallOption) (*google_protobuf.Empty, error) {
|
||||||
|
return c.s.Resume(ctx, in)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *local) Kill(ctx context.Context, in *shimapi.KillRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) {
|
||||||
|
return c.s.Kill(ctx, in)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *local) ListProcesses(ctx context.Context, in *shimapi.ListProcessesRequest, opts ...grpc.CallOption) (*shimapi.ListProcessesResponse, error) {
|
||||||
|
return c.s.ListProcesses(ctx, in)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *local) CloseIO(ctx context.Context, in *shimapi.CloseIORequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) {
|
||||||
|
return c.s.CloseIO(ctx, in)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *local) Checkpoint(ctx context.Context, in *shimapi.CheckpointTaskRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) {
|
||||||
|
return c.s.Checkpoint(ctx, in)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *local) ShimInfo(ctx context.Context, in *google_protobuf.Empty, opts ...grpc.CallOption) (*shimapi.ShimInfoResponse, error) {
|
||||||
|
return c.s.ShimInfo(ctx, in)
|
||||||
|
}
|
||||||
|
|
||||||
|
type events struct {
|
||||||
|
c chan *shimapi.Event
|
||||||
|
ctx context.Context
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *events) Recv() (*shimapi.Event, error) {
|
||||||
|
ev := <-e.c
|
||||||
|
return ev, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *events) Header() (metadata.MD, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *events) Trailer() metadata.MD {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *events) CloseSend() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *events) Context() context.Context {
|
||||||
|
return e.ctx
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *events) SendMsg(m interface{}) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *events) RecvMsg(m interface{}) error {
|
||||||
|
return nil
|
||||||
|
}
|
@ -9,8 +9,8 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/containerd/console"
|
"github.com/containerd/console"
|
||||||
shimapi "github.com/containerd/containerd/api/services/shim/v1"
|
|
||||||
"github.com/containerd/containerd/api/types/task"
|
"github.com/containerd/containerd/api/types/task"
|
||||||
|
shimapi "github.com/containerd/containerd/linux/shim/v1"
|
||||||
"github.com/containerd/containerd/reaper"
|
"github.com/containerd/containerd/reaper"
|
||||||
google_protobuf "github.com/golang/protobuf/ptypes/empty"
|
google_protobuf "github.com/golang/protobuf/ptypes/empty"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@ -22,15 +22,15 @@ var empty = &google_protobuf.Empty{}
|
|||||||
|
|
||||||
const RuncRoot = "/run/containerd/runc"
|
const RuncRoot = "/run/containerd/runc"
|
||||||
|
|
||||||
// New returns a new shim service that can be used via GRPC
|
// NewService returns a new shim service that can be used via GRPC
|
||||||
func New(path, namespace string) (*Service, error) {
|
func NewService(path, namespace string) (*Service, error) {
|
||||||
if namespace == "" {
|
if namespace == "" {
|
||||||
return nil, fmt.Errorf("shim namespace cannot be empty")
|
return nil, fmt.Errorf("shim namespace cannot be empty")
|
||||||
}
|
}
|
||||||
return &Service{
|
return &Service{
|
||||||
path: path,
|
path: path,
|
||||||
processes: make(map[int]process),
|
processes: make(map[int]process),
|
||||||
events: make(chan *task.Event, 4096),
|
events: make(chan *shimapi.Event, 4096),
|
||||||
namespace: namespace,
|
namespace: namespace,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
@ -42,14 +42,14 @@ type Service struct {
|
|||||||
bundle string
|
bundle string
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
processes map[int]process
|
processes map[int]process
|
||||||
events chan *task.Event
|
events chan *shimapi.Event
|
||||||
eventsMu sync.Mutex
|
eventsMu sync.Mutex
|
||||||
deferredEvent *task.Event
|
deferredEvent *shimapi.Event
|
||||||
execID int
|
execID int
|
||||||
namespace string
|
namespace string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Create(ctx context.Context, r *shimapi.CreateRequest) (*shimapi.CreateResponse, error) {
|
func (s *Service) Create(ctx context.Context, r *shimapi.CreateTaskRequest) (*shimapi.CreateTaskResponse, error) {
|
||||||
process, err := newInitProcess(ctx, s.path, s.namespace, r)
|
process, err := newInitProcess(ctx, s.path, s.namespace, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -65,30 +65,30 @@ func (s *Service) Create(ctx context.Context, r *shimapi.CreateRequest) (*shimap
|
|||||||
ExitCh: make(chan int, 1),
|
ExitCh: make(chan int, 1),
|
||||||
}
|
}
|
||||||
reaper.Default.Register(pid, cmd)
|
reaper.Default.Register(pid, cmd)
|
||||||
s.events <- &task.Event{
|
s.events <- &shimapi.Event{
|
||||||
Type: task.Event_CREATE,
|
Type: shimapi.Event_CREATE,
|
||||||
ID: r.ID,
|
ID: r.ID,
|
||||||
Pid: uint32(pid),
|
Pid: uint32(pid),
|
||||||
}
|
}
|
||||||
go s.waitExit(process, pid, cmd)
|
go s.waitExit(process, pid, cmd)
|
||||||
return &shimapi.CreateResponse{
|
return &shimapi.CreateTaskResponse{
|
||||||
Pid: uint32(pid),
|
Pid: uint32(pid),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Start(ctx context.Context, r *shimapi.StartRequest) (*google_protobuf.Empty, error) {
|
func (s *Service) Start(ctx context.Context, r *google_protobuf.Empty) (*google_protobuf.Empty, error) {
|
||||||
if err := s.initProcess.Start(ctx); err != nil {
|
if err := s.initProcess.Start(ctx); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
s.events <- &task.Event{
|
s.events <- &shimapi.Event{
|
||||||
Type: task.Event_START,
|
Type: shimapi.Event_START,
|
||||||
ID: s.id,
|
ID: s.id,
|
||||||
Pid: uint32(s.initProcess.Pid()),
|
Pid: uint32(s.initProcess.Pid()),
|
||||||
}
|
}
|
||||||
return empty, nil
|
return empty, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Delete(ctx context.Context, r *shimapi.DeleteRequest) (*shimapi.DeleteResponse, error) {
|
func (s *Service) Delete(ctx context.Context, r *google_protobuf.Empty) (*shimapi.DeleteResponse, error) {
|
||||||
p := s.initProcess
|
p := s.initProcess
|
||||||
// TODO (@crosbymichael): how to handle errors here
|
// TODO (@crosbymichael): how to handle errors here
|
||||||
p.Delete(ctx)
|
p.Delete(ctx)
|
||||||
@ -124,7 +124,7 @@ func (s *Service) DeleteProcess(ctx context.Context, r *shimapi.DeleteProcessReq
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Exec(ctx context.Context, r *shimapi.ExecRequest) (*shimapi.ExecResponse, error) {
|
func (s *Service) Exec(ctx context.Context, r *shimapi.ExecProcessRequest) (*shimapi.ExecProcessResponse, error) {
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
defer s.mu.Unlock()
|
defer s.mu.Unlock()
|
||||||
s.execID++
|
s.execID++
|
||||||
@ -140,18 +140,18 @@ func (s *Service) Exec(ctx context.Context, r *shimapi.ExecRequest) (*shimapi.Ex
|
|||||||
reaper.Default.Register(pid, cmd)
|
reaper.Default.Register(pid, cmd)
|
||||||
s.processes[pid] = process
|
s.processes[pid] = process
|
||||||
|
|
||||||
s.events <- &task.Event{
|
s.events <- &shimapi.Event{
|
||||||
Type: task.Event_EXEC_ADDED,
|
Type: shimapi.Event_EXEC_ADDED,
|
||||||
ID: s.id,
|
ID: s.id,
|
||||||
Pid: uint32(pid),
|
Pid: uint32(pid),
|
||||||
}
|
}
|
||||||
go s.waitExit(process, pid, cmd)
|
go s.waitExit(process, pid, cmd)
|
||||||
return &shimapi.ExecResponse{
|
return &shimapi.ExecProcessResponse{
|
||||||
Pid: uint32(pid),
|
Pid: uint32(pid),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Pty(ctx context.Context, r *shimapi.PtyRequest) (*google_protobuf.Empty, error) {
|
func (s *Service) ResizePty(ctx context.Context, r *shimapi.ResizePtyRequest) (*google_protobuf.Empty, error) {
|
||||||
if r.Pid == 0 {
|
if r.Pid == 0 {
|
||||||
return nil, errors.Errorf("pid not provided in request")
|
return nil, errors.Errorf("pid not provided in request")
|
||||||
}
|
}
|
||||||
@ -171,7 +171,7 @@ func (s *Service) Pty(ctx context.Context, r *shimapi.PtyRequest) (*google_proto
|
|||||||
return empty, nil
|
return empty, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Events(r *shimapi.EventsRequest, stream shimapi.Shim_EventsServer) error {
|
func (s *Service) Stream(r *shimapi.StreamEventsRequest, stream shimapi.Shim_StreamServer) error {
|
||||||
s.eventsMu.Lock()
|
s.eventsMu.Lock()
|
||||||
defer s.eventsMu.Unlock()
|
defer s.eventsMu.Unlock()
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ func (s *Service) Events(r *shimapi.EventsRequest, stream shimapi.Shim_EventsSer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) State(ctx context.Context, r *shimapi.StateRequest) (*shimapi.StateResponse, error) {
|
func (s *Service) State(ctx context.Context, r *google_protobuf.Empty) (*shimapi.StateResponse, error) {
|
||||||
st, err := s.initProcess.ContainerStatus(ctx)
|
st, err := s.initProcess.ContainerStatus(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -245,28 +245,20 @@ func (s *Service) State(ctx context.Context, r *shimapi.StateRequest) (*shimapi.
|
|||||||
return o, nil
|
return o, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Pause(ctx context.Context, r *shimapi.PauseRequest) (*google_protobuf.Empty, error) {
|
func (s *Service) Pause(ctx context.Context, r *google_protobuf.Empty) (*google_protobuf.Empty, error) {
|
||||||
if err := s.initProcess.Pause(ctx); err != nil {
|
if err := s.initProcess.Pause(ctx); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return empty, nil
|
return empty, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Resume(ctx context.Context, r *shimapi.ResumeRequest) (*google_protobuf.Empty, error) {
|
func (s *Service) Resume(ctx context.Context, r *google_protobuf.Empty) (*google_protobuf.Empty, error) {
|
||||||
if err := s.initProcess.Resume(ctx); err != nil {
|
if err := s.initProcess.Resume(ctx); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return empty, nil
|
return empty, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Exit(ctx context.Context, r *shimapi.ExitRequest) (*google_protobuf.Empty, error) {
|
|
||||||
// signal ourself to exit
|
|
||||||
if err := unix.Kill(os.Getpid(), syscall.SIGTERM); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return empty, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) Kill(ctx context.Context, r *shimapi.KillRequest) (*google_protobuf.Empty, error) {
|
func (s *Service) Kill(ctx context.Context, r *shimapi.KillRequest) (*google_protobuf.Empty, error) {
|
||||||
if r.Pid == 0 {
|
if r.Pid == 0 {
|
||||||
if err := s.initProcess.Kill(ctx, r.Signal, r.All); err != nil {
|
if err := s.initProcess.Kill(ctx, r.Signal, r.All); err != nil {
|
||||||
@ -300,7 +292,7 @@ func (s *Service) Kill(ctx context.Context, r *shimapi.KillRequest) (*google_pro
|
|||||||
return empty, nil
|
return empty, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Processes(ctx context.Context, r *shimapi.ProcessesRequest) (*shimapi.ProcessesResponse, error) {
|
func (s *Service) ListProcesses(ctx context.Context, r *shimapi.ListProcessesRequest) (*shimapi.ListProcessesResponse, error) {
|
||||||
pids, err := s.getContainerPids(ctx, r.ID)
|
pids, err := s.getContainerPids(ctx, r.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -311,13 +303,13 @@ func (s *Service) Processes(ctx context.Context, r *shimapi.ProcessesRequest) (*
|
|||||||
Pid: pid,
|
Pid: pid,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
resp := &shimapi.ProcessesResponse{
|
resp := &shimapi.ListProcessesResponse{
|
||||||
Processes: ps,
|
Processes: ps,
|
||||||
}
|
}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) CloseStdin(ctx context.Context, r *shimapi.CloseStdinRequest) (*google_protobuf.Empty, error) {
|
func (s *Service) CloseIO(ctx context.Context, r *shimapi.CloseIORequest) (*google_protobuf.Empty, error) {
|
||||||
p, ok := s.processes[int(r.Pid)]
|
p, ok := s.processes[int(r.Pid)]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("process does not exist %d", r.Pid)
|
return nil, fmt.Errorf("process does not exist %d", r.Pid)
|
||||||
@ -328,20 +320,26 @@ func (s *Service) CloseStdin(ctx context.Context, r *shimapi.CloseStdinRequest)
|
|||||||
return empty, nil
|
return empty, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Checkpoint(ctx context.Context, r *shimapi.CheckpointRequest) (*google_protobuf.Empty, error) {
|
func (s *Service) Checkpoint(ctx context.Context, r *shimapi.CheckpointTaskRequest) (*google_protobuf.Empty, error) {
|
||||||
if err := s.initProcess.Checkpoint(ctx, r); err != nil {
|
if err := s.initProcess.Checkpoint(ctx, r); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return empty, nil
|
return empty, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Service) ShimInfo(ctx context.Context, r *google_protobuf.Empty) (*shimapi.ShimInfoResponse, error) {
|
||||||
|
return &shimapi.ShimInfoResponse{
|
||||||
|
ShimPid: uint32(os.Getpid()),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Service) waitExit(p process, pid int, cmd *reaper.Cmd) {
|
func (s *Service) waitExit(p process, pid int, cmd *reaper.Cmd) {
|
||||||
status := <-cmd.ExitCh
|
status := <-cmd.ExitCh
|
||||||
p.Exited(status)
|
p.Exited(status)
|
||||||
|
|
||||||
reaper.Default.Delete(pid)
|
reaper.Default.Delete(pid)
|
||||||
s.events <- &task.Event{
|
s.events <- &shimapi.Event{
|
||||||
Type: task.Event_EXIT,
|
Type: shimapi.Event_EXIT,
|
||||||
ID: s.id,
|
ID: s.id,
|
||||||
Pid: uint32(pid),
|
Pid: uint32(pid),
|
||||||
ExitStatus: uint32(status),
|
ExitStatus: uint32(status),
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -5,59 +5,67 @@ package containerd.runtime.linux.shim.v1;
|
|||||||
import "google/protobuf/any.proto";
|
import "google/protobuf/any.proto";
|
||||||
import "google/protobuf/empty.proto";
|
import "google/protobuf/empty.proto";
|
||||||
import "gogoproto/gogo.proto";
|
import "gogoproto/gogo.proto";
|
||||||
|
import "google/protobuf/timestamp.proto";
|
||||||
import "github.com/containerd/containerd/api/types/mount.proto";
|
import "github.com/containerd/containerd/api/types/mount.proto";
|
||||||
import "github.com/containerd/containerd/api/types/task/task.proto";
|
import "github.com/containerd/containerd/api/types/task/task.proto";
|
||||||
import "google/protobuf/timestamp.proto";
|
|
||||||
|
|
||||||
option go_package = "github.com/containerd/containerd/api/services/shim/v1;shim";
|
option go_package = "github.com/containerd/containerd/linux/shim/v1;shim";
|
||||||
|
|
||||||
// Shim service is launched for each container and is responsible for owning the IO
|
// Shim service is launched for each container and is responsible for owning the IO
|
||||||
// for the container and its additional processes. The shim is also the parent of
|
// for the container and its additional processes. The shim is also the parent of
|
||||||
// each container and allows reattaching to the IO and receiving the exit status
|
// each container and allows reattaching to the IO and receiving the exit status
|
||||||
// for the container processes.
|
// for the container processes.
|
||||||
service Shim {
|
service Shim {
|
||||||
rpc Create(CreateRequest) returns (CreateResponse);
|
// State returns shim and task state information.
|
||||||
rpc Start(StartRequest) returns (google.protobuf.Empty);
|
rpc State(google.protobuf.Empty) returns (StateResponse);
|
||||||
rpc Delete(DeleteRequest) returns (DeleteResponse);
|
|
||||||
rpc DeleteProcess(DeleteProcessRequest) returns (DeleteResponse);
|
rpc Create(CreateTaskRequest) returns (CreateTaskResponse);
|
||||||
rpc State(StateRequest) returns (StateResponse);
|
|
||||||
rpc Processes(ProcessesRequest) returns (ProcessesResponse);
|
rpc Start(google.protobuf.Empty) returns (google.protobuf.Empty);
|
||||||
rpc Pause(PauseRequest) returns (google.protobuf.Empty);
|
|
||||||
rpc Resume(ResumeRequest) returns (google.protobuf.Empty);
|
rpc Delete(google.protobuf.Empty) returns (DeleteResponse);
|
||||||
rpc Checkpoint(CheckpointRequest) returns (google.protobuf.Empty);
|
|
||||||
|
rpc DeleteProcess(DeleteProcessRequest) returns (DeleteResponse);
|
||||||
|
|
||||||
|
rpc ListProcesses(ListProcessesRequest) returns (ListProcessesResponse);
|
||||||
|
|
||||||
|
rpc Pause(google.protobuf.Empty) returns (google.protobuf.Empty);
|
||||||
|
|
||||||
|
rpc Resume(google.protobuf.Empty) returns (google.protobuf.Empty);
|
||||||
|
|
||||||
|
rpc Checkpoint(CheckpointTaskRequest) returns (google.protobuf.Empty);
|
||||||
|
|
||||||
|
rpc Stream(StreamEventsRequest) returns (stream Event);
|
||||||
|
|
||||||
rpc Exit(ExitRequest) returns (google.protobuf.Empty);
|
|
||||||
rpc Events(EventsRequest) returns (stream containerd.v1.types.Event);
|
|
||||||
rpc Kill(KillRequest) returns (google.protobuf.Empty);
|
rpc Kill(KillRequest) returns (google.protobuf.Empty);
|
||||||
rpc Exec(ExecRequest) returns (ExecResponse);
|
|
||||||
rpc Pty(PtyRequest) returns (google.protobuf.Empty);
|
rpc Exec(ExecProcessRequest) returns (ExecProcessResponse);
|
||||||
rpc CloseStdin(CloseStdinRequest) returns (google.protobuf.Empty);
|
|
||||||
|
rpc ResizePty(ResizePtyRequest) returns (google.protobuf.Empty);
|
||||||
|
|
||||||
|
rpc CloseIO(CloseIORequest) returns (google.protobuf.Empty);
|
||||||
|
|
||||||
|
// ShimInfo returns information about the shim.
|
||||||
|
rpc ShimInfo(google.protobuf.Empty) returns (ShimInfoResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
message CreateRequest {
|
message CreateTaskRequest {
|
||||||
string id = 1;
|
string id = 1;
|
||||||
string bundle = 2;
|
string bundle = 2;
|
||||||
string runtime = 3;
|
string runtime = 3;
|
||||||
bool no_pivot = 4;
|
repeated containerd.types.Mount rootfs = 4;
|
||||||
bool terminal = 5;
|
bool terminal = 5;
|
||||||
string stdin = 6;
|
string stdin = 6;
|
||||||
string stdout = 7;
|
string stdout = 7;
|
||||||
string stderr = 8;
|
string stderr = 8;
|
||||||
repeated containerd.types.Mount rootfs = 9;
|
string checkpoint = 9;
|
||||||
string checkpoint = 10;
|
string parent_checkpoint = 10;
|
||||||
string parent_checkpoint = 11;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message CreateResponse {
|
message CreateTaskResponse {
|
||||||
uint32 pid = 1;
|
uint32 pid = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message StartRequest {
|
|
||||||
}
|
|
||||||
|
|
||||||
message DeleteRequest {
|
|
||||||
}
|
|
||||||
|
|
||||||
message DeleteResponse {
|
message DeleteResponse {
|
||||||
uint32 pid = 1;
|
uint32 pid = 1;
|
||||||
uint32 exit_status = 2;
|
uint32 exit_status = 2;
|
||||||
@ -68,7 +76,7 @@ message DeleteProcessRequest {
|
|||||||
uint32 pid = 1;
|
uint32 pid = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ExecRequest {
|
message ExecProcessRequest {
|
||||||
bool terminal = 1;
|
bool terminal = 1;
|
||||||
string stdin = 2;
|
string stdin = 2;
|
||||||
string stdout = 3;
|
string stdout = 3;
|
||||||
@ -76,28 +84,16 @@ message ExecRequest {
|
|||||||
google.protobuf.Any spec = 5;
|
google.protobuf.Any spec = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Rlimit {
|
message ExecProcessResponse {
|
||||||
string type = 1;
|
|
||||||
uint64 hard = 2;
|
|
||||||
uint64 soft = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message ExecResponse {
|
|
||||||
uint32 pid = 1;
|
uint32 pid = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message PtyRequest {
|
message ResizePtyRequest {
|
||||||
uint32 pid = 1;
|
uint32 pid = 1;
|
||||||
uint32 width = 2;
|
uint32 width = 2;
|
||||||
uint32 height = 3;
|
uint32 height = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message EventsRequest {
|
|
||||||
}
|
|
||||||
|
|
||||||
message StateRequest {
|
|
||||||
}
|
|
||||||
|
|
||||||
message StateResponse {
|
message StateResponse {
|
||||||
string id = 1;
|
string id = 1;
|
||||||
string bundle = 2;
|
string bundle = 2;
|
||||||
@ -110,34 +106,51 @@ message StateResponse {
|
|||||||
bool terminal = 9;
|
bool terminal = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
message PauseRequest {
|
|
||||||
}
|
|
||||||
|
|
||||||
message ResumeRequest {
|
|
||||||
}
|
|
||||||
|
|
||||||
message ExitRequest {
|
|
||||||
}
|
|
||||||
|
|
||||||
message KillRequest {
|
message KillRequest {
|
||||||
uint32 signal = 1;
|
uint32 signal = 1;
|
||||||
bool all = 2;
|
bool all = 2;
|
||||||
uint32 pid = 3;
|
uint32 pid = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message CloseStdinRequest {
|
message CloseIORequest {
|
||||||
uint32 pid = 1;
|
uint32 pid = 1;
|
||||||
|
bool stdin = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ProcessesRequest {
|
message ListProcessesRequest {
|
||||||
string id = 1;
|
string id = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ProcessesResponse{
|
message ListProcessesResponse{
|
||||||
repeated containerd.v1.types.Process processes = 1;
|
repeated containerd.v1.types.Process processes = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message CheckpointRequest {
|
message CheckpointTaskRequest {
|
||||||
string path = 1;
|
string path = 1;
|
||||||
map<string, string> options = 2;
|
map<string, string> options = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message ShimInfoResponse {
|
||||||
|
uint32 shim_pid = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message StreamEventsRequest {
|
||||||
|
}
|
||||||
|
|
||||||
|
message Event {
|
||||||
|
string id = 1;
|
||||||
|
|
||||||
|
enum EventType {
|
||||||
|
EXIT = 0;
|
||||||
|
OOM = 1;
|
||||||
|
CREATE = 2;
|
||||||
|
START = 3;
|
||||||
|
EXEC_ADDED = 4;
|
||||||
|
PAUSED = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
EventType type = 2;
|
||||||
|
uint32 pid = 3;
|
||||||
|
uint32 exit_status = 4;
|
||||||
|
google.protobuf.Timestamp exited_at = 5 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
|
||||||
|
}
|
@ -7,8 +7,9 @@ import (
|
|||||||
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
|
||||||
"github.com/containerd/containerd/api/services/shim/v1"
|
|
||||||
"github.com/containerd/containerd/api/types/task"
|
"github.com/containerd/containerd/api/types/task"
|
||||||
|
client "github.com/containerd/containerd/linux/shim"
|
||||||
|
shim "github.com/containerd/containerd/linux/shim/v1"
|
||||||
"github.com/containerd/containerd/plugin"
|
"github.com/containerd/containerd/plugin"
|
||||||
protobuf "github.com/gogo/protobuf/types"
|
protobuf "github.com/gogo/protobuf/types"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
@ -18,11 +19,11 @@ import (
|
|||||||
type Task struct {
|
type Task struct {
|
||||||
containerID string
|
containerID string
|
||||||
spec []byte
|
spec []byte
|
||||||
shim shim.ShimClient
|
shim *client.Client
|
||||||
namespace string
|
namespace string
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTask(id, namespace string, spec []byte, shim shim.ShimClient) *Task {
|
func newTask(id, namespace string, spec []byte, shim *client.Client) *Task {
|
||||||
return &Task{
|
return &Task{
|
||||||
containerID: id,
|
containerID: id,
|
||||||
shim: shim,
|
shim: shim,
|
||||||
@ -42,7 +43,7 @@ func (t *Task) Info() plugin.TaskInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Task) Start(ctx context.Context) error {
|
func (t *Task) Start(ctx context.Context) error {
|
||||||
_, err := t.shim.Start(ctx, &shim.StartRequest{})
|
_, err := t.shim.Start(ctx, empty)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = errors.New(grpc.ErrorDesc(err))
|
err = errors.New(grpc.ErrorDesc(err))
|
||||||
}
|
}
|
||||||
@ -50,7 +51,7 @@ func (t *Task) Start(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Task) State(ctx context.Context) (plugin.State, error) {
|
func (t *Task) State(ctx context.Context) (plugin.State, error) {
|
||||||
response, err := t.shim.State(ctx, &shim.StateRequest{})
|
response, err := t.shim.State(ctx, empty)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return plugin.State{}, errors.New(grpc.ErrorDesc(err))
|
return plugin.State{}, errors.New(grpc.ErrorDesc(err))
|
||||||
}
|
}
|
||||||
@ -77,7 +78,7 @@ func (t *Task) State(ctx context.Context) (plugin.State, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Task) Pause(ctx context.Context) error {
|
func (t *Task) Pause(ctx context.Context) error {
|
||||||
_, err := t.shim.Pause(ctx, &shim.PauseRequest{})
|
_, err := t.shim.Pause(ctx, empty)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = errors.New(grpc.ErrorDesc(err))
|
err = errors.New(grpc.ErrorDesc(err))
|
||||||
}
|
}
|
||||||
@ -85,7 +86,7 @@ func (t *Task) Pause(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Task) Resume(ctx context.Context) error {
|
func (t *Task) Resume(ctx context.Context) error {
|
||||||
_, err := t.shim.Resume(ctx, &shim.ResumeRequest{})
|
_, err := t.shim.Resume(ctx, empty)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = errors.New(grpc.ErrorDesc(err))
|
err = errors.New(grpc.ErrorDesc(err))
|
||||||
}
|
}
|
||||||
@ -105,7 +106,7 @@ func (t *Task) Kill(ctx context.Context, signal uint32, pid uint32, all bool) er
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Task) Exec(ctx context.Context, opts plugin.ExecOpts) (plugin.Process, error) {
|
func (t *Task) Exec(ctx context.Context, opts plugin.ExecOpts) (plugin.Process, error) {
|
||||||
request := &shim.ExecRequest{
|
request := &shim.ExecProcessRequest{
|
||||||
Stdin: opts.IO.Stdin,
|
Stdin: opts.IO.Stdin,
|
||||||
Stdout: opts.IO.Stdout,
|
Stdout: opts.IO.Stdout,
|
||||||
Stderr: opts.IO.Stderr,
|
Stderr: opts.IO.Stderr,
|
||||||
@ -127,7 +128,7 @@ func (t *Task) Exec(ctx context.Context, opts plugin.ExecOpts) (plugin.Process,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Task) Processes(ctx context.Context) ([]uint32, error) {
|
func (t *Task) Processes(ctx context.Context) ([]uint32, error) {
|
||||||
resp, err := t.shim.Processes(ctx, &shim.ProcessesRequest{
|
resp, err := t.shim.ListProcesses(ctx, &shim.ListProcessesRequest{
|
||||||
ID: t.containerID,
|
ID: t.containerID,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -143,8 +144,8 @@ func (t *Task) Processes(ctx context.Context) ([]uint32, error) {
|
|||||||
return pids, nil
|
return pids, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Task) Pty(ctx context.Context, pid uint32, size plugin.ConsoleSize) error {
|
func (t *Task) ResizePty(ctx context.Context, pid uint32, size plugin.ConsoleSize) error {
|
||||||
_, err := t.shim.Pty(ctx, &shim.PtyRequest{
|
_, err := t.shim.ResizePty(ctx, &shim.ResizePtyRequest{
|
||||||
Pid: pid,
|
Pid: pid,
|
||||||
Width: size.Width,
|
Width: size.Width,
|
||||||
Height: size.Height,
|
Height: size.Height,
|
||||||
@ -155,9 +156,10 @@ func (t *Task) Pty(ctx context.Context, pid uint32, size plugin.ConsoleSize) err
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Task) CloseStdin(ctx context.Context, pid uint32) error {
|
func (t *Task) CloseIO(ctx context.Context, pid uint32) error {
|
||||||
_, err := t.shim.CloseStdin(ctx, &shim.CloseStdinRequest{
|
_, err := t.shim.CloseIO(ctx, &shim.CloseIORequest{
|
||||||
Pid: pid,
|
Pid: pid,
|
||||||
|
Stdin: true,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = errors.New(grpc.ErrorDesc(err))
|
err = errors.New(grpc.ErrorDesc(err))
|
||||||
@ -166,7 +168,7 @@ func (t *Task) CloseStdin(ctx context.Context, pid uint32) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Task) Checkpoint(ctx context.Context, path string, options map[string]string) error {
|
func (t *Task) Checkpoint(ctx context.Context, path string, options map[string]string) error {
|
||||||
r := &shim.CheckpointRequest{
|
r := &shim.CheckpointTaskRequest{
|
||||||
Path: path,
|
Path: path,
|
||||||
Options: options,
|
Options: options,
|
||||||
}
|
}
|
||||||
|
@ -28,9 +28,9 @@ type Task interface {
|
|||||||
// Processes returns all pids for the container
|
// Processes returns all pids for the container
|
||||||
Processes(context.Context) ([]uint32, error)
|
Processes(context.Context) ([]uint32, error)
|
||||||
// Pty resizes the processes pty/console
|
// Pty resizes the processes pty/console
|
||||||
Pty(context.Context, uint32, ConsoleSize) error
|
ResizePty(context.Context, uint32, ConsoleSize) error
|
||||||
// CloseStdin closes the processes stdin
|
// CloseStdin closes the processes stdin
|
||||||
CloseStdin(context.Context, uint32) error
|
CloseIO(context.Context, uint32) error
|
||||||
// Checkpoint checkpoints a container to an image with live system data
|
// Checkpoint checkpoints a container to an image with live system data
|
||||||
Checkpoint(context.Context, string, map[string]string) error
|
Checkpoint(context.Context, string, map[string]string) error
|
||||||
// DeleteProcess deletes a specific exec process via the pid
|
// DeleteProcess deletes a specific exec process via the pid
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
|
|
||||||
eventsapi "github.com/containerd/containerd/api/services/events/v1"
|
eventsapi "github.com/containerd/containerd/api/services/events/v1"
|
||||||
"github.com/containerd/containerd/api/services/tasks/v1"
|
"github.com/containerd/containerd/api/services/tasks/v1"
|
||||||
tasktypes "github.com/containerd/containerd/api/types/task"
|
|
||||||
"github.com/containerd/containerd/events"
|
"github.com/containerd/containerd/events"
|
||||||
protobuf "github.com/gogo/protobuf/types"
|
protobuf "github.com/gogo/protobuf/types"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
@ -92,7 +91,7 @@ evloop:
|
|||||||
return UnknownExitStatus, err
|
return UnknownExitStatus, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if e.Type != tasktypes.Event_EXIT {
|
if e.Type != eventsapi.RuntimeEvent_EXIT {
|
||||||
continue evloop
|
continue evloop
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,7 +392,7 @@ func (s *Service) ResizePty(ctx context.Context, r *api.ResizePtyRequest) (*goog
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err := t.Pty(ctx, r.Pid, plugin.ConsoleSize{
|
if err := t.ResizePty(ctx, r.Pid, plugin.ConsoleSize{
|
||||||
Width: r.Width,
|
Width: r.Width,
|
||||||
Height: r.Height,
|
Height: r.Height,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
@ -407,7 +407,7 @@ func (s *Service) CloseIO(ctx context.Context, r *api.CloseIORequest) (*google_p
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if r.Stdin {
|
if r.Stdin {
|
||||||
if err := t.CloseStdin(ctx, r.Pid); err != nil {
|
if err := t.CloseIO(ctx, r.Pid); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
task.go
3
task.go
@ -13,7 +13,6 @@ import (
|
|||||||
"github.com/containerd/containerd/api/services/containers/v1"
|
"github.com/containerd/containerd/api/services/containers/v1"
|
||||||
eventsapi "github.com/containerd/containerd/api/services/events/v1"
|
eventsapi "github.com/containerd/containerd/api/services/events/v1"
|
||||||
"github.com/containerd/containerd/api/services/tasks/v1"
|
"github.com/containerd/containerd/api/services/tasks/v1"
|
||||||
tasktypes "github.com/containerd/containerd/api/types/task"
|
|
||||||
"github.com/containerd/containerd/content"
|
"github.com/containerd/containerd/content"
|
||||||
"github.com/containerd/containerd/events"
|
"github.com/containerd/containerd/events"
|
||||||
"github.com/containerd/containerd/plugin"
|
"github.com/containerd/containerd/plugin"
|
||||||
@ -172,7 +171,7 @@ func (t *task) Wait(ctx context.Context) (uint32, error) {
|
|||||||
return UnknownExitStatus, err
|
return UnknownExitStatus, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if e.Type != tasktypes.Event_EXIT {
|
if e.Type != eventsapi.RuntimeEvent_EXIT {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,9 +17,7 @@ import (
|
|||||||
winsys "golang.org/x/sys/windows"
|
winsys "golang.org/x/sys/windows"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var ErrLoadedContainer = errors.New("loaded container can only be terminated")
|
||||||
ErrLoadedContainer = errors.New("loaded container can only be terminated")
|
|
||||||
)
|
|
||||||
|
|
||||||
type eventCallback func(id string, evType plugin.EventType, pid, exitStatus uint32, exitedAt time.Time)
|
type eventCallback func(id string, evType plugin.EventType, pid, exitStatus uint32, exitedAt time.Time)
|
||||||
|
|
||||||
@ -160,12 +158,12 @@ func (c *container) Exec(ctx context.Context, opts plugin.ExecOpts) (plugin.Proc
|
|||||||
return &process{p}, nil
|
return &process{p}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *container) CloseStdin(ctx context.Context, pid uint32) error {
|
func (c *container) CloseIO(ctx context.Context, pid uint32) error {
|
||||||
return c.ctr.CloseStdin(ctx, pid)
|
return c.ctr.CloseIO(ctx, pid)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *container) Pty(ctx context.Context, pid uint32, size plugin.ConsoleSize) error {
|
func (c *container) ResizePty(ctx context.Context, pid uint32, size plugin.ConsoleSize) error {
|
||||||
return c.ctr.Pty(ctx, pid, size)
|
return c.ctr.ResizePty(ctx, pid, size)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *container) Status() plugin.Status {
|
func (c *container) Status() plugin.Status {
|
||||||
|
@ -199,7 +199,7 @@ func (c *Container) Stop(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Container) CloseStdin(ctx context.Context, pid uint32) error {
|
func (c *Container) CloseIO(ctx context.Context, pid uint32) error {
|
||||||
var proc *Process
|
var proc *Process
|
||||||
c.Lock()
|
c.Lock()
|
||||||
for _, p := range c.processes {
|
for _, p := range c.processes {
|
||||||
@ -216,7 +216,7 @@ func (c *Container) CloseStdin(ctx context.Context, pid uint32) error {
|
|||||||
return proc.CloseStdin()
|
return proc.CloseStdin()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Container) Pty(ctx context.Context, pid uint32, size plugin.ConsoleSize) error {
|
func (c *Container) ResizePty(ctx context.Context, pid uint32, size plugin.ConsoleSize) error {
|
||||||
var proc *Process
|
var proc *Process
|
||||||
c.Lock()
|
c.Lock()
|
||||||
for _, p := range c.processes {
|
for _, p := range c.processes {
|
||||||
|
Loading…
Reference in New Issue
Block a user