sandbox: merge address and protocol to one url
Signed-off-by: Abel Feng <fshb1988@gmail.com>
This commit is contained in:
@@ -53,8 +53,6 @@ type CreateOpts struct {
|
||||
SandboxID string
|
||||
// Address is an optional Address for Task API server
|
||||
Address string
|
||||
// Protocol is an optional Protocol for Task API connection
|
||||
Protocol string
|
||||
// Version is an optional Version of the Task API
|
||||
Version uint32
|
||||
}
|
||||
|
||||
@@ -143,10 +143,12 @@ func (b *binary) Start(ctx context.Context, opts *types.Any, onClose func()) (_
|
||||
if err := writeBootstrapParams(filepath.Join(b.bundle.Path, "bootstrap.json"), params); err != nil {
|
||||
return nil, fmt.Errorf("failed to write bootstrap.json: %w", err)
|
||||
}
|
||||
|
||||
// The address is in the form like ttrpc+unix://<uds-path> or grpc+vsock://<cid>:<port>
|
||||
address := fmt.Sprintf("%s+%s", params.Protocol, params.Address)
|
||||
return &shim{
|
||||
bundle: b.bundle,
|
||||
client: conn,
|
||||
address: address,
|
||||
version: params.Version,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -80,16 +80,9 @@ file {
|
||||
type: TYPE_STRING
|
||||
json_name: "taskApiAddress"
|
||||
}
|
||||
field {
|
||||
name: "task_api_protocol"
|
||||
number: 13
|
||||
label: LABEL_OPTIONAL
|
||||
type: TYPE_STRING
|
||||
json_name: "taskApiProtocol"
|
||||
}
|
||||
field {
|
||||
name: "task_api_version"
|
||||
number: 14
|
||||
number: 13
|
||||
label: LABEL_OPTIONAL
|
||||
type: TYPE_UINT32
|
||||
json_name: "taskApiVersion"
|
||||
|
||||
@@ -46,11 +46,10 @@ type Options struct {
|
||||
// criu work path
|
||||
CriuWorkPath string `protobuf:"bytes,11,opt,name=criu_work_path,json=criuWorkPath,proto3" json:"criu_work_path,omitempty"`
|
||||
// task api address, can be a unix domain socket, or vsock address.
|
||||
// it is in the form of ttrpc+unix://path/to/uds or grpc+vsock://<vsock cid>:<port>.
|
||||
TaskApiAddress string `protobuf:"bytes,12,opt,name=task_api_address,json=taskApiAddress,proto3" json:"task_api_address,omitempty"`
|
||||
// protocol for task api connection, currently ttrpc and grpc supported
|
||||
TaskApiProtocol string `protobuf:"bytes,13,opt,name=task_api_protocol,json=taskApiProtocol,proto3" json:"task_api_protocol,omitempty"`
|
||||
// task api version, currently supported value is 2 and 3.
|
||||
TaskApiVersion uint32 `protobuf:"varint,14,opt,name=task_api_version,json=taskApiVersion,proto3" json:"task_api_version,omitempty"`
|
||||
TaskApiVersion uint32 `protobuf:"varint,13,opt,name=task_api_version,json=taskApiVersion,proto3" json:"task_api_version,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Options) Reset() {
|
||||
@@ -162,13 +161,6 @@ func (x *Options) GetTaskApiAddress() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Options) GetTaskApiProtocol() string {
|
||||
if x != nil {
|
||||
return x.TaskApiProtocol
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Options) GetTaskApiVersion() uint32 {
|
||||
if x != nil {
|
||||
return x.TaskApiVersion
|
||||
@@ -352,7 +344,7 @@ var file_github_com_containerd_containerd_core_runtime_v2_runc_options_oci_proto
|
||||
0x72, 0x64, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2f,
|
||||
0x76, 0x32, 0x2f, 0x72, 0x75, 0x6e, 0x63, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f,
|
||||
0x6f, 0x63, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x12, 0x63, 0x6f, 0x6e, 0x74, 0x61,
|
||||
0x69, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x72, 0x75, 0x6e, 0x63, 0x2e, 0x76, 0x31, 0x22, 0xd2, 0x03,
|
||||
0x69, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x72, 0x75, 0x6e, 0x63, 0x2e, 0x76, 0x31, 0x22, 0xa6, 0x03,
|
||||
0x0a, 0x07, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x22, 0x0a, 0x0d, 0x6e, 0x6f, 0x5f,
|
||||
0x70, 0x69, 0x76, 0x6f, 0x74, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08,
|
||||
0x52, 0x0b, 0x6e, 0x6f, 0x50, 0x69, 0x76, 0x6f, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x24, 0x0a,
|
||||
@@ -376,40 +368,38 @@ var file_github_com_containerd_containerd_core_runtime_v2_runc_options_oci_proto
|
||||
0x63, 0x72, 0x69, 0x75, 0x57, 0x6f, 0x72, 0x6b, 0x50, 0x61, 0x74, 0x68, 0x12, 0x28, 0x0a, 0x10,
|
||||
0x74, 0x61, 0x73, 0x6b, 0x5f, 0x61, 0x70, 0x69, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73,
|
||||
0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x74, 0x61, 0x73, 0x6b, 0x41, 0x70, 0x69, 0x41,
|
||||
0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x2a, 0x0a, 0x11, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x61,
|
||||
0x70, 0x69, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x0d, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x0f, 0x74, 0x61, 0x73, 0x6b, 0x41, 0x70, 0x69, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63,
|
||||
0x6f, 0x6c, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x61, 0x70, 0x69, 0x5f, 0x76,
|
||||
0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0e, 0x74, 0x61,
|
||||
0x73, 0x6b, 0x41, 0x70, 0x69, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x4a, 0x04, 0x08, 0x08,
|
||||
0x10, 0x09, 0x22, 0xbb, 0x02, 0x0a, 0x11, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e,
|
||||
0x74, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x65, 0x78, 0x69, 0x74,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x65, 0x78, 0x69, 0x74, 0x12, 0x19, 0x0a, 0x08,
|
||||
0x6f, 0x70, 0x65, 0x6e, 0x5f, 0x74, 0x63, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07,
|
||||
0x6f, 0x70, 0x65, 0x6e, 0x54, 0x63, 0x70, 0x12, 0x32, 0x0a, 0x15, 0x65, 0x78, 0x74, 0x65, 0x72,
|
||||
0x6e, 0x61, 0x6c, 0x5f, 0x75, 0x6e, 0x69, 0x78, 0x5f, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x73,
|
||||
0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c,
|
||||
0x55, 0x6e, 0x69, 0x78, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x74,
|
||||
0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x74,
|
||||
0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x6c, 0x12, 0x1d, 0x0a, 0x0a, 0x66, 0x69, 0x6c, 0x65, 0x5f,
|
||||
0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x66, 0x69, 0x6c,
|
||||
0x65, 0x4c, 0x6f, 0x63, 0x6b, 0x73, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x5f,
|
||||
0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09,
|
||||
0x52, 0x0f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65,
|
||||
0x73, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x5f, 0x6d, 0x6f, 0x64,
|
||||
0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73,
|
||||
0x4d, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x5f, 0x70, 0x61,
|
||||
0x74, 0x68, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x50,
|
||||
0x61, 0x74, 0x68, 0x12, 0x1b, 0x0a, 0x09, 0x77, 0x6f, 0x72, 0x6b, 0x5f, 0x70, 0x61, 0x74, 0x68,
|
||||
0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x77, 0x6f, 0x72, 0x6b, 0x50, 0x61, 0x74, 0x68,
|
||||
0x22, 0x29, 0x0a, 0x0e, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69,
|
||||
0x6c, 0x73, 0x12, 0x17, 0x0a, 0x07, 0x65, 0x78, 0x65, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x06, 0x65, 0x78, 0x65, 0x63, 0x49, 0x64, 0x42, 0x4a, 0x5a, 0x48, 0x67,
|
||||
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69,
|
||||
0x6e, 0x65, 0x72, 0x64, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x64, 0x2f,
|
||||
0x76, 0x32, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2f,
|
||||
0x76, 0x32, 0x2f, 0x72, 0x75, 0x6e, 0x63, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3b,
|
||||
0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x61,
|
||||
0x70, 0x69, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0d,
|
||||
0x52, 0x0e, 0x74, 0x61, 0x73, 0x6b, 0x41, 0x70, 0x69, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
|
||||
0x4a, 0x04, 0x08, 0x08, 0x10, 0x09, 0x22, 0xbb, 0x02, 0x0a, 0x11, 0x43, 0x68, 0x65, 0x63, 0x6b,
|
||||
0x70, 0x6f, 0x69, 0x6e, 0x74, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x04,
|
||||
0x65, 0x78, 0x69, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x65, 0x78, 0x69, 0x74,
|
||||
0x12, 0x19, 0x0a, 0x08, 0x6f, 0x70, 0x65, 0x6e, 0x5f, 0x74, 0x63, 0x70, 0x18, 0x02, 0x20, 0x01,
|
||||
0x28, 0x08, 0x52, 0x07, 0x6f, 0x70, 0x65, 0x6e, 0x54, 0x63, 0x70, 0x12, 0x32, 0x0a, 0x15, 0x65,
|
||||
0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x75, 0x6e, 0x69, 0x78, 0x5f, 0x73, 0x6f, 0x63,
|
||||
0x6b, 0x65, 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x65, 0x78, 0x74, 0x65,
|
||||
0x72, 0x6e, 0x61, 0x6c, 0x55, 0x6e, 0x69, 0x78, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x12,
|
||||
0x1a, 0x0a, 0x08, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28,
|
||||
0x08, 0x52, 0x08, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x6c, 0x12, 0x1d, 0x0a, 0x0a, 0x66,
|
||||
0x69, 0x6c, 0x65, 0x5f, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52,
|
||||
0x09, 0x66, 0x69, 0x6c, 0x65, 0x4c, 0x6f, 0x63, 0x6b, 0x73, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6d,
|
||||
0x70, 0x74, 0x79, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x18, 0x06,
|
||||
0x20, 0x03, 0x28, 0x09, 0x52, 0x0f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x73,
|
||||
0x70, 0x61, 0x63, 0x65, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73,
|
||||
0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x67, 0x72,
|
||||
0x6f, 0x75, 0x70, 0x73, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x6d, 0x61, 0x67,
|
||||
0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x69, 0x6d,
|
||||
0x61, 0x67, 0x65, 0x50, 0x61, 0x74, 0x68, 0x12, 0x1b, 0x0a, 0x09, 0x77, 0x6f, 0x72, 0x6b, 0x5f,
|
||||
0x70, 0x61, 0x74, 0x68, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x77, 0x6f, 0x72, 0x6b,
|
||||
0x50, 0x61, 0x74, 0x68, 0x22, 0x29, 0x0a, 0x0e, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x44,
|
||||
0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x12, 0x17, 0x0a, 0x07, 0x65, 0x78, 0x65, 0x63, 0x5f, 0x69,
|
||||
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x65, 0x78, 0x65, 0x63, 0x49, 0x64, 0x42,
|
||||
0x4a, 0x5a, 0x48, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f,
|
||||
0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x64, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e,
|
||||
0x65, 0x72, 0x64, 0x2f, 0x76, 0x32, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x72, 0x75, 0x6e, 0x74,
|
||||
0x69, 0x6d, 0x65, 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x75, 0x6e, 0x63, 0x2f, 0x6f, 0x70, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x73, 0x3b, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -30,11 +30,10 @@ message Options {
|
||||
// criu work path
|
||||
string criu_work_path = 11;
|
||||
// task api address, can be a unix domain socket, or vsock address.
|
||||
// it is in the form of ttrpc+unix://path/to/uds or grpc+vsock://<vsock cid>:<port>.
|
||||
string task_api_address = 12;
|
||||
// protocol for task api connection, currently ttrpc and grpc supported
|
||||
string task_api_protocol = 13;
|
||||
// task api version, currently supported value is 2 and 3.
|
||||
uint32 task_api_version = 14;
|
||||
uint32 task_api_version = 13;
|
||||
}
|
||||
|
||||
message CheckpointOptions {
|
||||
|
||||
@@ -113,9 +113,13 @@ func loadShim(ctx context.Context, bundle *Bundle, onClose func()) (_ ShimInstan
|
||||
}
|
||||
}()
|
||||
|
||||
// The address is in the form like ttrpc+unix://<uds-path> or grpc+vsock://<cid>:<port>
|
||||
address := fmt.Sprintf("%s+%s", params.Protocol, params.Address)
|
||||
|
||||
shim := &shim{
|
||||
bundle: bundle,
|
||||
client: conn,
|
||||
address: address,
|
||||
version: params.Version,
|
||||
}
|
||||
|
||||
@@ -186,8 +190,8 @@ type ShimInstance interface {
|
||||
// Delete will close the client and remove bundle from disk.
|
||||
Delete(ctx context.Context) error
|
||||
// Endpoint returns shim's endpoint information,
|
||||
// including address, protocol and version.
|
||||
Endpoint() (string, string, int)
|
||||
// including address and version.
|
||||
Endpoint() (string, int)
|
||||
}
|
||||
|
||||
func parseStartResponse(response []byte) (client.BootstrapParams, error) {
|
||||
@@ -360,11 +364,10 @@ func (gc *grpcConn) UserOnCloseWait(ctx context.Context) error {
|
||||
}
|
||||
|
||||
type shim struct {
|
||||
bundle *Bundle
|
||||
client any
|
||||
address string
|
||||
protocol string
|
||||
version int
|
||||
bundle *Bundle
|
||||
client any
|
||||
address string
|
||||
version int
|
||||
}
|
||||
|
||||
var _ ShimInstance = (*shim)(nil)
|
||||
@@ -374,8 +377,8 @@ func (s *shim) ID() string {
|
||||
return s.bundle.ID
|
||||
}
|
||||
|
||||
func (s *shim) Endpoint() (string, string, int) {
|
||||
return s.address, s.protocol, s.version
|
||||
func (s *shim) Endpoint() (string, int) {
|
||||
return s.address, s.version
|
||||
}
|
||||
|
||||
func (s *shim) Namespace() string {
|
||||
@@ -443,7 +446,7 @@ type shimTask struct {
|
||||
}
|
||||
|
||||
func newShimTask(shim ShimInstance) (*shimTask, error) {
|
||||
_, _, version := shim.Endpoint()
|
||||
_, version := shim.Endpoint()
|
||||
taskClient, err := NewTaskClient(shim.Client(), version)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -164,16 +164,27 @@ func (m *ShimManager) Start(ctx context.Context, id string, bundle *Bundle, opts
|
||||
// This container belongs to sandbox which supposed to be already started via sandbox API.
|
||||
if opts.SandboxID != "" {
|
||||
var params shimbinary.BootstrapParams
|
||||
if opts.Address != "" && opts.Protocol != "" {
|
||||
if opts.Address != "" {
|
||||
// The address returned from sandbox controller should be in the form like ttrpc+unix://<uds-path>
|
||||
// or grpc+vsock://<cid>:<port>, we should get the protocol from the url first.
|
||||
protocol, address, ok := strings.Cut(opts.Address, "+")
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("the scheme of sandbox address should be in " +
|
||||
" the form of <protocol>+<unix|vsock|tcp>, i.e. ttrpc+unix or grpc+vsock")
|
||||
}
|
||||
params = shimbinary.BootstrapParams{
|
||||
Version: int(opts.Version),
|
||||
Address: opts.Address,
|
||||
Protocol: opts.Protocol,
|
||||
Protocol: protocol,
|
||||
Address: address,
|
||||
}
|
||||
} else {
|
||||
// For those sandbox we can not get endpoint,
|
||||
// fallback to legacy implementation
|
||||
p, restoreErr := m.restoreBootstrapParams(ctx, opts.SandboxID)
|
||||
process, err := m.Get(ctx, opts.SandboxID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("can't find sandbox %s", opts.SandboxID)
|
||||
}
|
||||
p, restoreErr := restoreBootstrapParams(process.Bundle())
|
||||
if restoreErr != nil {
|
||||
return nil, fmt.Errorf("failed to get bootstrap "+
|
||||
"params of sandbox %s, %v, legacy restore error %v", opts.SandboxID, err, restoreErr)
|
||||
@@ -259,18 +270,6 @@ func (m *ShimManager) startShim(ctx context.Context, bundle *Bundle, id string,
|
||||
return shim, nil
|
||||
}
|
||||
|
||||
func (m *ShimManager) restoreBootstrapParams(ctx context.Context, sandboxID string) (shimbinary.BootstrapParams, error) {
|
||||
process, err := m.Get(ctx, sandboxID)
|
||||
if err != nil {
|
||||
return shimbinary.BootstrapParams{}, fmt.Errorf("can't find sandbox %s", sandboxID)
|
||||
}
|
||||
params, err := restoreBootstrapParams(filepath.Join(m.state, process.Namespace(), sandboxID))
|
||||
if err != nil {
|
||||
return shimbinary.BootstrapParams{}, err
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// restoreBootstrapParams reads bootstrap.json to restore shim configuration.
|
||||
// If its an old shim, this will perform migration - read address file and write default bootstrap
|
||||
// configuration (version = 2, protocol = ttrpc, and address).
|
||||
|
||||
@@ -118,7 +118,6 @@ type ControllerInstance struct {
|
||||
Pid uint32
|
||||
CreatedAt time.Time
|
||||
Address string
|
||||
Protocol string
|
||||
Version uint32
|
||||
Labels map[string]string
|
||||
}
|
||||
@@ -137,6 +136,5 @@ type ControllerStatus struct {
|
||||
ExitedAt time.Time
|
||||
Extra typeurl.Any
|
||||
Address string
|
||||
Protocol string
|
||||
Version uint32
|
||||
}
|
||||
|
||||
@@ -74,7 +74,6 @@ func (s *remoteSandboxController) Start(ctx context.Context, sandboxID string) (
|
||||
CreatedAt: resp.GetCreatedAt().AsTime(),
|
||||
Labels: resp.GetLabels(),
|
||||
Address: resp.GetAddress(),
|
||||
Protocol: resp.GetProtocol(),
|
||||
Version: resp.GetVersion(),
|
||||
}, nil
|
||||
}
|
||||
@@ -145,7 +144,6 @@ func (s *remoteSandboxController) Status(ctx context.Context, sandboxID string,
|
||||
ExitedAt: resp.GetExitedAt().AsTime(),
|
||||
Extra: resp.GetExtra(),
|
||||
Address: resp.GetAddress(),
|
||||
Protocol: resp.GetProtocol(),
|
||||
Version: resp.GetVersion(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user