Skip to content

Commit de38490

Browse files
committed
sandbox: merge address and protocol to one url
Signed-off-by: Abel Feng <[email protected]>
1 parent c3b3062 commit de38490

File tree

19 files changed

+280
-332
lines changed

19 files changed

+280
-332
lines changed

api/next.pb.txt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5520,13 +5520,6 @@ file {
55205520
type: TYPE_UINT32
55215521
json_name: "version"
55225522
}
5523-
field {
5524-
name: "protocol"
5525-
number: 7
5526-
label: LABEL_OPTIONAL
5527-
type: TYPE_STRING
5528-
json_name: "protocol"
5529-
}
55305523
nested_type {
55315524
name: "LabelsEntry"
55325525
field {
@@ -5731,13 +5724,6 @@ file {
57315724
type: TYPE_UINT32
57325725
json_name: "version"
57335726
}
5734-
field {
5735-
name: "protocol"
5736-
number: 10
5737-
label: LABEL_OPTIONAL
5738-
type: TYPE_STRING
5739-
json_name: "protocol"
5740-
}
57415727
nested_type {
57425728
name: "InfoEntry"
57435729
field {

api/services/sandbox/v1/sandbox.pb.go

Lines changed: 192 additions & 205 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/services/sandbox/v1/sandbox.proto

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,11 @@ message ControllerStartResponse {
120120
uint32 pid = 2;
121121
google.protobuf.Timestamp created_at = 3;
122122
map<string, string> labels = 4;
123+
// Address of the sandbox for containerd to connect,
124+
// for calling Task or other APIs serving in the sandbox.
125+
// it is in the form of ttrpc+unix://path/to/uds or grpc+vsock://<vsock cid>:<port>.
123126
string address = 5;
124127
uint32 version = 6;
125-
string protocol = 7;
126128
}
127129

128130
message ControllerPlatformRequest {
@@ -166,9 +168,11 @@ message ControllerStatusResponse {
166168
google.protobuf.Timestamp created_at = 5;
167169
google.protobuf.Timestamp exited_at = 6;
168170
google.protobuf.Any extra = 7;
171+
// Address of the sandbox for containerd to connect,
172+
// for calling Task or other APIs serving in the sandbox.
173+
// it is in the form of ttrpc+unix://path/to/uds or grpc+vsock://<vsock cid>:<port>.
169174
string address = 8;
170175
uint32 version = 9;
171-
string protocol = 10;
172176
}
173177

174178
message ControllerShutdownRequest {

client/task_opts.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func WithRuntimePath(absRuntimePath string) NewTaskOpts {
5252

5353
// WithTaskAPIEndpoint allow task service to manage a task through a given endpoint,
5454
// usually it is served inside a sandbox, and we can get it from sandbox status.
55-
func WithTaskAPIEndpoint(address, protocol string, version uint32) NewTaskOpts {
55+
func WithTaskAPIEndpoint(address string, version uint32) NewTaskOpts {
5656
return func(ctx context.Context, client *Client, info *TaskInfo) error {
5757
if info.Options == nil {
5858
info.Options = &options.Options{}
@@ -62,7 +62,6 @@ func WithTaskAPIEndpoint(address, protocol string, version uint32) NewTaskOpts {
6262
return errors.New("invalid runtime v2 options format")
6363
}
6464
opts.TaskApiAddress = address
65-
opts.TaskApiProtocol = protocol
6665
opts.TaskApiVersion = version
6766
return nil
6867
}

core/runtime/runtime.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ type CreateOpts struct {
5353
SandboxID string
5454
// Address is an optional Address for Task API server
5555
Address string
56-
// Protocol is an optional Protocol for Task API connection
57-
Protocol string
5856
// Version is an optional Version of the Task API
5957
Version uint32
6058
}

core/runtime/v2/binary.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,12 @@ func (b *binary) Start(ctx context.Context, opts *types.Any, onClose func()) (_
143143
if err := writeBootstrapParams(filepath.Join(b.bundle.Path, "bootstrap.json"), params); err != nil {
144144
return nil, fmt.Errorf("failed to write bootstrap.json: %w", err)
145145
}
146-
146+
// The address is in the form like ttrpc+unix://<uds-path> or grpc+vsock://<cid>:<port>
147+
address := fmt.Sprintf("%s+%s", params.Protocol, params.Address)
147148
return &shim{
148149
bundle: b.bundle,
149150
client: conn,
151+
address: address,
150152
version: params.Version,
151153
}, nil
152154
}

core/runtime/v2/runc/options/next.pb.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,9 @@ file {
8080
type: TYPE_STRING
8181
json_name: "taskApiAddress"
8282
}
83-
field {
84-
name: "task_api_protocol"
85-
number: 13
86-
label: LABEL_OPTIONAL
87-
type: TYPE_STRING
88-
json_name: "taskApiProtocol"
89-
}
9083
field {
9184
name: "task_api_version"
92-
number: 14
85+
number: 13
9386
label: LABEL_OPTIONAL
9487
type: TYPE_UINT32
9588
json_name: "taskApiVersion"

core/runtime/v2/runc/options/oci.pb.go

Lines changed: 35 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/runtime/v2/runc/options/oci.proto

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ message Options {
3030
// criu work path
3131
string criu_work_path = 11;
3232
// task api address, can be a unix domain socket, or vsock address.
33+
// it is in the form of ttrpc+unix://path/to/uds or grpc+vsock://<vsock cid>:<port>.
3334
string task_api_address = 12;
34-
// protocol for task api connection, currently ttrpc and grpc supported
35-
string task_api_protocol = 13;
3635
// task api version, currently supported value is 2 and 3.
37-
uint32 task_api_version = 14;
36+
uint32 task_api_version = 13;
3837
}
3938

4039
message CheckpointOptions {

core/runtime/v2/shim.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,13 @@ func loadShim(ctx context.Context, bundle *Bundle, onClose func()) (_ ShimInstan
113113
}
114114
}()
115115

116+
// The address is in the form like ttrpc+unix://<uds-path> or grpc+vsock://<cid>:<port>
117+
address := fmt.Sprintf("%s+%s", params.Protocol, params.Address)
118+
116119
shim := &shim{
117120
bundle: bundle,
118121
client: conn,
122+
address: address,
119123
version: params.Version,
120124
}
121125

@@ -186,8 +190,8 @@ type ShimInstance interface {
186190
// Delete will close the client and remove bundle from disk.
187191
Delete(ctx context.Context) error
188192
// Endpoint returns shim's endpoint information,
189-
// including address, protocol and version.
190-
Endpoint() (string, string, int)
193+
// including address and version.
194+
Endpoint() (string, int)
191195
}
192196

193197
func parseStartResponse(response []byte) (client.BootstrapParams, error) {
@@ -360,11 +364,10 @@ func (gc *grpcConn) UserOnCloseWait(ctx context.Context) error {
360364
}
361365

362366
type shim struct {
363-
bundle *Bundle
364-
client any
365-
address string
366-
protocol string
367-
version int
367+
bundle *Bundle
368+
client any
369+
address string
370+
version int
368371
}
369372

370373
var _ ShimInstance = (*shim)(nil)
@@ -374,8 +377,8 @@ func (s *shim) ID() string {
374377
return s.bundle.ID
375378
}
376379

377-
func (s *shim) Endpoint() (string, string, int) {
378-
return s.address, s.protocol, s.version
380+
func (s *shim) Endpoint() (string, int) {
381+
return s.address, s.version
379382
}
380383

381384
func (s *shim) Namespace() string {
@@ -443,7 +446,7 @@ type shimTask struct {
443446
}
444447

445448
func newShimTask(shim ShimInstance) (*shimTask, error) {
446-
_, _, version := shim.Endpoint()
449+
_, version := shim.Endpoint()
447450
taskClient, err := NewTaskClient(shim.Client(), version)
448451
if err != nil {
449452
return nil, err

0 commit comments

Comments
 (0)