linux: Honor RuncOptions if set on container

This also fix the type used for RuncOptions.SystemCgroup, hence introducing
an API break.

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
Kenfe-Mickael Laventure
2017-08-30 15:20:57 -07:00
parent e0d8cb1366
commit ab0cb4e756
12 changed files with 378 additions and 222 deletions

View File

@@ -37,8 +37,9 @@ var _ = math.Inf
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type RuncOptions struct {
CriuPath string `protobuf:"bytes,1,opt,name=criu_path,json=criuPath,proto3" json:"criu_path,omitempty"`
SystemdCgroup string `protobuf:"bytes,2,opt,name=systemd_cgroup,json=systemdCgroup,proto3" json:"systemd_cgroup,omitempty"`
Runtime string `protobuf:"bytes,1,opt,name=runtime,proto3" json:"runtime,omitempty"`
CriuPath string `protobuf:"bytes,2,opt,name=criu_path,json=criuPath,proto3" json:"criu_path,omitempty"`
SystemdCgroup bool `protobuf:"varint,3,opt,name=systemd_cgroup,json=systemdCgroup,proto3" json:"systemd_cgroup,omitempty"`
}
func (m *RuncOptions) Reset() { *m = RuncOptions{} }
@@ -95,17 +96,27 @@ func (m *RuncOptions) MarshalTo(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if len(m.CriuPath) > 0 {
if len(m.Runtime) > 0 {
dAtA[i] = 0xa
i++
i = encodeVarintRunc(dAtA, i, uint64(len(m.Runtime)))
i += copy(dAtA[i:], m.Runtime)
}
if len(m.CriuPath) > 0 {
dAtA[i] = 0x12
i++
i = encodeVarintRunc(dAtA, i, uint64(len(m.CriuPath)))
i += copy(dAtA[i:], m.CriuPath)
}
if len(m.SystemdCgroup) > 0 {
dAtA[i] = 0x12
if m.SystemdCgroup {
dAtA[i] = 0x18
i++
if m.SystemdCgroup {
dAtA[i] = 1
} else {
dAtA[i] = 0
}
i++
i = encodeVarintRunc(dAtA, i, uint64(len(m.SystemdCgroup)))
i += copy(dAtA[i:], m.SystemdCgroup)
}
return i, nil
}
@@ -334,13 +345,16 @@ func encodeVarintRunc(dAtA []byte, offset int, v uint64) int {
func (m *RuncOptions) Size() (n int) {
var l int
_ = l
l = len(m.Runtime)
if l > 0 {
n += 1 + l + sovRunc(uint64(l))
}
l = len(m.CriuPath)
if l > 0 {
n += 1 + l + sovRunc(uint64(l))
}
l = len(m.SystemdCgroup)
if l > 0 {
n += 1 + l + sovRunc(uint64(l))
if m.SystemdCgroup {
n += 2
}
return n
}
@@ -432,6 +446,7 @@ func (this *RuncOptions) String() string {
return "nil"
}
s := strings.Join([]string{`&RuncOptions{`,
`Runtime:` + fmt.Sprintf("%v", this.Runtime) + `,`,
`CriuPath:` + fmt.Sprintf("%v", this.CriuPath) + `,`,
`SystemdCgroup:` + fmt.Sprintf("%v", this.SystemdCgroup) + `,`,
`}`,
@@ -510,6 +525,35 @@ func (m *RuncOptions) Unmarshal(dAtA []byte) error {
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Runtime", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowRunc
}
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 ErrInvalidLengthRunc
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Runtime = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field CriuPath", wireType)
}
@@ -538,11 +582,11 @@ func (m *RuncOptions) Unmarshal(dAtA []byte) error {
}
m.CriuPath = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 2:
if wireType != 2 {
case 3:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field SystemdCgroup", wireType)
}
var stringLen uint64
var v int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowRunc
@@ -552,21 +596,12 @@ func (m *RuncOptions) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
v |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthRunc
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.SystemdCgroup = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
m.SystemdCgroup = bool(v != 0)
default:
iNdEx = preIndex
skippy, err := skipRunc(dAtA[iNdEx:])
@@ -1163,33 +1198,34 @@ func init() {
}
var fileDescriptorRunc = []byte{
// 438 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x93, 0xb1, 0x6f, 0xd4, 0x30,
0x18, 0xc5, 0x9b, 0xb6, 0xb4, 0x89, 0xaf, 0x57, 0xc0, 0x50, 0x29, 0x14, 0x11, 0xca, 0x09, 0xa4,
0xb2, 0xdc, 0x49, 0xb0, 0x20, 0xd8, 0xb8, 0x11, 0x28, 0x25, 0xc0, 0xc2, 0x62, 0xa5, 0xbe, 0x8f,
0xc4, 0xba, 0xe4, 0xfb, 0x2c, 0xdb, 0xa1, 0xb9, 0x8d, 0x3f, 0xaf, 0x23, 0x62, 0x62, 0xa4, 0xf9,
0x47, 0x40, 0x71, 0x2e, 0x85, 0x95, 0x95, 0xed, 0xf9, 0xf7, 0x9e, 0x9e, 0xa5, 0x27, 0x7d, 0xec,
0x79, 0xae, 0x5c, 0x51, 0x9f, 0x4d, 0x25, 0x55, 0x33, 0x49, 0xe8, 0x32, 0x85, 0x60, 0x16, 0x7f,
0xcb, 0x52, 0x61, 0xdd, 0xcc, 0x4c, 0x8d, 0x92, 0xb4, 0xb3, 0x5e, 0x4c, 0xb5, 0x21, 0x47, 0xfc,
0xe0, 0x4f, 0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x82, 0x8d, 0x77, 0x8e, 0xb6, 0x8e,
0xa3, 0xf4, 0xba, 0xe7, 0x27, 0x57, 0x98, 0x3f, 0x60, 0x7b, 0xfd, 0x12, 0x56, 0x54, 0xb4, 0x80,
0x78, 0xd7, 0xef, 0x31, 0x5a, 0xb3, 0x37, 0xb4, 0x00, 0xfe, 0x90, 0xed, 0x23, 0x09, 0x84, 0x73,
0xb1, 0x84, 0x95, 0x51, 0x98, 0xc7, 0xa1, 0xff, 0x70, 0x0f, 0xe9, 0x04, 0xce, 0x5f, 0xf5, 0x8c,
0xdf, 0x67, 0x23, 0x5b, 0xa8, 0x6a, 0xd8, 0x35, 0xf2, 0x3d, 0xac, 0x43, 0xeb, 0x51, 0x7f, 0x05,
0xec, 0xe6, 0xbc, 0x00, 0xb9, 0xd4, 0xa4, 0xd0, 0x0d, 0xc3, 0x72, 0xb6, 0x0d, 0x8d, 0x1a, 0xf6,
0xf4, 0xfa, 0x7f, 0x1d, 0xf2, 0x65, 0x7a, 0x71, 0x99, 0x6c, 0xfc, 0xb8, 0x4c, 0x36, 0xbe, 0xb6,
0x49, 0x70, 0xd1, 0x26, 0xc1, 0xb7, 0x36, 0x09, 0x7e, 0xb6, 0x49, 0xf0, 0xe9, 0xd9, 0x3f, 0x1e,
0xcb, 0x8b, 0x41, 0x9c, 0xed, 0xf8, 0x23, 0x78, 0xfa, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x00, 0x19,
0xba, 0x8f, 0x6f, 0x03, 0x00, 0x00,
// 453 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x93, 0x41, 0x6f, 0xd3, 0x4e,
0x14, 0xc4, 0xeb, 0xb6, 0xff, 0xc6, 0xde, 0x34, 0xfd, 0xc3, 0x42, 0x25, 0x53, 0x84, 0x09, 0x11,
0x48, 0xe1, 0x92, 0x48, 0x70, 0x41, 0x70, 0x23, 0x47, 0xa0, 0x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