-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The logic for container process setup and launching is moved to a separate process. This process runs in parallel to the runtime and communicates to it via Unix Domain sockets. This enables running the northstar runtime in a multithreaded way without the danger of deadlocking with libc. ┌───────────┐ ┌────────┐ ┌────────────────────────────┐ │ Northstar ├────┤ Forker │ │ Container A │ │ Runtime │ └────┬───┘ │ ┌──────┐ ┌───────────────┐ │ └───────────┘ ├───────┼►│ Init ├─┤ Application A │ │ │ │ └──────┘ └───────────────┘ │ │ └────────────────────────────┘ │ │ ┌────────────────────────────┐ │ │ Container B │ │ │ ┌──────┐ ┌───────────────┐ │ ├───────┼►│ Init ├─┤ Application B │ │ │ │ └──────┘ └───────────────┘ │ │ └────────────────────────────┘ ▼ ... The `Forker` process must consequently be single threaded. Additionally, this patch introduces a small API for the container Init processes that enables the request to start new processes inside the container. This is a prerequisite to #454.
- Loading branch information
Alfonso Ros
committed
Jan 21, 2022
1 parent
92189a7
commit 8a02168
Showing
59 changed files
with
2,745 additions
and
2,262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,70 @@ | ||
@startuml container_startup | ||
|
||
create Client | ||
activate Client | ||
|
||
create Runtime | ||
activate Runtime | ||
Runtime -> Runtime: Check and Mount container | ||
|
||
create Forker | ||
Runtime -> Forker: Fork | ||
activate Forker | ||
|
||
Client -> Runtime: Connect: Hello | ||
Client <- Runtime: ConnectAck | ||
Client -> Runtime: Start container | ||
Runtime -> Runtime: Check and mount container(s) | ||
Runtime -> Runtime: Open PTY | ||
|
||
Runtime -> Forker: Create container | ||
|
||
create Trampoline | ||
Runtime -> Trampoline: Fork | ||
Forker -> Trampoline: Fork | ||
activate Trampoline | ||
Trampoline -> Trampoline: Create PID namespace | ||
|
||
create Init | ||
Trampoline -> Init: Fork | ||
activate Init | ||
Trampoline -> Runtime: Init PID | ||
Init -> Init: Mount, Chroot, UID / GID,\ndrop privileges, file descriptors | ||
|
||
Trampoline -> Forker: Forked init with PID | ||
destroy Trampoline | ||
Runtime -> Runtime: Wait for Trampoline exit (waitpid) | ||
Init -> Init: Wait for run signal (Condition::wait) | ||
|
||
Forker -> Forker: reap Trampoline | ||
|
||
Forker -> Runtime: Created init with PID | ||
|
||
Runtime -> Runtime: Configure cgroups | ||
Runtime -> Init: Signal run (Condition::notify) | ||
Runtime -> Runtime: Wait for execve (Condition::wait) | ||
Init -> Init: Mount, Chroot, UID / GID,\ndrop privileges, file descriptors | ||
Runtime -> Runtime: Configure debug | ||
Runtime -> Runtime: Configure PTY forward | ||
|
||
Runtime -> Forker: Exec container | ||
Forker -> Init: Exec Container | ||
create Container | ||
Init -> Container: Fork | ||
activate Container | ||
Forker <- Init: Exec | ||
Runtime <- Forker: Exec | ||
Client <- Runtime: Started | ||
Client <- Runtime: Notification: Started | ||
|
||
Init -> Init: Wait for container to exit (waitpid) | ||
Container -> Container: Setup PTY | ||
Container -> Container: Set seccomp filter | ||
Container -> : Execve(..) | ||
Runtime -> Runtime: Condition pipe closed: Container is started | ||
note left: Condition pipe is CLOEXEC | ||
Container -> Init: Exit | ||
... | ||
Container -> Init: SIGCHLD | ||
destroy Container | ||
Init -> Runtime: Exit | ||
Runtime -> Runtime: Read exit status from pipe or waitpid on pid of init | ||
|
||
Init -> Init: waitpid: Exit status of container | ||
Init -> Forker: Container exit status | ||
destroy Init | ||
|
||
Forker -> Runtime: Container exit status | ||
Runtime -> Runtime: Stop PTY thread | ||
Runtime -> Runtime: Destroy cgroups | ||
Runtime -> Runtime: Destroy cgroups | ||
Client <- Runtime: Notification: Exit | ||
|
||
@enduml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.