fuweid / embedshim

Provide task runtime implementation with pidfd and eBPF sched_process_exit tracepoint to manage deamonless container with low overhead.
Apache License 2.0
116 stars 10 forks source link

rewrite embedshim's task manager #5

Closed fuweid closed 2 years ago

fuweid commented 2 years ago
[PATCH 10] embedshim: store id and pin bpf in root dir

The host can be restarted. If we should store id allocator db in tmpfs,
it doesn't bring issue but the containerd log will show id reuse. I
think the uint64 range is bigger enough and it will be easy to debug the
trace ID when restart containerd if we store it in root dir.

BPF pinned dir is just aligned with id db.

[PATCH 9] embedshim: rename pid_monitor to exitsnoop

[PATCH 8] embedshim: rename struct embedshim to shim

[PATCH 7] embedshim: add helper function on bundle

* Rootfs() returns the bundleDir/rootfs path
* IsValid() returns nil if the bundleDir/work dir is still there, which
  is used to check the bundle is valid during restart containerd

[PATCH 6] embedshim: fix linter issue

[PATCH 5] embedshim: fix panic on close nil IO

[PATCH 4] embedshim: rewrite pid monitor

Rewrited the id allocator because we don't have to allocate id with
namespace and task ID and release it. The uin64 number range is totally
enough for us. Just keep it simpler with nextID() interface. And the
trace event ID can also used for exec process in the future.

Added traceEventId field in the initProcess because the trace event ID
is the identity of process.

And rewrite the monitor interface:

* subscribe -> traceInitProcess
* resubscribe -> repollingInitProces

I think it can be easy to understand.

[PATCH 3] embedshim: rename utils to runtime_utils

And remove unuse codes.

[PATCH 2] embedshim: rewrite init process

Basically, we should reuse the upstream pkg/process package. But the IO
design doesn't work with that. The initProcess should be redesigned to
work with embedshim.

In this commit, we rename Init to initProcess because we don't need to
export it. And then we make newInitProcess with bundle since the bundle
is the key store dir for us, especially when containerd restart.

[PATCH 1] embedshim: move bundle.go to pkg/bundle

[PATCH 0] embedshim: rewrite bundle handler

The bundle is the key store for reload. Besides the
rootfs/init.pid/config.json, the embedshim needs to store
stdio/options/eventID important information in bundle.

In order to manage files in bundle easily, this commit introduces option
design as newBundle' interface and bring helper to read the file in
bundle.

Signed-off-by: Wei Fu fuweid89@gmail.com