Skip to content

Commit b564c33

Browse files
committed
[sandbox] Respect sandbox interfaces on shim side
Signed-off-by: Maksym Pavlenko <[email protected]>
1 parent 101d430 commit b564c33

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

runtime/v2/example/example.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,34 @@ func (s *service) Update(ctx context.Context, r *taskAPI.UpdateTaskRequest) (*pt
136136
func (s *service) Wait(ctx context.Context, r *taskAPI.WaitRequest) (*taskAPI.WaitResponse, error) {
137137
return nil, errdefs.ErrNotImplemented
138138
}
139+
140+
// Optional sandbox extensions this shim may support
141+
var _ taskAPI.SandboxService = (*service)(nil)
142+
143+
func (s *service) StartSandbox(ctx context.Context, req *taskAPI.StartSandboxRequest) (*taskAPI.StartSandboxResponse, error) {
144+
return nil, errdefs.ErrNotImplemented
145+
}
146+
147+
func (s *service) StopSandbox(ctx context.Context, req *taskAPI.StopSandboxRequest) (*taskAPI.StopSandboxResponse, error) {
148+
return nil, errdefs.ErrNotImplemented
149+
}
150+
151+
func (s *service) UpdateSandbox(ctx context.Context, req *taskAPI.UpdateSandboxRequest) (*taskAPI.UpdateSandboxResponse, error) {
152+
return nil, errdefs.ErrNotImplemented
153+
}
154+
155+
func (s *service) PauseSandbox(ctx context.Context, req *taskAPI.PauseSandboxRequest) (*taskAPI.PauseSandboxResponse, error) {
156+
return nil, errdefs.ErrNotImplemented
157+
}
158+
159+
func (s *service) ResumeSandbox(ctx context.Context, req *taskAPI.ResumeSandboxRequest) (*taskAPI.ResumeSandboxResponse, error) {
160+
return nil, errdefs.ErrNotImplemented
161+
}
162+
163+
func (s *service) SandboxStatus(ctx context.Context, req *taskAPI.SandboxStatusRequest) (*taskAPI.SandboxStatusResponse, error) {
164+
return nil, errdefs.ErrNotImplemented
165+
}
166+
167+
func (s *service) PingSandbox(ctx context.Context, req *taskAPI.PingRequest) (*taskAPI.PingResponse, error) {
168+
return nil, errdefs.ErrNotImplemented
169+
}

runtime/v2/shim/shim.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ type StartOpts struct {
5757
ContainerdBinary string
5858
Address string
5959
TTRPCAddress string
60+
Options io.Reader
6061
}
6162

6263
// Init func for the creation of a shim server
@@ -233,6 +234,9 @@ func run(id string, initFunc Init, config Config) error {
233234
ContainerdBinary: containerdBinaryFlag,
234235
Address: addressFlag,
235236
TTRPCAddress: ttrpcAddress,
237+
// Additional shim options may be provided via Stdin
238+
// See https://github.com/containerd/containerd/blob/c9afc4250ab183f9e944297c15df705851b3ec42/runtime/v2/shim/util.go#L116
239+
Options: os.Stdin,
236240
}
237241
address, err := service.StartShim(ctx, opts)
238242
if err != nil {
@@ -297,6 +301,11 @@ func (s *Client) Serve() error {
297301
logrus.Debug("registering ttrpc server")
298302
shimapi.RegisterTaskService(server, s.service)
299303

304+
// Register sandbox service if this shim is able to manage sandboxed environments
305+
if sb, ok := s.service.(shimapi.SandboxService); ok {
306+
shimapi.RegisterSandboxService(server, sb)
307+
}
308+
300309
if err := serve(s.context, server, socketFlag); err != nil {
301310
return err
302311
}

0 commit comments

Comments
 (0)