X Tutup
Skip to content

Commit fe38efd

Browse files
committed
Add shim for reattach of processes
Signed-off-by: Michael Crosby <crosbymichael@gmail.com> Remove runtime files from containerd Signed-off-by: Michael Crosby <crosbymichael@gmail.com> Update supervisor for orphaned containers Signed-off-by: Michael Crosby <crosbymichael@gmail.com> Remove ctr/container.go back to rpc calls Signed-off-by: Michael Crosby <crosbymichael@gmail.com> Add attach to loaded container Signed-off-by: Michael Crosby <crosbymichael@gmail.com> Add monitor based on epoll for process exits Signed-off-by: Michael Crosby <crosbymichael@gmail.com> Convert pids in containerd to string This is so that we no longer care about linux or system level pids and processes in containerd have user defined process id(pid) kinda like the exec process ids that docker has today. Signed-off-by: Michael Crosby <crosbymichael@gmail.com> Add reaper back to containerd Signed-off-by: Michael Crosby <crosbymichael@gmail.com> Implement list containers with new process model Signed-off-by: Michael Crosby <crosbymichael@gmail.com> Implement restore of processes Signed-off-by: Michael Crosby <crosbymichael@gmail.com> Add NONBLOCK to exit fifo open Signed-off-by: Michael Crosby <crosbymichael@gmail.com> Implement tty reattach Signed-off-by: Michael Crosby <crosbymichael@gmail.com> Fix race in exit pipe creation Signed-off-by: Michael Crosby <crosbymichael@gmail.com> Add delete to shim Signed-off-by: Michael Crosby <crosbymichael@gmail.com> Update shim to use pid-file and not stdout Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
1 parent 8d1f71c commit fe38efd

33 files changed

+1205
-1831
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
containerd/containerd
2+
containerd-shim/containerd-shim
23
bin/
34
ctr/ctr
45
hack/benchmark

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
BUILDTAGS=libcontainer
1+
BUILDTAGS=
22

33
# if this session isn't interactive, then we don't want to allocate a
44
# TTY, which would fail, but if it is interactive, we do want to attach
@@ -13,7 +13,7 @@ DOCKER_RUN := docker run --rm -i $(DOCKER_FLAGS) "$(DOCKER_IMAGE)"
1313

1414
export GOPATH:=$(CURDIR)/vendor:$(GOPATH)
1515

16-
all: client daemon
16+
all: client daemon shim
1717

1818
bin:
1919
mkdir -p bin/
@@ -27,6 +27,9 @@ client: bin
2727
daemon: bin
2828
cd containerd && go build -tags "$(BUILDTAGS)" -o ../bin/containerd
2929

30+
shim: bin
31+
cd containerd-shim && go build -tags "$(BUILDTAGS)" -o ../bin/containerd-shim
32+
3033
dbuild:
3134
@docker build --rm --force-rm -t "$(DOCKER_IMAGE)" .
3235

api/grpc/server/server.go

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ func (s *apiServer) CreateContainer(ctx context.Context, c *types.CreateContaine
3333
e := supervisor.NewEvent(supervisor.StartContainerEventType)
3434
e.ID = c.Id
3535
e.BundlePath = c.BundlePath
36-
e.Stdout = c.Stdout
37-
e.Stderr = c.Stderr
38-
e.Stdin = c.Stdin
39-
e.Console = c.Console
4036
e.StartResponse = make(chan supervisor.StartResponse, 1)
4137
if c.Checkpoint != "" {
4238
e.Checkpoint = &runtime.Checkpoint{
@@ -49,14 +45,16 @@ func (s *apiServer) CreateContainer(ctx context.Context, c *types.CreateContaine
4945
}
5046
sr := <-e.StartResponse
5147
return &types.CreateContainerResponse{
52-
Pid: uint32(sr.Pid),
48+
Stdin: sr.Stdin,
49+
Stdout: sr.Stdout,
50+
Stderr: sr.Stderr,
5351
}, nil
5452
}
5553

5654
func (s *apiServer) Signal(ctx context.Context, r *types.SignalRequest) (*types.SignalResponse, error) {
5755
e := supervisor.NewEvent(supervisor.SignalEventType)
5856
e.ID = r.Id
59-
e.Pid = int(r.Pid)
57+
e.Pid = r.Pid
6058
e.Signal = syscall.Signal(int(r.Signal))
6159
s.sv.SendEvent(e)
6260
if err := <-e.Err; err != nil {
@@ -79,7 +77,7 @@ func (s *apiServer) AddProcess(ctx context.Context, r *types.AddProcessRequest)
7977
}
8078
e := supervisor.NewEvent(supervisor.AddProcessEventType)
8179
e.ID = r.Id
82-
e.Process = process
80+
e.ProcessSpec = process
8381
e.Console = r.Console
8482
e.Stdin = r.Stdin
8583
e.Stdout = r.Stdout
@@ -88,7 +86,7 @@ func (s *apiServer) AddProcess(ctx context.Context, r *types.AddProcessRequest)
8886
if err := <-e.Err; err != nil {
8987
return nil, err
9088
}
91-
return &types.AddProcessResponse{Pid: uint32(e.Pid)}, nil
89+
return &types.AddProcessResponse{}, nil
9290
}
9391

9492
func (s *apiServer) CreateCheckpoint(ctx context.Context, r *types.CreateCheckpointRequest) (*types.CreateCheckpointResponse, error) {
@@ -140,21 +138,23 @@ func (s *apiServer) ListCheckpoint(ctx context.Context, r *types.ListCheckpointR
140138
if container == nil {
141139
return nil, grpc.Errorf(codes.NotFound, "no such containers")
142140
}
143-
checkpoints, err := container.Checkpoints()
144-
if err != nil {
145-
return nil, err
146-
}
147141
var out []*types.Checkpoint
148-
for _, c := range checkpoints {
149-
out = append(out, &types.Checkpoint{
150-
Name: c.Name,
151-
Tcp: c.Tcp,
152-
Shell: c.Shell,
153-
UnixSockets: c.UnixSockets,
154-
// TODO: figure out timestamp
155-
//Timestamp: c.Timestamp,
156-
})
157-
}
142+
/*
143+
checkpoints, err := container.Checkpoints()
144+
if err != nil {
145+
return nil, err
146+
}
147+
for _, c := range checkpoints {
148+
out = append(out, &types.Checkpoint{
149+
Name: c.Name,
150+
Tcp: c.Tcp,
151+
Shell: c.Shell,
152+
UnixSockets: c.UnixSockets,
153+
// TODO: figure out timestamp
154+
//Timestamp: c.Timestamp,
155+
})
156+
}
157+
*/
158158
return &types.ListCheckpointResponse{Checkpoints: out}, nil
159159
}
160160

@@ -167,7 +167,6 @@ func (s *apiServer) State(ctx context.Context, r *types.StateRequest) (*types.St
167167
m := s.sv.Machine()
168168
state := &types.StateResponse{
169169
Machine: &types.Machine{
170-
Id: m.ID,
171170
Cpus: uint32(m.Cpus),
172171
Memory: uint64(m.Cpus),
173172
},
@@ -179,13 +178,9 @@ func (s *apiServer) State(ctx context.Context, r *types.StateRequest) (*types.St
179178
}
180179
var procs []*types.Process
181180
for _, p := range processes {
182-
pid, err := p.Pid()
183-
if err != nil {
184-
logrus.WithField("error", err).Error("get process pid")
185-
}
186181
oldProc := p.Spec()
187182
procs = append(procs, &types.Process{
188-
Pid: uint32(pid),
183+
Pid: p.ID(),
189184
Terminal: oldProc.Terminal,
190185
Args: oldProc.Args,
191186
Env: oldProc.Env,
@@ -231,7 +226,7 @@ func (s *apiServer) Events(r *types.EventsRequest, stream types.API_EventsServer
231226
ev = &types.Event{
232227
Type: "exit",
233228
Id: evt.ID,
234-
Pid: uint32(evt.Pid),
229+
Pid: evt.Pid,
235230
Status: uint32(evt.Status),
236231
}
237232
case supervisor.OOMEventType:

0 commit comments

Comments
 (0)
X Tutup